123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- 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 System.Web.UI.WebControls;
- using LYFZ.BLL;
- namespace LYFZ.Software.MainBusiness.Customers
- {
- public partial class Othercustomers : LYFZ.Software.UI.Customers.Othercustomers
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL_ErpOrder();
- BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
- LYFZ.BLL.BLL_ErpSystemLogs slgbll = new BLL_ErpSystemLogs();
- public Othercustomers()
- {
- this.Shown += Othercustomers_Shown;
- this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
- this.btnAdd.Click += btnAdd_Click;
- this.btnUpdate.Click += btnUpdate_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnClose.Click += btnClose_Click;
- this.btnSlect.Click += btnSlect_Click;
- this.btnAddExcel.Click += btnAddExcel_Click;
- this.chkBaby.CheckedChanged += chkBaby_CheckedChanged;
- this.btnExport.Click += btnExport_Click;
- this.btnTexting.Click += btnTexting_Click;
- this.chkONkh.CheckedChanged += chkONkh_CheckedChanged;
- this.Resize += Othercustomers_Resize;
- this.btnAddExcel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.DataImport);
- this.btnAdd.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.Add);
- this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.Update);
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OtherCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.Delete);
- this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.DataExport);
- this.btnTexting.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OldCustomerCompetence, CustomAttributes.OperatingAuthority.SMSSend);
- }
- /// <summary>
- /// 窗体加载
- /// </summary>
- void Othercustomers_Shown(object sender, EventArgs e)
- {
- string StrColumnName = "ID,Cus_CustomerNumber,客户姓名,性别,客户生日,客户QQ,微信号,客户电话,客户固定电话,客户所在地区,客户工作单位,录入时间,客户地址";
- this.dgvData.DataColumns(StrColumnName, strHideField: "ID,Cus_CustomerNumber");
- this.dgvData.Columns["录入时间"].Width = 110;
- this.dgvData.Columns["客户工作单位"].Width = 250;
- this.dgvData.Columns["客户地址"].Width = 500;
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 发送短信
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnTexting_Click(object sender, EventArgs e)
- {
- try
- {
- string Cus_Telephone = "";
- string Sj1 = "";
- LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms set = new SMSManagement.SmsSend.FrmSendSms();
- if (this.dgvData.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("选择你要发送短信的客户!");
- return;
- }
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- Cus_Telephone = this.dgvData.SelectedRows[i].Cells["客户电话"].Value.ToString();
- //检查手机合法性
- string okPhones = "";
- LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(Cus_Telephone.Replace('/', ','), ref okPhones);
- if (!string.IsNullOrEmpty(okPhones))
- { Sj1 += okPhones + ","; }
- }
- set.Phone = Sj1.Trim(',');
- set.ShowDialog();
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExport_Click(object sender, EventArgs e)
- {
- this.dgvData.ExportDataTable();
- }
- /// <summary>
- /// 儿童客户
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkBaby_CheckedChanged(object sender, EventArgs e)
- {
- if (this.chkBaby.Checked)
- {
- this.btnUpdate.Enabled = false;
- this.chkONkh.Checked = false;
- this.PublicFunctionRows();
- }
- else
- {
- this.btnUpdate.Enabled = true;
- if (!this.chkONkh.Checked)
- this.PublicFunctionRows();
- }
- }
- /// <summary>
- /// 未使用过客户
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkONkh_CheckedChanged(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 导入Excel
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAddExcel_Click(object sender, EventArgs e)
- {
- ImportExcel open = new ImportExcel();
- open.Type = 0;
- if (open.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSlect_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 创建行
- /// </summary>
- void PublicFunctionRows()
- {
- if (this.dgvData.Rows.Count > 0)
- { this.dgvData.Rows.Clear(); }
- DataTable dt = new DataTable();
- StringBuilder str = new StringBuilder();
- if (this.cmbQueryText.Text != "")
- {
- str.Append(" and (Cus_Name like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_QQ like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_Telephone like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_FixedPhone like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_Region like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_Address like '%" + this.cmbQueryText.Text.Trim() + "%' or Cus_WorkUnit like '%" + this.cmbQueryText.Text.Trim() + "%')");
- }
- if (this.chkBaby.Checked)
- {
- str.Append(" and Cus_Type='儿童'");
- }
- else
- {
- str.Append(" and (Cus_Type!='儿童' or Cus_Type is null) ");
- }
- bool ischkONkh = this.chkONkh.Checked;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (ischkONkh)
- {
- dt = DAL.DAL_ErpCustomer.GetInvalidCustomer(str.ToString());
- }
- else
- {
- dt = DAL.DAL_ErpCustomer.GetOtherCustomer(str.ToString());
- }
- });
- this.lbStatistics.Text = String.Format("共计 {0} 条", dt.Rows.Count);
- if (dt.Rows.Count > 0)
- {
- #region
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- //客户ID
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["ID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户编号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_CustomerNumber"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户姓名
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //性别
- cell = new DataGridViewTextBoxCell();
- cell.Value = Convert.ToBoolean(dt.Rows[t]["Cus_Sex"]) ? "女" : "男";
- dgvr.Cells.Add(cell);
- //客户生日
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Birthday"].ToString().Trim() == "1900/1/1 0:00:00" ? "" : dt.Rows[t]["Cus_Birthday"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户QQ
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_QQ"].ToString().Trim();
- dgvr.Cells.Add(cell);
- // 微信号
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_MicroSignal"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户电话
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Telephone"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户固定电话
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_FixedPhone"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户所在地区
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Region"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //客户工作单位
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_WorkUnit"].ToString().Trim();
- dgvr.Cells.Add(cell);
- //录入时间
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[t]["Cus_CreateDateTime"], "yyyy-MM-dd HH:mm");
- dgvr.Cells.Add(cell);
- //客户地址
- cell = new DataGridViewTextBoxCell();
- cell.Value = dt.Rows[t]["Cus_Address"].ToString().Trim();
- dgvr.Cells.Add(cell);
- this.dgvData.Rows.Add(dgvr);
- }
- #endregion
- }
- this.dgvData.ClearSelection();
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- this.btnUpdate_Click(this, null);
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 删除按钮
- /// </summary>
- void btnDelete_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvData.SelectedRows.Count > 0)
- {
- List<int> ctlist = new List<int>();
- if (MessageBoxCustom.Show("是否删除!", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- string StrMagess = "";
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_CustomerNumber = '" + this.dgvData.SelectedRows[i].Cells["Cus_CustomerNumber"].Value.ToString().Trim() + "' And Mc_Status = '1' And Mc_CradNumber != ''", ShowColumnName: "ID").Tables[0];
- if (dt.Rows.Count <= 0)
- {
- clist.Add(ctbll.GetDeleteCommandInfo("Cus_CustomerNumber", "=", this.dgvData.SelectedRows[i].Cells["Cus_CustomerNumber"].Value.ToString().Trim()));
- clist.Add(slgbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除客户资料, "删除联系人资料:" + this.dgvData.SelectedRows[i].Cells["客户姓名"].Value.ToString() + ",时间:" + SDateTime.Now, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID())));
- }
- else
- { StrMagess += this.dgvData.SelectedRows[i].Cells["客户姓名"].Value.ToString() + ","; }
- }
- bool IsDelete = false;
- if (clist.Count > 0)
- {
- if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
- { IsDelete = true; }
- }
- if (!string.IsNullOrEmpty(StrMagess))
- { StrMagess += "但客户:" + StrMagess.TrimEnd(',') + "已办有会员卡,不允许删除!"; }
- if (IsDelete)
- { StrMagess = "删除成功!" + StrMagess; }
- else
- { StrMagess = "删除失败!" + StrMagess; }
- MessageBoxCustom.Show(StrMagess);
- if (StrMagess.IndexOf("成功") != -1)
- { this.PublicFunctionRows(); }
- }
- }
- else
- { MessageBoxCustom.Show("请选中要删除的信息!"); }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 更新按钮
- /// </summary>
- void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (this.dgvData.SelectedRows.Count > 0)
- {
- if (this.dgvData.CurrentRow != null)
- {
- if (this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.ColumnIndex >= 0)
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmAddContacts frm = new OldCustomer.FrmAddContacts();
- frm.YouID = this.dgvData.CurrentRow.Cells["ID"].Value.ToString();
- frm.Zhuangtai = "编辑";
- if (frm.ShowDialog() == DialogResult.OK)
- { this.PublicFunctionRows(); }
- }
- }
- }
- else
- { MessageBoxCustom.Show("请选择修改信息!"); }
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 添加按钮
- /// </summary>
- void btnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmAddContacts frm = new OldCustomer.FrmAddContacts();
- frm.Zhuangtai = "添加";
- frm.Qita = true;
- if (frm.ShowDialog() == DialogResult.OK)
- {
- MessageBoxCustom.Show("添加成功!");
- this.PublicFunctionRows();
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void Othercustomers_Resize(object sender, EventArgs e)
- {
- switch (this.panelONkh.Location.Y)
- {
- case 3: this.flowLayoutPanel1.Height = 36; break;
- case 37: this.flowLayoutPanel1.Height = 70; break;
- }
- }
- }
- }
|