774 lines
25 KiB
C#
774 lines
25 KiB
C#
|
|
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 System.Text.RegularExpressions;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using WMS.Ctrl;
|
|||
|
|
using System.Collections;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
using WMS.Business;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
public partial class FrmUpCustomer : FormBase
|
|||
|
|
{
|
|||
|
|
#region 变量声明
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定的数据源
|
|||
|
|
/// </summary>
|
|||
|
|
public List<CustomerModel> list;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 实体
|
|||
|
|
/// </summary>
|
|||
|
|
CustomerModel model;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 目标页面对象
|
|||
|
|
/// </summary>
|
|||
|
|
// public FrmUpCustomerDet cus;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 操作标志 0 新增,1 修改
|
|||
|
|
/// </summary>
|
|||
|
|
public int flag = 0;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 焦点行
|
|||
|
|
/// </summary>
|
|||
|
|
public int rowFocus = 0;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public FrmUpCustomer()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmUpCustomer_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
FrmSelectModle = new CustomerModel();
|
|||
|
|
BindData();
|
|||
|
|
LEPCUS_TYPE.LoadData();
|
|||
|
|
lueTown.LoadData();
|
|||
|
|
lueCity.LoadData();
|
|||
|
|
luePro.LoadData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ChangeState()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
groupBox3.Enabled = false;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
list = ConvertHelper<CustomerModel>.ConvertToList(table);
|
|||
|
|
BSCustomer.DataSource = list.Count > 0 ? list[0] : new CustomerModel();
|
|||
|
|
gridControlUpCustomer.DataSource = list;
|
|||
|
|
gridView1.RefreshData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 绑定数据
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定数据
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindData()
|
|||
|
|
{
|
|||
|
|
model = new CustomerModel();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
CustomerModel model = new CustomerModel();
|
|||
|
|
//mode.Customer_id = this.txtUpCustomerID.Text;
|
|||
|
|
list = IBussFactory<BussCustomer>.Instance().GetCustomer(model);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载客户出错了:" + ex.Message);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
//foreach (CustomerModel mo in list)
|
|||
|
|
//{
|
|||
|
|
// if (mo.Status == "1")
|
|||
|
|
// {
|
|||
|
|
// mo.Status = "停用";
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// mo.Status = "正常";
|
|||
|
|
//}
|
|||
|
|
this.gridControlUpCustomer.DataSource = list;
|
|||
|
|
gridView1.RefreshData();
|
|||
|
|
if (list.Count > 0)
|
|||
|
|
{
|
|||
|
|
model = list[0];
|
|||
|
|
BSCustomer.DataSource = model;
|
|||
|
|
groupBox3.Enabled = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BSCustomer.DataSource = new CustomerModel();
|
|||
|
|
groupBox3.Enabled = false;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 按钮事件
|
|||
|
|
|
|||
|
|
#region 查询按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Search()
|
|||
|
|
{
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 删除按钮
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Del()
|
|||
|
|
{
|
|||
|
|
///首先判断有没有选中行,
|
|||
|
|
///然后string 变量 = this.gridView1.GetFocusedRowCellValue("Customer_name").ToString()
|
|||
|
|
///
|
|||
|
|
if (SystemCommon.ShowMessageBoxResult("是否删除该货主:" + this.gridView1.GetFocusedRowCellValue("Customer_name").ToString()) == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
string CustomerID = this.gridView1.GetFocusedRowCellValue("Customer_id").ToString();
|
|||
|
|
//this.gridView1.GetRowCellValue(this.gridView1.FocusedRowHandle, "Customer_id");
|
|||
|
|
int count = 0;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
count = IBussFactory<BussCustomer>.Instance().execCustomerDel(CustomerID);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("删除客户出错了:" + ex.Message);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (count > 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|||
|
|
}
|
|||
|
|
//gridView1.RefreshData();
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 刷新按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Refresh()
|
|||
|
|
{
|
|||
|
|
BindData();
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
//LockControl(true);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 新增按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Add()
|
|||
|
|
{
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
this.flag = 0;
|
|||
|
|
groupBox3.Enabled = true;
|
|||
|
|
txtCustomer_ID.Enabled = true;
|
|||
|
|
model = new CustomerModel();
|
|||
|
|
// string strNum = "KH" + System.DateTime.Now.Date.ToString("yyyyMMdd");
|
|||
|
|
//try
|
|||
|
|
//{
|
|||
|
|
// strNum += WebLockConfig.Instance.WebCustomerModel.execGetSerialNum();
|
|||
|
|
//}
|
|||
|
|
//catch (Exception ex)
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("网络连接错误!");
|
|||
|
|
//}
|
|||
|
|
// model.Customer_id = strNum;
|
|||
|
|
|
|||
|
|
BSCustomer.DataSource = model;
|
|||
|
|
BSCustomer.EndEdit();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 编辑按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 编辑按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Edit()
|
|||
|
|
{
|
|||
|
|
flag = 1;
|
|||
|
|
rowFocus = gridView1.FocusedRowHandle;
|
|||
|
|
if (rowFocus < 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择要编辑的供应商!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
groupBox3.Enabled = true;
|
|||
|
|
txtCustomer_ID.Enabled = false;
|
|||
|
|
|
|||
|
|
txtCustomer_Name.Focus();
|
|||
|
|
txtCustomer_Name.SelectAll();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 确认按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确认按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public override void Save()
|
|||
|
|
{
|
|||
|
|
// gridView1.Focus();
|
|||
|
|
if (!txtCustomer_Name.Enabled)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请选择增加或编辑操作!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (LEPCUS_TYPE.Text == "")
|
|||
|
|
//{
|
|||
|
|
// SystemCommon.ShowInfoMessageBox("客户分类不能为空!");
|
|||
|
|
// LEPCUS_TYPE.Focus();
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
if (txtCustomer_ID.Text.Trim() == "")
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("货主编号不能为空!");
|
|||
|
|
txtCustomer_ID.SelectAll();
|
|||
|
|
txtCustomer_ID.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CustomerModel m = new CustomerModel();
|
|||
|
|
m.Customer_id = txtCustomer_ID.Text;
|
|||
|
|
List<CustomerModel> lis = IBussFactory<BussCustomer>.Instance().GetCustomer(m);
|
|||
|
|
|
|||
|
|
if (lis.Count > 0 && flag == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("此编号已经存在!");
|
|||
|
|
txtCustomer_ID.Focus();
|
|||
|
|
txtCustomer_ID.SelectAll();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flag == 1 && lis.Count > 1)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("此编号已经存在!");
|
|||
|
|
txtCustomer_ID.Focus();
|
|||
|
|
txtCustomer_ID.SelectAll();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (txtCustomer_Name.Text.Trim() == "")
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("货主名称不能为空!");
|
|||
|
|
txtCustomer_Name.Focus();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (SystemCommon.ShowMessageBoxResult("确定此操作 ?") == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
string str_address = luePro.Text + " " + lueCity.Text + " " + lueTown.Text;
|
|||
|
|
|
|||
|
|
model.Telephone = txtTelephone.Text;
|
|||
|
|
model.Province_id = luePro.EditValue.ToString();
|
|||
|
|
model.City_id = lueCity.EditValue.ToString();
|
|||
|
|
model.Town_id = lueTown.EditValue.ToString();
|
|||
|
|
model.OperatorID = userData.USER_ID;
|
|||
|
|
model.OperateDate = System.DateTime.Now;
|
|||
|
|
BSCustomer.DataSource = model;
|
|||
|
|
BSCustomer.EndEdit();
|
|||
|
|
|
|||
|
|
CustomerModel customer = BSCustomer.DataSource as CustomerModel;
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
errText = IBussFactory<BussCustomer>.Instance().AddCustomer(customer);
|
|||
|
|
model.Address = str_address + " " + txtAddress.Text;
|
|||
|
|
}
|
|||
|
|
else if (flag == 1)
|
|||
|
|
{
|
|||
|
|
model.Address = txtAddress.Text;
|
|||
|
|
errText = IBussFactory<BussCustomer>.Instance().UpdateCustomer(customer);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("保存失败了:" + ex.Message);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (errText.Trim().Length == 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
BSCustomer.DataSource = model;
|
|||
|
|
model = new CustomerModel();
|
|||
|
|
//LockControl(true);
|
|||
|
|
BindData();
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
gridView1.FocusedRowHandle = rowFocus;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作失败!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Refresh();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 导入
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导入
|
|||
|
|
/// </summary>
|
|||
|
|
public void Import()
|
|||
|
|
{
|
|||
|
|
//LockControl(true);
|
|||
|
|
|
|||
|
|
OpenFileDialog fileDialog = new OpenFileDialog();
|
|||
|
|
fileDialog.Title = "导入货主资料";
|
|||
|
|
fileDialog.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx";
|
|||
|
|
DialogResult dialogResult = fileDialog.ShowDialog(this);
|
|||
|
|
if (dialogResult == DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Hashtable ht = new Hashtable();
|
|||
|
|
ht.Add("CUSTOMER_ID", "货主代码");
|
|||
|
|
ht.Add("CUSTOMER_NAME", "货主名称");
|
|||
|
|
ht.Add("CUSTOMER_SHORT_NAME", "货主简称");
|
|||
|
|
ht.Add("Cus_type_id", "货主级别");
|
|||
|
|
ht.Add("CUS_TYPE_NAME", "货主级别ISNAME");
|
|||
|
|
ht.Add("PY_NAME", "拼音简称");
|
|||
|
|
ht.Add("TELEPHONE", "手机");
|
|||
|
|
ht.Add("PHONE", "联系电话");
|
|||
|
|
ht.Add("FAX", "联系传真");
|
|||
|
|
ht.Add("ADDRESS", "联系地址");
|
|||
|
|
ht.Add("REMARK", "备注");
|
|||
|
|
|
|||
|
|
list = NPOIHelper<CustomerModel>.Import(fileDialog, ht);
|
|||
|
|
if (list == null || list.Count <= 0)
|
|||
|
|
{
|
|||
|
|
if (frmButtonItem.ContainsKey("SaveImport"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["SaveImport"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BSCustomer.DataSource = list;
|
|||
|
|
gridControlUpCustomer.DataSource = list;
|
|||
|
|
gridView1.RefreshData();
|
|||
|
|
if (list.FindAll(r => r.Customer_id == "").Count == list.Count)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("货主编号不能为空!请重新选择");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("SaveImport"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["SaveImport"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Cancel"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Cancel"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Refresh"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Refresh"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
//LockControl(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 导出
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出
|
|||
|
|
/// </summary>
|
|||
|
|
public void Export()
|
|||
|
|
{
|
|||
|
|
gridControlUpCustomer.ShowExportDialog();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 保存导入数据
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存导入数据
|
|||
|
|
/// </summary>
|
|||
|
|
public void SaveImport()
|
|||
|
|
{
|
|||
|
|
if (list.Count <= 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
List<CustomerModel> _list = new List<CustomerModel>();
|
|||
|
|
List<string> listID = IBussFactory<BussCustomer>.Instance().Import(list, ref _list);
|
|||
|
|
if (listID.Count > 0)
|
|||
|
|
{
|
|||
|
|
//string fileName = @"D:\客户分类导入错误日志" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
|
|||
|
|
string fileName = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "客户分类导入错误日志" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
|
|||
|
|
//fileName = Application.StartupPath.ToString();
|
|||
|
|
string strContent = "";
|
|||
|
|
|
|||
|
|
foreach (string str in listID)
|
|||
|
|
{
|
|||
|
|
strContent += str;
|
|||
|
|
strContent += "\r\n";
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
SystemCommon.WriteFile(fileName, strContent);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("写入日志出错!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
BSCustomer.DataSource = _list;
|
|||
|
|
gridControlUpCustomer.DataSource = _list;
|
|||
|
|
gridView1.RefreshData();
|
|||
|
|
string msg = "导入成功 " + (list.Count - listID.Count).ToString() + " 条数据, ";
|
|||
|
|
msg += "失败 " + listID.Count + "条 如上所示请重试.\r\n";
|
|||
|
|
msg += "成功数据已写入数据库,错误日志已写入 " + fileName;
|
|||
|
|
SystemCommon.ShowInfoMessageBox(msg);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("导入成功 " + list.Count + " 条数据!");
|
|||
|
|
BindData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//LockControl(true);
|
|||
|
|
|
|||
|
|
if (frmButtonItem.ContainsKey("Cancel"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Cancel"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Import"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Import"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Export"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Export"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("SaveImport"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["SaveImport"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Edit"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Del"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Del"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Refresh"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Refresh"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 事件
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// gridControl单击事件
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void gridControlUpCustomer_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (gridView1.FocusedRowHandle < 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
flag = 1;
|
|||
|
|
model = gridView1.GetRow(gridView1.FocusedRowHandle) as CustomerModel;
|
|||
|
|
BSCustomer.DataSource = model;
|
|||
|
|
//LockControl(true);
|
|||
|
|
|
|||
|
|
if (frmButtonItem.ContainsKey("Add"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Add"].Enabled = true;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Confirm"))
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Confirm"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
if (frmButtonItem.ContainsKey("Edit"))
|
|||
|
|
{
|
|||
|
|
if (gridControlUpCustomer.DataSource != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
frmButtonItem["Edit"].Enabled = true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
frmButtonItem["Edit"].Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 省份改变时绑定市
|
|||
|
|
/// <summary>
|
|||
|
|
/// 市份改变时绑定县市区
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void luePro_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(luePro.Properties.ValueMember) && luePro.EditValue != null && !string.IsNullOrEmpty(luePro.EditValue.ToString()))
|
|||
|
|
{
|
|||
|
|
//绑定城市数据
|
|||
|
|
AddressAreaModel addressAreaModel = new AddressAreaModel();
|
|||
|
|
addressAreaModel.Add_pid = luePro.EditValue.ToString();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable tabAddress = IBussFactory<BussAddressArea>.Instance().GetAddressArea(addressAreaModel);
|
|||
|
|
lueCity.Properties.DataSource = tabAddress;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("出错了Province_EditValueChanged:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 市份改变时绑定县市区
|
|||
|
|
/// <summary>
|
|||
|
|
/// 市份改变时绑定县市区
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void lueCity_EditValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(lueCity.Properties.ValueMember) && lueCity.EditValue != null && !string.IsNullOrEmpty(lueCity.EditValue.ToString()))
|
|||
|
|
{
|
|||
|
|
//绑定区县数据
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
|
|||
|
|
AddressAreaModel addressAreaModel = new AddressAreaModel();
|
|||
|
|
addressAreaModel.Add_pid = lueCity.EditValue.ToString();
|
|||
|
|
string strResult = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable tabAddress = IBussFactory<BussAddressArea>.Instance().GetAddressArea(addressAreaModel);
|
|||
|
|
lueTown.Properties.DataSource = tabAddress;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("出错了City_EditValueChanged:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|