using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
namespace Core.StlMes.Client.GlBusiness
{
public partial class FrmSlmGlAccrued : FrmBase
{
public FrmSlmGlAccrued()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "doQuery":
doQuery();
break;
//case "doAdd":
// doAdd();
// break;
case "doAddInvoices":
doAddInvoices();
break;
case "doAddFreight":
doAddFreight();
break;
case "doUpdate":
doUpdate();
break;
case "doReset":
doReset();
break;
case "doDelete":
doDelete();
break;
case "Close":
this.Close();
break;
}
}
private string setCreateTimeStart(Object value)
{
DateTime time = Convert.ToDateTime(value);
DateTime endtime = new DateTime(time.Year, time.Month, time.Day, 0, 0, 0);
endtime.ToLongTimeString();
return endtime.ToString();
}
private string setCreateTimeEnd(Object value)
{
DateTime time = Convert.ToDateTime(value);
DateTime endtime = new DateTime(time.Year, time.Month, time.Day, 23, 59, 59);
return endtime.ToString();
}
///
/// 查询
///
public void doQuery()
{
this.dataTable1.Clear();
ArrayList parm = new ArrayList();
parm.Add(txt_balanceNo.Text.Trim());
parm.Add(txt_orderNo.Text.Trim());
if (QcreateTime_Begin.Value != null)//创建开始时间
{
parm.Add(setCreateTimeStart(QcreateTime_Begin.Value));
}
if (QcreateTime_End.Value != null)//创建结束时间
{
parm.Add(setCreateTimeEnd(QcreateTime_End.Value));
}
parm.Add(cbxBALANCE_TYPE.Value.ToString());
DataTable dt = ServerHelper.GetData("com.steering.pss.glbusiness.SlmGlAccrued.doQuery", new Object[] { parm }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
double ysPrice = 0;
double yfPrice = 0;
double sumYsPrice = 0;
double sumYfPrice = 0;
foreach (UltraGridRow ugr in ultraGrid1.Rows)
{
if (ugr.Cells["BALANCE_TPYE_DESC"].Value.ToString().Trim().Equals("应收")) {
Double.TryParse(ugr.Cells["BALNCE_TOL_PRICE"].Value.ToString().Trim(), out ysPrice);
sumYsPrice += ysPrice;
}
else if (ugr.Cells["BALANCE_TPYE_DESC"].Value.ToString().Trim().Equals("应付")) {
Double.TryParse(ugr.Cells["BALNCE_TOL_PRICE"].Value.ToString().Trim(), out yfPrice);
sumYfPrice += yfPrice;
}
}
sumPrice.Text = string.Format("{0:C}", Convert.ToDecimal(sumYsPrice - sumYfPrice));
}
///
/// 增加应收应付
///
public void doAdd()
{
orderManage head = new orderManage();
head.ob = this.ob;
head.ShowDialog();
}
///
/// 增加发票
///
public void doAddInvoices()
{
}
///
/// 增加运费
///
public void doAddFreight()
{
freightManage head = new freightManage();
head.ob = this.ob;
head.ShowDialog();
}
///
/// 重置
///
public void doReset()
{
txt_balanceNo.Text = "";
txt_orderNo.Text = "";
cbxBALANCE_TYPE.SelectedIndex = 0;
}
///
/// 删除
///
public void doDelete()
{
try
{
ultraGrid1.Update();
if (ultraGrid1.ActiveRow == null)
{
MessageUtil.ShowTips("请选择需要废除的数据!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确定废除?") == DialogResult.No)
{
return;
}
ArrayList all = new ArrayList();
//all.Add(UserInfo.GetUserID());
all.Add(UserInfo.GetUserName());
all.Add(ultraGrid1.ActiveRow.Cells["BALANCE_NO"].Value.ToString());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.glbusiness.SlmGlAccrued";
ccp.MethodName = "doDelete";
ccp.ServerParams = new object[] { all };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageBox.Show("废除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
doQuery();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
///
/// 修改票据
///
public void doUpdate()
{
try
{
this.ultraGrid1.UpdateData();
if (ultraGrid1.ActiveRow == null)
{
MessageUtil.ShowTips("请选择需要修改的数据!");
return;
}
if (MessageUtil.ShowYesNoAndQuestion("是否确定新增或修改票据?") == DialogResult.No)
{
return;
}
ArrayList all = new ArrayList();
//all.Add(UserInfo.GetUserID());
all.Add(ultraGrid1.ActiveRow.Cells["BILLS_KEY"].Text.ToString());
all.Add(UserInfo.GetUserName());
all.Add(ultraGrid1.ActiveRow.Cells["BALANCE_NO"].Value.ToString());
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.glbusiness.SlmGlAccrued";
ccp.MethodName = "doUpdate";
ccp.ServerParams = new object[] { all };
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode == -1) return;
MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
doQuery();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void FrmSlmGlPay_Load(object sender, EventArgs e)
{
QcreateTime_Begin.Value = DateTime.Now.AddMonths(-1);
QcreateTime_End.Value = DateTime.Now;
GridHelper.SetColumnsActivateAndColor(ultraGrid1.Rows.Band, "BILLS_KEY");
cbxBALANCE_TYPE.SelectedIndex = 0;
}
}
}