Beispiel #1
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            if (txtCash.Text == "" || !Regex.IsMatch(txtCash.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_请填写正确的客户欠款金额_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }
            if (txtMaster.Text == "")
            {
                MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_请填写正确的客户欠款人名称_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtName.Text == "")
            {
                MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_请填写正确的客户欠款事项_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            cmdAdd.Enabled = false;

            if (MessageBox.Show(
                    "是否确认如下递交内容?\r\n欠款人:" + txtMaster.Text + "\r\n欠款时间:" + dtpTime.Value.Year +
                    dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                    dtpTime.Value.Day.ToString().PadLeft(2, '0') + "\r\n欠款金额:" + txtCash.Text + "元\r\n欠款事项:" + txtName.Text +
                    "\r\n到帐方式:" + cmbPayment.Text, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                var iCustemDebt = new MysqlController.LXCustomDebt
                {
                    DebtDate =
                        dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                        dtpTime.Value.Day.ToString().PadLeft(2, '0'),
                    DebtCustom  = txtMaster.Text,
                    DebtDetail  = txtName.Text,
                    DebtPrice   = double.Parse(txtCash.Text),
                    DebtisFix   = false,
                    DebtType    = cmbPayment.SelectedIndex,
                    DebtFixDate =
                        dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                        dtpTime.Value.Day.ToString().PadLeft(2, '0'),
                    DebtisInCircle = ckbinCircle.Checked
                };
                isBusy.Visible = true;
                DelegateAddCustomDebt dn = MysqlControl.AddCustomDebt;

                IAsyncResult iar = dn.BeginInvoke(iCustemDebt, null, null);

                while (iar.IsCompleted == false)
                {
                    Application.DoEvents();
                }

                MysqlController.ReturnResult iResult = dn.EndInvoke(iar);
                isBusy.Visible = false;
                if (iResult.isSuccess)
                {
                    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 = @"增加客户欠款记录" + txtMaster + txtName + txtCash;

                    DelegateAddLog dnlog = LogControl.AddLog;

                    IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null);

                    while (iarlog.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    dnlog.EndInvoke(iarlog);

                    MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_添加客户欠款成功_, Application.ProductName,
                                    MessageBoxButtons.OK);
                    CleanUI();
                    RefreshCustom(dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                  dtpTime.Value.Day.ToString().PadLeft(2, '0'), false);
                }
                else
                {
                    MessageBox.Show(Resources.frmCustomDebt_cmdAdd_Click_添加客户欠款失败_失败原因_ + iResult.ErrDesc,
                                    Application.ProductName,
                                    MessageBoxButtons.OK);
                }
            }
            cmdAdd.Enabled = true;
        }
Beispiel #2
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            //这里判断输入值正确性


            if (txtPrice.Text == "" || !Regex.IsMatch(txtPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmEquipSell_cmdAdd_Click_请填写正确的配件销售价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtRealPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmEquipSell_cmdAdd_Click_请填写正确的配件成本价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtName.Text == "")
            {
                MessageBox.Show(Resources.frmEquipSell_cmdAdd_Click_请填写正确的配件名称_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            cmdAdd.Enabled = false;

            if (MessageBox.Show(
                    "是否确认如下递交内容?\r\n配件名目:" + txtName.Text + "\r\n销售时间:" + dtpTime.Value.Year +
                    dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                    dtpTime.Value.Day.ToString().PadLeft(2, '0') + "\r\n销售价格:" + txtPrice.Text + "元\r\n实际成本:" +
                    txtRealPrice.Text + "元\r\n供货商:" + txtSupplier.Text + "\r\n销售人:" + cmbSeller.Text + "\r\n支付类型:" +
                    cmbPayment.Text + "\r\n备注:" +
                    txtBackup.Text, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                isBusy.Visible = true;
                var tempEquip = new MysqlController.LXEquip
                {
                    EquipDate =
                        dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                        dtpTime.Value.Day.ToString().PadLeft(2, '0'),
                    EquipBackup    = txtBackup.Text,
                    EquipName      = txtName.Text,
                    EquipPrice     = double.Parse(txtPrice.Text),
                    EquipRealPrice = double.Parse(txtRealPrice.Text),
                    EquipSellers   = cmbSeller.Text,
                    EquipSupplier  = txtSupplier.Text,
                    EquipPayment   = cmbPayment.SelectedIndex,
                    EquipBuyer     = txtEquipBuyer.Text
                };

                DelegateAddSellEquip dn = MysqlControl.AddSellEquip;

                IAsyncResult iar = dn.BeginInvoke(tempEquip, null, null);

                while (iar.IsCompleted == false)
                {
                    Application.DoEvents();
                }

                MysqlController.ReturnResult iResult = dn.EndInvoke(iar);

                if (iResult.isSuccess)
                {
                    if (cmbPayment.SelectedIndex != 0)
                    {
                        var iCustomDebt = new MysqlController.LXCustomDebt
                        {
                            DebtCustom = txtName.Text,
                            DebtType   = cmbPayment.SelectedIndex - 1,
                            DebtDate   =
                                dtpTime.Value.Year +
                                dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                dtpTime.Value.Day.ToString().PadLeft(2, '0'),
                            DebtDetail  = "购买配件:" + txtName.Text + " 备注:" + txtBackup.Text,
                            DebtisFix   = false,
                            DebtEquipID = iResult.PhoneID,
                            DebtPrice   =
                                Math.Round(
                                    double.Parse(txtPrice.Text) - double.Parse(txtUnDebt.Text), 2),
                            DebtFixDate =
                                DateTime.Now.Year +
                                DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                DateTime.Now.Day.ToString().PadLeft(2, '0'),
                            DebtisInCircle = true,
                        };
                        var iDResult = new MysqlController.ReturnResult {
                            isSuccess = false
                        };
                        while (!iDResult.isSuccess)
                        {
                            DelegateAddCustomDebt dn1 = MysqlControl.AddCustomDebt;

                            IAsyncResult iar1 = dn1.BeginInvoke(iCustomDebt, null, null);

                            while (iar1.IsCompleted == false)
                            {
                                Application.DoEvents();
                            }

                            iDResult = dn1.EndInvoke(iar1);
                        }
                    }

                    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 = @"增加配件销售记录:" + txtName.Text + "销售时间:" + dtpTime.Value.Year +
                                     dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                     dtpTime.Value.Day.ToString().PadLeft(2, '0');

                    DelegateAddLog dnlog = LogControl.AddLog;

                    IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null);

                    while (iarlog.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    dnlog.EndInvoke(iarlog);


                    isBusy.Visible = false;


                    MessageBox.Show(Resources.frmEquipSell_cmdAdd_Click_添加配件销售记录成功_已经成功添加 + txtName.Text,
                                    Application.ProductName, MessageBoxButtons.OK);
                    CleanUI();
                    RefreshPayout();
                }
                else
                {
                    isBusy.Visible = false;
                    MessageBox.Show(Resources.frmEquipSell_cmdAdd_Click_添加配件销售记录失败_错误原因_ + iResult.ErrDesc,
                                    Application.ProductName,
                                    MessageBoxButtons.OK);
                }
            }
            isBusy.Visible = false;
            cmdAdd.Enabled = true;
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            if (txtCash.Text == "" || !Regex.IsMatch(txtCash.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_请填写正确的手机收取价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRepairPrice.Text == "" || !Regex.IsMatch(txtRepairPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_请填写正确的手机维修价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtIndieFixPrice.Text == "" || !Regex.IsMatch(txtIndieFixPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的手机销售价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtName.Text == "")
            {
                MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_请填写正确的手机名称_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtIMEI.Text == "")
            {
                MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_请填写正确的手机IMEI_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            cmdAdd.Enabled = false;

            if (MessageBox.Show(
                    "是否确认如下递交内容?\r\n收取手机:" + txtName.Text + "\r\n收取时间:" + dtpTime.Value.Year +
                    dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                    dtpTime.Value.Day.ToString().PadLeft(2, '0') + "\r\n收取金额:" + txtCash.Text + "元\r\n维修金额:" +
                    txtRepairPrice.Text + "元\r\n手机串号:" + txtIMEI.Text + "\r\n经办人:" + cmbSellers.Text + "\r\n备注:" +
                    txtBackup.Text, Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                var iPhone = new MysqlController.RefundPhone
                {
                    RefundBackup = txtBackup.Text,
                    RefundDate   = dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                   dtpTime.Value.Day.ToString().PadLeft(2, '0'),
                    RefundIMEI         = txtIMEI.Text,
                    RefundName         = txtName.Text,
                    RefundPrice        = double.Parse(txtCash.Text),
                    RefundRepairPrice  = double.Parse(txtRepairPrice.Text),
                    RefundSeller       = cmdIndieSeller1.Text,
                    RefundRefundType   = cmbBinType.SelectedIndex,
                    RefundIsFix        = true,
                    RefundFixCommision = 0,
                    RefundFixPrice     = double.Parse(txtIndieFixPrice.Text),
                    RefundFixProfit    = 0,
                    RefundFixDate      =
                        dtpIndieFixDate.Value.Year +
                        dtpIndieFixDate.Value.Month.ToString().PadLeft(2, '0') +
                        dtpIndieFixDate.Value.Day.ToString().PadLeft(2, '0'),
                    RefundFixType   = cmdIndieSelltype.SelectedIndex,
                    RefundFixSeller = cmdIndieSeller2.Text
                };
                isBusy.Visible = true;
                DelegateAddRefundPhone dn = MysqlControl.AddIndieRefundPhone;

                IAsyncResult iar = dn.BeginInvoke(iPhone, null, null);

                while (iar.IsCompleted == false)
                {
                    Application.DoEvents();
                }

                MysqlController.ReturnResult iResult = dn.EndInvoke(iar);
                isBusy.Visible = false;
                if (iResult.isSuccess)
                {
                    isBusy.Visible = true;

                    if (cmbSellType.SelectedIndex != 0)
                    {
                        var iCustomDebt = new MysqlController.LXCustomDebt
                        {
                            DebtCustom = txtUserName.Text,
                            DebtType   = cmbSellType.SelectedIndex - 1,
                            DebtDate   =
                                dtpFixDate.Value.Year +
                                dtpFixDate.Value.Month.ToString().PadLeft(2, '0') +
                                dtpFixDate.Value.ToString().PadLeft(2, '0'),
                            DebtDetail = "购买二手机:" + txtUserName.Text,
                            DebtisFix  = false,
                            DebtBinID  = 0,
                            DebtPrice  =
                                Math.Round(
                                    double.Parse(txtFixPrice.Text) - double.Parse(txtUnDebt.Text),
                                    2),
                            DebtFixDate =
                                DateTime.Now.Year +
                                DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                DateTime.Now.Day.ToString().PadLeft(2, '0'),
                            DebtisInCircle = true
                        };
                        var iDResult = new MysqlController.ReturnResult {
                            isSuccess = false
                        };
                        while (!iDResult.isSuccess)
                        {
                            DelegateAddCustomDebt dn1 = MysqlControl.AddCustomDebt;

                            IAsyncResult iar1 = dn1.BeginInvoke(iCustomDebt, null, null);

                            while (iar1.IsCompleted == false)
                            {
                                Application.DoEvents();
                            }

                            iDResult = dn1.EndInvoke(iar1);
                        }
                    }
                    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 = @"添加用户手机返收:" + txtName.Text + "收取时间:" + dtpTime.Value.Year +
                                     dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                     dtpTime.Value.Day.ToString().PadLeft(2, '0') + "收取金额:" + txtCash.Text + "元";

                    DelegateAddLog dnlog = LogControl.AddLog;

                    IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null);

                    while (iarlog.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    dnlog.EndInvoke(iarlog);

                    isBusy.Visible = false;

                    MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_添加二手机回收完成_已成功添加_ + txtName.Text,
                                    Application.ProductName, MessageBoxButtons.OK);
                    CleanUI();
                    RefreshPayout(0, dtpTime.Value.Year + dtpTime.Value.Month.ToString().PadLeft(2, '0') +
                                  dtpTime.Value.Day.ToString().PadLeft(2, '0'), false);
                }
                else
                {
                    MessageBox.Show(Resources.frmBinPhone_cmdAdd_Click_添加二手机回收失败_失败原因_ + iResult.ErrDesc,
                                    Application.ProductName, MessageBoxButtons.OK);
                }
            }
            cmdAdd.Enabled = true;
        }
Beispiel #5
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            cmdUpdate.Enabled = false;
            isBusy.Visible    = true;
            try
            {
                int    RefundID       = int.Parse(lsvPhones.SelectedItems[0].Text);
                double RefundFixPrice = 0;
                try
                {
                    RefundFixPrice = double.Parse(lsvPhones.SelectedItems[0].SubItems[10].Text);
                }
                catch (Exception)
                {
                    RefundFixPrice = 0;
                }
                string FixDate = "";
                if (ckbisSold.Checked)
                {
                    FixDate = dtpFixDate.Value.Year +
                              dtpFixDate.Value.Month.ToString().PadLeft(2, '0') +
                              dtpFixDate.Value.Day.ToString().PadLeft(2, '0');
                }
                else
                {
                    RefundFixPrice = 0;
                    FixDate        = "";
                }


                DelegateFixRefundPhone dn = MysqlControl.FixRefundPhone;

                IAsyncResult iar = dn.BeginInvoke(ckbisSold.Checked, FixDate, RefundFixPrice,
                                                  RefundID, cmbSellType.SelectedIndex, cmbSellers.Text, null,
                                                  null);

                while (iar.IsCompleted == false)
                {
                    Application.DoEvents();
                }

                MysqlController.ReturnResult iResult = dn.EndInvoke(iar);

                if (iResult.isSuccess)
                {
                    isBusy.Visible = true;

                    if (cmbSellType.SelectedIndex != 0)
                    {
                        var iCustomDebt = new MysqlController.LXCustomDebt
                        {
                            DebtCustom = txtUserName.Text,
                            DebtType   = cmbSellType.SelectedIndex - 1,
                            DebtDate   =
                                dtpFixDate.Value.Year +
                                dtpFixDate.Value.Month.ToString().PadLeft(2, '0') +
                                dtpFixDate.Value.ToString().PadLeft(2, '0'),
                            DebtDetail = "购买二手机:" + txtUserName.Text,
                            DebtisFix  = false,
                            DebtBinID  = RefundID,
                            DebtPrice  =
                                Math.Round(
                                    double.Parse(txtFixPrice.Text) - double.Parse(txtUnDebt.Text),
                                    2),
                            DebtFixDate =
                                DateTime.Now.Year +
                                DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                DateTime.Now.Day.ToString().PadLeft(2, '0'),
                            DebtisInCircle = true
                        };
                        var iDResult = new MysqlController.ReturnResult {
                            isSuccess = false
                        };
                        while (!iDResult.isSuccess)
                        {
                            DelegateAddCustomDebt dn1 = MysqlControl.AddCustomDebt;

                            IAsyncResult iar1 = dn1.BeginInvoke(iCustomDebt, null, null);

                            while (iar1.IsCompleted == false)
                            {
                                Application.DoEvents();
                            }

                            iDResult = dn1.EndInvoke(iar1);
                        }
                    }

                    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 = @"更新用户手机返收记录 编号为" + RefundID;

                    DelegateAddLog dnlog = LogControl.AddLog;

                    IAsyncResult iarlog = dnlog.BeginInvoke(iLog, null, null);

                    while (iarlog.IsCompleted == false)
                    {
                        Application.DoEvents();
                    }

                    dnlog.EndInvoke(iarlog);

                    isBusy.Visible = false;

                    MessageBox.Show(
                        Resources.frmBinPhone_cmdUpdate_Click_修改二手机回收完成_已成功更改_ +
                        lsvPhones.SelectedItems[0].SubItems[2].Text,
                        Application.ProductName, MessageBoxButtons.OK);
                    //CleanUI();
                    RefreshPayout(iSaveType, iSavestrDate, iSaveisSold);
                }
                else
                {
                    MessageBox.Show(Resources.frmBinPhone_cmdUpdate_Click_修改二手机回收失败_失败原因_ + iResult.ErrDesc,
                                    Application.ProductName, MessageBoxButtons.OK);
                }
            }
            catch (Exception)
            {
                isBusy.Visible    = false;
                cmdUpdate.Enabled = true;
                return;
            }
            isBusy.Visible    = false;
            cmdUpdate.Enabled = true;
        }
Beispiel #6
0
        private void cmdAddUser_Click(object sender, EventArgs e)
        {
            //首先检测数据

            if (txtPhone.Text == "" || !Regex.IsMatch(txtPhone.Text.Trim(), @"^[0-9]+$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机号码_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtPhone2.Text != "" && !Regex.IsMatch(txtPhone2.Text.Trim(), @"^[0-9]+$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机号码_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }
            //txtUnDebt

            if (txtUnDebt.Text == "" || !Regex.IsMatch(txtUnDebt.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的已支付款额_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtPhonePrice.Text == "" || !Regex.IsMatch(txtPhonePrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机销售价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtRealPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机成本价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtScreenGuardPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的屏贴成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtBettaryPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的电池成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtSDCardPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的SD卡成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtShellPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的保护套成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtChargePrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的车载充电器成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtHeadPhonePrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的耳机成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtCardlePrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的车载支架成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtRealPrice.Text == "" || !Regex.IsMatch(txtOtherPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show("请填写正确的其他(赠品)成本价格", Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (txtPhoneIMEI.Text == "")
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的手机IMEI_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }


            if (txtWarrantyPrice.Text == "" || !Regex.IsMatch(txtWarrantyPrice.Text.Trim(), @"^(-?\d+)(\.\d+)?$"))
            {
                MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_请填写正确的保修卡销售价格_, Application.ProductName,
                                MessageBoxButtons.OK);
                return;
            }

            if (ckbWarranty.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)
            {
                cmdAddUser.Enabled = false;
                isBusy.Visible     = true;

                var tempPhone = new MysqlController.LXSellPhone();

                tempPhone.PhoneBattery    = double.Parse(txtBettaryPrice.Text);
                tempPhone.PhoneBrandid    = cmbPhoneBrand.SelectedIndex;
                tempPhone.PhoneCarCharger = double.Parse(txtChargePrice.Text);
                tempPhone.PhoneCarCradle  = double.Parse(txtCardlePrice.Text);
                tempPhone.PhoneDate       = dtpBuyPhone.Value.Year + dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') +
                                            dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0');
                tempPhone.PhoneHeadPhone         = double.Parse(txtHeadPhonePrice.Text);
                tempPhone.PhoneIMEI              = txtPhoneIMEI.Text;
                tempPhone.PhoneisDelete          = false;
                tempPhone.PhoneisHKLegal         = ckbisHKLegal.Checked;
                tempPhone.PhoneisLegal           = ckbisLegal.Checked;
                tempPhone.PhoneisUnLegal         = ckbisUnLegal.Checked;
                tempPhone.PhoneName              = cmbPhoneName.Text;
                tempPhone.PhoneOther             = double.Parse(txtOtherPrice.Text);
                tempPhone.PhonePayment           = cmbPayment.SelectedIndex;
                tempPhone.PhonePrice             = double.Parse(txtPhonePrice.Text);
                tempPhone.PhoneRealprice         = double.Parse(txtRealPrice.Text);
                tempPhone.PhoneScreenGuard       = double.Parse(txtScreenGuardPrice.Text);
                tempPhone.PhoneSDCARD            = double.Parse(txtSDCardPrice.Text);
                tempPhone.PhoneSeller            = cmbSeller.Text;
                tempPhone.PhoneShell             = double.Parse(txtShellPrice.Text);
                tempPhone.PhoneSupplier          = txtSupplier.Text;
                tempPhone.PhoneUserAddress       = txtContectAddress.Text;
                tempPhone.PhoneUserBXKid         = txtBXKid.Text;
                tempPhone.PhoneUsercellPhone     = txtPhone.Text;
                tempPhone.PhoneUsercellPhoneback = txtPhone2.Text;
                tempPhone.PhoneUseremail         = txtEmail.Text;
                tempPhone.PhoneUserName          = txtUserCName.Text;
                tempPhone.PhoneUserQQ            = txtQQ.Text;
                tempPhone.PhoneUserTelePhone     = txtTelephone.Text;
                tempPhone.PhoneUserTip           = txtUserTip.Text;
                tempPhone.PhoneUserType          = cmbType.SelectedIndex;
                tempPhone.PhoneWarranty          = ckbWarranty.Checked;
                tempPhone.PhoneWarrantyDate      = dtpBuyPhone.Value.Year +
                                                   dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') +
                                                   dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0');
                tempPhone.PhoneWarrantyDuration = cmbWarrantyDuration.SelectedIndex;
                tempPhone.PhoneWarrantyPrice    = double.Parse(txtWarrantyPrice.Text);
                tempPhone.PhoneWarrantyType     = cmbWarrantyType.SelectedIndex;

                //DelegateAddNewSell
                DelegateAddNewSell dnAdd = MysqlControl.AddNewSell;

                IAsyncResult iarAdd = dnAdd.BeginInvoke(tempPhone, null, null);

                while (iarAdd.IsCompleted == false)
                {
                    Application.DoEvents();
                }

                MysqlController.ReturnResult iResult = dnAdd.EndInvoke(iarAdd);

                if (iResult.isSuccess)
                {
                    //添加新销售成功 需要处理客户欠款及其余收尾工作

                    //添加欠款

                    /*
                     * 现金支付
                     *  刷卡支付
                     *  欠款支付
                     *  支付宝
                     */
                    if (cmbPayment.SelectedIndex != 0)
                    {
                        var iCustomDebt = new MysqlController.LXCustomDebt
                        {
                            DebtCustom = txtUserCName.Text,
                            DebtType   = cmbPayment.SelectedIndex - 1,
                            DebtDate   =
                                dtpBuyPhone.Value.Year +
                                dtpBuyPhone.Value.Month.ToString().PadLeft(2, '0') +
                                dtpBuyPhone.Value.Day.ToString().PadLeft(2, '0'),
                            DebtDetail  = "购买手机:" + cmbPhoneName.Text + " 备注:" + txtUserTip.Text,
                            DebtisFix   = false,
                            DebtPhoneID = iResult.PhoneID,
                            DebtPrice   =
                                Math.Round(
                                    double.Parse(txtPhonePrice.Text) -
                                    double.Parse(txtUnDebt.Text), 2),
                            DebtFixDate =
                                DateTime.Now.Year +
                                DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                DateTime.Now.Day.ToString().PadLeft(2, '0'),
                            DebtisInCircle = true,
                        };
                        var iDResult = new MysqlController.ReturnResult {
                            isSuccess = false
                        };
                        while (!iDResult.isSuccess)
                        {
                            DelegateAddCustomDebt dn1 = MysqlControl.AddCustomDebt;

                            IAsyncResult iar1 = dn1.BeginInvoke(iCustomDebt, null, null);

                            while (iar1.IsCompleted == false)
                            {
                                Application.DoEvents();
                            }

                            iDResult = dn1.EndInvoke(iar1);
                        }
                    }

                    //扫尾工
                    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;
                    cmdClear_Click(sender, e);
                }
                else
                {
                    MessageBox.Show(Resources.frmNewCustom_cmdAddUser_Click_ + iResult.ErrDesc, Application.ProductName,
                                    MessageBoxButtons.OK);
                }
                isBusy.Visible     = false;
                cmdAddUser.Enabled = true;
            }
        }