private void cmdSearch_Click(object sender, EventArgs e) { lsvUser.Items.Clear(); MysqlController.ReturnUsers tempUser = MysqlControl.SearchUser(cmbGroup.SelectedIndex, cmbBXK.SelectedIndex); int pos = 0; if (tempUser.isError != true) { if (tempUser.UserNum > 0) { for (int i = 0; i < tempUser.UserNum; i++) { if (tempUser.UserInfo[i].iFlag) { //开始筛选 for (int j = 0; j < tempUser.UserInfo[i].BuyPhones.Length; j++) { if (cmbPhoneType.SelectedIndex != 0 || cmbPhoneType.SelectedIndex != -1) { //筛选制定品牌 if (tempUser.UserInfo[i].BuyPhones[j].PhoneBrand == (cmbPhoneType.SelectedIndex - 1).ToString()) { //筛选具体手机型号 if (cmbPhoneType.SelectedIndex != -1) { if (tempUser.UserInfo[i].BuyPhones[j].PhoneName == cmbPhoneName.Text) { MixUser[pos] = i.ToString(); } } else { MixUser[pos] = i.ToString(); } } } } pos++; } pos = 0; if (cmbNetwork.SelectedIndex != 0 || cmbNetwork.SelectedIndex != -1) { switch (cmbNetwork.SelectedIndex) { case 1: for (int j = 0; j < MixUser.Length; j++) { if (MixUser[j] != null && MixUser[j] != "") { if (!string.IsNullOrEmpty(tempUser.UserInfo[int.Parse(MixUser[j])].Phone)) { switch (tempUser.UserInfo[int.Parse(MixUser[j])].Phone.Substring(0, 3)) { case "135": case "136": case "137": case "138": case "139": case "150": case "151": case "157": case "158": case "159": case "188": SecMixUser[pos] = j.ToString(); break; } switch (tempUser.UserInfo[int.Parse(MixUser[j])].Phone.Substring(0, 4)) { case "1340": case "1341": case "1342": case "1343": case "1344": case "1345": case "1346": case "1347": case "1348": SecMixUser[pos] = j.ToString(); break; } pos++; } } } break; case 2: for (int j = 0; j < MixUser.Length; j++) { if (MixUser[j] != null && MixUser[j] != "") { if (!string.IsNullOrEmpty(tempUser.UserInfo[int.Parse(MixUser[j])].Phone)) { switch (tempUser.UserInfo[int.Parse(MixUser[j])].Phone.Substring(0, 3)) { case "130": case "131": case "132": case "156": SecMixUser[pos] = j.ToString(); break; } switch (tempUser.UserInfo[int.Parse(MixUser[j])].Phone.Substring(0, 4)) { case "1349": SecMixUser[pos] = j.ToString(); break; } pos++; } } } break; case 3: for (int j = 0; j < MixUser.Length; j++) { if (MixUser[j] != null && MixUser[j] != "") { if (!string.IsNullOrEmpty(tempUser.UserInfo[int.Parse(MixUser[j])].Phone)) { switch (tempUser.UserInfo[int.Parse(MixUser[j])].Phone.Substring(0, 3)) { case "133": case "153": case "187": case "189": SecMixUser[pos] = j.ToString(); break; } pos++; } } } break; } } } /* * 移动:1340-1348,135,136,137,138,139,150,151,159,158,157(3G号码段),188(3G号码段已经审批下来了) * 联通:130,131,131,156,1349 * 中国电信(CDMA号码段已经是它的了)133,153,187,189 */ for (int i = 0; i < SecMixUser.Length; i++) { if (SecMixUser[i] != null && SecMixUser[i] != "") { lsvUser.Items.Add(tempUser.UserInfo[i].UserCName); lsvUser.Items[i].SubItems.Add(tempUser.UserInfo[i].UserName); lsvUser.Items[i].SubItems.Add(tempUser.UserInfo[i].Phone); lsvUser.Items[i].SubItems.Add(""); lsvUser.Items[i].SubItems.Add(""); lsvUser.Items[i].SubItems.Add(tempUser.UserInfo[i].LXCredit); lsvUser.Items[i].SubItems.Add(tempUser.UserInfo[i].haveBXK ? "有" : "没有"); lsvUser.Items[i].SubItems.Add(tempUser.UserInfo[i].BXKid); } } } else { MessageBox.Show("搜索不到任何符合条件的用户,请重试!", Application.ProductName, MessageBoxButtons.OK); } } else { MessageBox.Show("搜索用户失败!请重试", Application.ProductName, MessageBoxButtons.OK); } }
private void cmdAddUser_Click(object sender, EventArgs e) { var tempUser = new MysqlController.LXUser(); var tempPhone = new MysqlController.LXPhones[1]; tempPhone[0].PhoneBrand = cmbPhoneBrand.SelectedIndex.ToString(); tempPhone[0].PhoneIMEI = txtPhoneIMEI.Text; tempPhone[0].PhoneName = cmbPhoneName.Text; tempPhone[0].PhonePrice = txtPhonePrice.Text; tempPhone[0].PhoneRealPrice = txtRealPrice.Text; tempPhone[0].PhoneSeller = cmbSeller.SelectedIndex.ToString(); tempPhone[0].PhoneHasEquip = ckbEquip.Checked; tempPhone[0].PhoneDate = dtpBuyPhone.Value.Year + dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') + dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0'); tempPhone[0].PhoneHasWarranty = ckbWarranty.Checked; tempPhone[0].PhoneWarrantyType = cmbWarrantyType.SelectedIndex.ToString(); tempPhone[0].PhoneWarrantyDuration = cmbWarrantyDuration.SelectedIndex.ToString(); tempPhone[0].PhoneWarrantyDate = tempPhone[0].PhoneDate; tempPhone[0].PhoneIsDelete = false; tempPhone[0].phone_supplier = txtSupplier.Text; tempPhone[0].PhoneEquipPrice = txtEquipPrice.Text; tempPhone[0].PhoneEquipRealPrice = txtEquipRealPrice.Text; tempPhone[0].PhoneIsLegal = ckbisLegal.Checked; tempPhone[0].PhoneIsHKLegal = ckbisHKLegal.Checked; tempPhone[0].PhoneIsUnLegal = ckbisUnLegal.Checked; tempPhone[0].PhoneWarrantyPrice = txtWarrantyPrice.Text; tempUser.BuyPhones = tempPhone; tempUser.Email = txtEmail.Text; tempUser.BXKid = txtBXKid.Text; tempUser.ContectAddress = txtContectAddress.Text; tempUser.haveBXK = ckbBXK.Checked; tempUser.LXCredit = txtPhonePrice.Text; tempUser.Phone = txtPhone.Text; tempUser.QQ = txtQQ.Text; tempUser.UserCName = txtUserCName.Text; tempUser.UserName = txtUserName.Text; tempUser.UserTip = txtUserTip.Text; tempUser.Telephone = txtTelephone.Text; tempUser.userType = cmbType.SelectedIndex; switch (cmbGroup.SelectedIndex) { case 0: tempUser.GroupID = 15; break; case 1: tempUser.GroupID = 16; break; case 2: tempUser.GroupID = 17; break; case 3: tempUser.GroupID = 18; break; default: tempUser.GroupID = 0; break; } tempUser.Birthday = dtpBirthday.Value.Year + dtpBirthday.Value.Month.ToString().PadLeft(2, '0') + dtpBirthday.Value.Day.ToString().PadLeft(2, '0'); //首先检测数据 if (txtPhone.Text == "" || !Regex.IsMatch(txtPhone.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机号码_, Application.ProductName, MessageBoxButtons.OK); return; } //txtUnDebt if (txtUnDebt.Text == "" || !Regex.IsMatch(txtUnDebt.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的已支付款额_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtPhonePrice.Text == "" || !Regex.IsMatch(txtPhonePrice.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机销售价格_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtRealPrice.Text == "" || !Regex.IsMatch(txtRealPrice.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机成本价格_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtPhoneIMEI.Text == "") { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机IMEI_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtEquipPrice.Text == "" || !Regex.IsMatch(txtEquipPrice.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的配件销售价格_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtEquipRealPrice.Text == "" || !Regex.IsMatch(txtEquipRealPrice.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的配件成本价格_, Application.ProductName, MessageBoxButtons.OK); return; } if (txtWarrantyPrice.Text == "" || !Regex.IsMatch(txtWarrantyPrice.Text.Trim(), @"^[0-9]+$")) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的保修卡销售价格_, Application.ProductName, MessageBoxButtons.OK); return; } if (ckbBXK.Checked && txtBXKid.Text == "") { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_已经勾选保修卡_但未填写保修卡编号_, Application.ProductName, MessageBoxButtons.OK); return; } if (cmbPhoneBrand.SelectedIndex == -1) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请选择正确的生产厂商_, Application.ProductName, MessageBoxButtons.OK); return; } if (cmbPhoneName.SelectedIndex == -1) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请选择正确的手机型号_, Application.ProductName, MessageBoxButtons.OK); return; } if (cmbSeller.SelectedIndex == -1) { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请选择正确的销售人员_, Application.ProductName, MessageBoxButtons.OK); return; } if ( MessageBox.Show( "是否确认递交以下内容?\r\n客户名称:" + txtUserCName.Text + "\r\n手机号码:" + txtPhone.Text + "\r\n保修卡:" + txtBXKid.Text + "\r\n购机时间:" + dtpBuyPhone.Value.Year + dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') + dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0') + "\r\n手机品牌:" + cmbPhoneBrand.Text + "\r\n手机型号:" + cmbPhoneName.Text + "\r\n手机购买价格:" + txtPhonePrice.Text + "\r\n实际成本:" + txtRealPrice.Text + "\r\n销售人员:" + cmbSeller.Text + "\r\n手机串号:" + txtPhoneIMEI.Text + "\r\n供应商:" + txtSupplier.Text, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK) { //这里进行手机号验证; isBusy.Visible = true; DelegateGetSingleUser dn = MysqlControl.GetSingleUser; IAsyncResult iar = dn.BeginInvoke("", txtPhone.Text, "", null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnUsers tempUsers = dn.EndInvoke(iar); if (tempUsers.UserNum > 0) { isBusy.Visible = false; string BuyPhone = ""; for (int i = 0; i < tempUsers.UserInfo[0].BuyPhones.Length; i++) { BuyPhone = BuyPhone + "\r\n" + tempUsers.UserInfo[0].BuyPhones[i].PhoneName; } if ( MessageBox.Show( Resources.frmNewCustom_cmdAddUser_Click_已经存在该用户_将跳转到用户修改页面进行操作_ + "\r\n用户详细信息:\r\n" + tempUsers.UserInfo[0].UserCName + "\r\n手机号码:" + tempUsers.UserInfo[0].Phone + "\r\n保修卡号:" + tempUsers.UserInfo[0].BXKid + "\r\n已经购买手机:" + BuyPhone, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK) { var iCustem = new frmEditCustem(isBusy, iLoginUser) { TopLevel = false, Dock = DockStyle.Fill, Parent = Parent }; iCustem.SetCustom(tempUsers.UserInfo[0]); iCustem.Show(); iCustem.BringToFront(); Parent.BringToFront(); iCustem.AddPhone(tempPhone[0], cmbPayment.SelectedIndex, txtUnDebt.Text); return; } } //正常添加 cmdAddUser.Enabled = false; isBusy.Visible = true; DelegateAddUser dnAdd = MysqlControl.AddUser; IAsyncResult iarAdd = dnAdd.BeginInvoke(tempUser, null, null); while (iarAdd.IsCompleted == false) { Application.DoEvents(); } MysqlController.ReturnResult iResult = dnAdd.EndInvoke(iarAdd); if (iResult.isSuccess) { //这里去增加到客户欠款里 if (cmbPayment.SelectedIndex != 0) { var iDebt = new MysqlController.LXCustomDebt { DebtDate = dtpBuyPhone.Value.Year + dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') + dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0'), DebtCustom = txtUserCName.Text, DebtDetail = "购买手机:" + cmbPhoneBrand.Text + " - " + cmbPhoneName.Text, DebtisFix = false, DebtPrice = int.Parse(txtPhonePrice.Text) + int.Parse(txtEquipPrice.Text) + int.Parse(txtWarrantyPrice.Text) - int.Parse(txtUnDebt.Text), DebtType = cmbPayment.SelectedIndex - 1 }; var iDResult = new MysqlController.ReturnResult { isSuccess = false }; while (!iDResult.isSuccess) { DelegateAddCustomDebt dnACD = MysqlControl.AddCustomDebt; IAsyncResult iarACD = dnACD.BeginInvoke(iDebt, null, null); while (iarACD.IsCompleted == false) { Application.DoEvents(); } iDResult = dnACD.EndInvoke(iarACD); } } var iLog = new clsLog.LogPart(); iLog.LogDate = DateTime.Now.Year + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0'); iLog.LogTime = DateTime.Now.Hour + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0'); iLog.LogUser = iLoginUser; iLog.LogDetail = @"添加客户:" + txtUserCName.Text; DelegateAddLog dnlog = LogControl.AddLog; IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null); while (iarlog.IsCompleted == false) { Application.DoEvents(); } dnlog.EndInvoke(iarlog); MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_添加用户成功_已经添加用户_ + txtUserCName.Text, Application.ProductName, MessageBoxButtons.OK); txtLastAdd.Text = Resources.frmNewCustom_cmdAddUser_Click_刚刚添加的用户为_ + txtUserCName.Text + Resources.frmNewCustom_cmdAddUser_Click___购买机型为 + cmbPhoneName.Text; CleanUI(); } else { MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_ + iResult.ErrDesc, Application.ProductName, MessageBoxButtons.OK); } } isBusy.Visible = false; cmdAddUser.Enabled = true; }