using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder
{
public partial class FrmTwoSalesOrderUpdate : LYFZ.Software.UI.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderUpdate
{
LYFZ.BLL.BLL_ErpPayment ptbll = new BLL.BLL_ErpPayment();
LYFZ.BLL.BLL_ErpTwoSalesOrder torbll = new BLL.BLL_ErpTwoSalesOrder();
public FrmTwoSalesOrderUpdate()
{
}
///
/// 客户编号
///
string StrClientNumber = "";
public bool IsSaveed = false;
public string Tsorder_Number;
Dictionary DictDataArray = new Dictionary();
///
/// 窗体加载
///
///
///
protected override void FrmTwoSalesOrderUpdate_Load(object sender, EventArgs e)
{
try
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtTsorder_Telephone);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACHBBCDBGJAJDF", this.CtvTsorder_Name);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbtreevConsumeType, StrWhere: "Sc_ClassCode!='BEBCADBFBCDFBGJHC' and Sc_ClassCode!='BEBCADBFBDDEGGABF' and Sc_ClassCode!='BEBCBFBICGDHCGBEJ'");
DataTable dt = torbll.GetView_TwoSalesOrder(" Tsorder_Number = '" + this.Tsorder_Number + "'").Tables[0];
if (dt.Rows.Count > 0)
{
this.cmbtreevConsumeType.Enabled = false;
this.txtTsorder_CustomerName.ReadOnly = true;
this.txtTsorder_Telephone.ReadOnly = true;
this.StrClientNumber = dt.Rows[0]["Tsorder_CustomerNumber"].ToString();
this.CtvTsorder_Name.Text = dt.Rows[0]["Tsorder_Name"].ToString();
this.txtTsorder_CustomerName.Text = dt.Rows[0]["Tsorder_CustomerName"].ToString();
this.txtTsorder_Telephone.Text = dt.Rows[0]["Tsorder_Telephone"].ToString();
this.txtTsorder_Money.Text = dt.Rows[0]["Tsorder_Money"].ToString();
this.txtTsorder_Quantity.Text = dt.Rows[0]["Tsorder_Quantity"].ToString();
this.cmbtreevConsumeType.TagFindText(dt.Rows[0]["Tsorder_Category"].ToString().Trim());
this.txtPay_OpenSingle.Text = dt.Rows[0]["User_Name"].ToString();
this.txtTsorder_PersonHandling.Text = dt.Rows[0]["Tsorder_PersonHandlingName"].ToString();
this.txtTsorder_Remark.Text = dt.Rows[0]["Tsorder_Remark"].ToString();
this.txtTsorder_CreateDatetime.Text = Convert.ToDateTime(dt.Rows[0]["Tsorder_CreateDatetime"]).ToString("yyyy-MM-dd");
this.Tsorder_Number = dt.Rows[0]["Tsorder_Number"].ToString();
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 设置项目名称
///
///
///
protected override void btnSet_Click(object sender, EventArgs e)
{
try
{
LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
frm.TypeName = "BEBACHBBCDBGJAJDF";
frm.Version = "Version";
if (frm.ShowDialog() == DialogResult.OK)
{
string StrTag = this.CtvTsorder_Name.Tag.ToString().Trim();
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACHBBCDBGJAJDF", this.CtvTsorder_Name);
this.CtvTsorder_Name.TagFindText(StrTag);
}
}
catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
}
///
/// 设置二销类别
///
///
///
protected override void btnSet2_Click(object sender, EventArgs e)
{
try
{
LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new InitialSet.FrmSystemSet();
frm.TypeName = "BEBACDAJDFDDEACGJ";
frm.Version = "Version";
if (frm.ShowDialog() == DialogResult.OK)
{
string StrTag = this.cmbtreevConsumeType.Tag.ToString().Trim();
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEBACDAJDFDDEACGJ", this.cmbtreevConsumeType, StrWhere: "Sc_ClassCode!='BEBCADBFBCDFBGJHC' and Sc_ClassCode!='BEBCADBFBDDEGGABF' and Sc_ClassCode!='BEBCBFBICGDHCGBEJ'" );
this.cmbtreevConsumeType.TagFindText(StrTag);
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 输入框设置
///
///
///
protected override void txtTsorder_Quantity_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
///
/// 输入框设置
///
///
///
protected override void txtTsorder_Money_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
else if (Char.IsPunctuation(e.KeyChar))
{
if (e.KeyChar == '.')
{
if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
{ e.Handled = true; }
}
else if (e.KeyChar == '-')
{
if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('-') != -1)
{ e.Handled = true; }
}
else
{ e.Handled = true; }
}
}
///
/// 输入框设置
///
///
///
protected override void txtTsorder_Telephone_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
///
/// 保存
///
///
///
protected override void btnSave_Click(object sender, EventArgs e)
{
try
{
#region 判断不能为空
if (string.IsNullOrEmpty(this.CtvTsorder_Name.Text))
{
MessageBoxCustom.Show("项目名称不能为空!");
return;
}
if (string.IsNullOrEmpty(this.txtTsorder_CustomerName.Text))
{
MessageBoxCustom.Show("客户名称不能为空!");
return;
}
//if (string.IsNullOrEmpty(txtTsorder_Telephone.Text))
//{
// MessageBoxCustom.Show("联系电话不能为空!");
// return;
//}
//if (txtTsorder_Telephone.Text.Length != 11)
//{
// MessageBoxCustom.Show("联系电话必须为11位数!");
// return;
//}
if (string.IsNullOrEmpty(this.txtTsorder_Money.Text))
{
MessageBoxCustom.Show("金额不能为空!");
return;
}
if (string.IsNullOrEmpty(this.cmbtreevConsumeType.Text))
{
MessageBoxCustom.Show("二销类别不能为空!");
return;
}
if (string.IsNullOrEmpty(this.txtTsorder_CreateDatetime.Text))
{
MessageBoxCustom.Show("日期不能为空!");
return;
}
if (string.IsNullOrEmpty(this.txtTsorder_PersonHandling.Text))
{
MessageBoxCustom.Show("经手人不能为空!");
return;
}
#endregion
List clist = new List();
LYFZ.Model.Model_ErpTwoSalesOrder model = torbll.GetModel("Tsorder_Number", this.Tsorder_Number);
model.Tsorder_Name = CtvTsorder_Name.Text;
model.Tsorder_Money = Convert.ToDecimal(txtTsorder_Money.Text);
if (string.IsNullOrEmpty(txtTsorder_Quantity.Text))
{ model.Tsorder_Quantity = 0; }
else
{ model.Tsorder_Quantity = Convert.ToInt32(txtTsorder_Quantity.Text); }
model.Tsorder_Category = this.cmbtreevConsumeType.Tag.ToString().Trim();
if (string.IsNullOrEmpty(model.Tsorder_PhotoNames))
{ model.Tsorder_PhotoNames = ""; }
if (string.IsNullOrEmpty(model.Tsorder_Photography))
{ model.Tsorder_Photography = ""; }
if (string.IsNullOrEmpty(model.Tsorder_PhotoPickupName))
{ model.Tsorder_PhotoPickupName = ""; }
if (string.IsNullOrEmpty(model.Tsorder_PhotoPickup.ToString().Trim()))
{ model.Tsorder_PhotoPickup = 0; }
model.Tsorder_Remark = txtTsorder_Remark.Text;
model.Tsorder_UpdateDatetime = SDateTime.Now;
model.Tsorder_CustomerNumber = this.StrClientNumber;
clist.Add(torbll.GetUpdateCommandInfo(model));
List mlist = ptbll.GetModelList("Pay_OrdNumber='" + Tsorder_Number + "'");
for (int i = 0; i < mlist.Count; i++)
{
LYFZ.Model.Model_ErpPayment modelpt = mlist[i];
modelpt.Pay_TwoPinsCategory = this.cmbtreevConsumeType.Tag.ToString().Trim();
clist.Add(ptbll.GetUpdateCommandInfo(modelpt));
}
if (clist.Count > 0)
{
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
{
MessageBoxCustom.Show("保存成功!");
this.IsSaveed = true;
this.Close();
}
else
{ MessageBoxCustom.Show("保存失败!"); }
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 取消
///
///
///
protected override void btnCanle_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 选择客户
///
///
///
protected override void btnCustomer_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder.FrmCustomerSelete frm = new FrmCustomerSelete();
frm.ShowDialog();
if (!string.IsNullOrEmpty(frm.StrClientNumber))
{
DataTable dt = new BLL.BLL_ErpCustomer().GetList("Cus_CustomerNumber='" + frm.StrClientNumber + "'").Tables[0];
if (dt.Rows.Count > 0)
{
this.txtTsorder_CustomerName.ReadOnly = true;
this.txtTsorder_Telephone.ReadOnly = true;
this.StrClientNumber = frm.StrClientNumber;
this.txtTsorder_CustomerName.Text = dt.Rows[0]["Cus_Name"].ToString();
this.txtTsorder_Telephone.Text = dt.Rows[0]["Cus_Telephone"].ToString();
}
}
}
}
}