private void cmdViewBuyer_Click(object sender, EventArgs e) { try { int tempID = int.Parse(lsvPhones.SelectedItems[0].SubItems[16].Text); if (tempID.ToString() != "") { DelegateReadUserByPhoneID dn = MysqlControl.ReadUserByPhoneID; IAsyncResult iar = dn.BeginInvoke(lsvPhones.SelectedItems[0].SubItems[16].Text, null, null); while (iar.IsCompleted == false) { Application.DoEvents(); } MysqlController.LXUser tempUser = dn.EndInvoke(iar); var iCustem = new frmEditCustem(isBusy, iLoginUser) { TopLevel = false, Dock = DockStyle.Fill, Parent = Parent }; iCustem.SetCustom(tempUser); iCustem.Show(); iCustem.BringToFront(); Parent.BringToFront(); } } catch (Exception) { return; } }
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; }