BaoKai_202508_Wms_Jingwang_.../WMS.FrmBaseData/FrmUpCustomerDet.cs

178 lines
5.5 KiB
C#
Raw Permalink Normal View History

2025-08-24 21:52:42 +08:00
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;
using WMS.Frm.Base;
using WMS.Base.WebService;
using WMS.Model.Base;
using WMS.Common;
using System.Text.RegularExpressions;
namespace WMS.FrmBaseData
{
public partial class FrmUpCustomerDet : FormBase
{
/// <summary>
/// 客户信息Model
/// </summary>
public CustomerModel customerModel;
/// <summary>
/// 操作标志0 增加1 修改(默认为0)
/// </summary>
public int flg = 0;
public List<CustomerModel> list;
public FrmUpCustomerDet()
{
InitializeComponent();
}
//修改调用的构造函数
public FrmUpCustomerDet(CustomerModel customerModel, int flg)
{
this.customerModel = customerModel;
this.flg = flg;
InitializeComponent();
}
//确定提交事件
private void btnCommit_Click(object sender, EventArgs e)
{
if (LEPCUS_TYPE.Text == "")
{
SystemCommon.ShowInfoMessageBox("客户分类不能为空!");
LEPCUS_TYPE.Focus();
return;
}
if (txtCustomer_ID.Text.Trim() == "")
{
SystemCommon.ShowInfoMessageBox("客户编号不能为空!");
txtCustomer_ID.SelectAll();
txtCustomer_ID.Focus();
return;
}
else
{
Regex reg = new Regex(@"^([a-z]|[A-Z]|[0-9])+$");
if (!reg.IsMatch(this.txtCustomer_ID.Text.Trim()))
{
SystemCommon.ShowInfoMessageBox("托盘编号只能输入字母或数字!");
this.txtCustomer_ID.Focus();
this.txtCustomer_ID.SelectAll();
return;
}
}
if (txtCustomer_Name.Text.Trim() == "")
{
SystemCommon.ShowErrorMessageBox("客户名称不能为空!");
txtCustomer_Name.Focus();
return;
}
if (SystemCommon.ShowMessageBoxResult("确定此操作 ") != DialogResult.Yes)
{
return;
}
CustomerModel cusModel = BSCustomer.DataSource as CustomerModel;
if (chkCustomerstatusoff.Checked && !chkCustomerstatusIn.Checked)
{
cusModel.Status = "1";
}
if (chkCustomerstatusIn.Checked && !chkCustomerstatusoff.Checked)
{
cusModel.Status = "0";
}
//都不选择默认为正常
if (!chkCustomerstatusIn.Checked && !chkCustomerstatusoff.Checked)
{
customerModel.Status = "0";
}
//新增
string strcusModel = Newtonsoft.Json.JsonConvert.SerializeObject(cusModel);
string errText = string.Empty;
try
{
if (flg == 0)
{
errText = WebLockConfig.Instance.WebCustomerModel.AddCustomer(strcusModel);
}
else
{ errText = WebLockConfig.Instance.WebCustomerModel.UpdateCustomer(strcusModel); }
}
catch (Exception ex)
{
SystemCommon.ShowErrorMessageBox("网络连接错误!");
return;
}
if (errText.Trim().Length==0)
{
SystemCommon.ShowInfoMessageBox("操作成功!");
this.Close();
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
}
private void FrmUpCustomerDet_Load(object sender, EventArgs e)
{
BSCustomer.DataSource = this.customerModel;
LEPCUS_TYPE.LoadData();
if (customerModel.Status == "正常" || customerModel.Status == "" || customerModel.Status == null)
{
chkCustomerstatusIn.Checked = true;
//this.chkCustomerstatusoff.Checked = false;
}
else
{
chkCustomerstatusoff.Checked = true;
//this.chkCustomerstatusIn.Checked = false;
}
//新增的话默认为正常
if (this.flg == 0)
{
txtCustomer_ID.Focus();
}
else //如果为编辑操作则编号为不可操作状态
{
txtCustomer_ID.Enabled = false;
txtCustomer_ID.Properties.ReadOnly = true;
txtCustomer_Name.SelectAll();
txtCustomer_Name.Focus();
}
}
//checkEdit 去重选择
private void chkCustomerstatusIn_CheckedChanged(object sender, EventArgs e)
{
if (chkCustomerstatusIn.Checked)
{
chkCustomerstatusoff.Checked = !chkCustomerstatusIn.Checked;
}
}
//checkEdit 去重选择
private void chkCustomerstatusoff_CheckedChanged(object sender, EventArgs e)
{
if (chkCustomerstatusoff.Checked)
{
chkCustomerstatusIn.Checked = !chkCustomerstatusoff.Checked;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}