Ejemplo n.º 1
0
        //提交
        private void btnOK_Click(object sender, EventArgs e)
        {
            double totalPrice = 0;

            foreach (DataRow row in AddApplicationDT.Rows)
            {
                decimal MoneyDiscont = 1;
                switch (row["MoneyUnit"].ToString())
                {
                case "1":
                default:
                    MoneyDiscont = 1;
                    break;

                case "2":
                    MoneyDiscont = EmailControl.config.USrate;
                    break;

                case "3":
                    MoneyDiscont = EmailControl.config.HKrate;
                    break;

                case "4":
                    MoneyDiscont = EmailControl.config.MOPrate;
                    break;

                case "5":
                    MoneyDiscont = EmailControl.config.SGDrate;
                    break;

                case "6":
                    MoneyDiscont = EmailControl.config.MYRrate;
                    break;

                case "7":
                    MoneyDiscont = EmailControl.config.GBPrate;
                    break;

                case "8":
                    MoneyDiscont = EmailControl.config.EURrate;
                    break;

                case "9":
                    MoneyDiscont = EmailControl.config.JPYrate;
                    break;

                case "10":
                    MoneyDiscont = EmailControl.config.TWDrate;
                    break;
                }
                if (items.SelectItemByItemID(row["ItemID"].ToString()).Rows[0]["IsSpecial"].ToString() == "1")
                {
                }
                else
                {
                    totalPrice += double.Parse(row["Price"].ToString()) * double.Parse(row["Count"].ToString()) * double.Parse(row["ApprovalDiscount"].ToString()) / 100.00 * Convert.ToDouble(MoneyDiscont);
                }
            }
            if (AddApplicationDT.Rows.Count == 0)
            {
                MessageBox.Show("申请表中未添加项目内容");
            }
            else if (Login.LoginUser.RestAmount - totalPrice < 0)
            {
                MessageBox.Show("当前余额不足");
            }
            else if (applicationInfo.SelectApplicationByTransNo(txtTransNo.Text).Rows.Count > 0)
            {
                MessageBox.Show("已存在该交易号");
            }
            else
            {
                DataTable AddAppInfoDT = applicationInfo.SelectApplicationByTransNo("0");
                DataRow   dr           = AddAppInfoDT.NewRow();
                dr["TransNo"]          = transNo;
                dr["Applicants"]       = Login.LoginUser.UID;
                dr["ApplicantsName"]   = txtApplicantsName.Text;
                dr["ApplicantsNo"]     = txtApplicantsNo.Text;
                dr["Location"]         = txtLocation.Text;
                dr["ApplicantsDate"]   = DateTime.Now;
                dr["TotalPrice"]       = txtTotalPrice.Value;
                dr["Deadline"]         = txtDeadline.Value;
                dr["SalesDate"]        = txtDeadline.Value.AddYears(3);
                dr["ApprovalDate"]     = txtDeadline.Value.AddYears(3);
                dr["ApprovalDate2"]    = txtDeadline.Value.AddYears(3);
                dr["PurchaseLocation"] = txtPurchaseLocation.Text;
                dr["IsDelete"]         = 0;
                dr["AppState"]         = 0;
                dr["ApprovalState"]    = 0;
                dr["ApprovalState2"]   = 0;
                dr["Approval2"]        = Login.LoginUser.ManagerID;
                dr["StaffApproval"]    = 0;
                dr["MoneyUnit"]        = AddApplicationDT.Rows[0]["MoneyUnit"];
                foreach (DataRow addDr in AddApplicationDT.Rows)
                {
                    addDr["TransNo"] = dr["TransNo"];
                }
                AddAppInfoDT.Rows.Add(dr);
                try
                {
                    applicationInfo.SubmitApplicationInfo(AddAppInfoDT, totalPrice, Login.LoginUser.UID, 0);
                    applicationDetail.SubmitApplicationDetail(AddApplicationDT, totalPrice, Login.LoginUser.UID, 1);

                    Thread thread = new Thread(new ThreadStart(SendEmail));
                    thread.Start();


                    MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("提交失败,错误信息:" + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        //提交
        private void btnOK_Click(object sender, EventArgs e)
        {
            double totalPrice = 0;

            foreach (DataRow row in AddApplicationDT.Rows)
            {
                if (items.SelectItemByItemID(row["ItemID"].ToString()).Rows[0]["IsSpecial"].ToString() == "1")
                {
                }
                else
                {
                    totalPrice += double.Parse(row["Price"].ToString()) * double.Parse(row["Count"].ToString());
                }
            }
            if (AddApplicationDT.Rows.Count == 0)
            {
                MessageBox.Show("Items are not added in the application form");
            }
            else if (Login.LoginUser.RestAmount - totalPrice < 0)
            {
                MessageBox.Show("Your current balance is not enough");
            }
            else
            {
                string    transNo      = "NG" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
                DataTable AddAppInfoDT = applicationInfo.SelectApplicationByTransNo("0");
                DataRow   dr           = AddAppInfoDT.NewRow();
                dr["TransNo"]          = transNo;
                dr["Applicants"]       = Login.LoginUser.UID;
                dr["ApplicantsName"]   = txtApplicantsName.Text;
                dr["ApplicantsNo"]     = txtApplicantsNo.Text;
                dr["Location"]         = txtLocation.Text;
                dr["ApplicantsDate"]   = DateTime.Now;
                dr["TotalPrice"]       = txtTotalPrice.Value;
                dr["Deadline"]         = txtDeadline.Value;
                dr["PurchaseLocation"] = txtPurchaseLocation.Text;
                dr["IsDelete"]         = 0;
                dr["AppState"]         = 0;
                dr["ApprovalState"]    = 0;
                dr["ApprovalState2"]   = 0;
                dr["Approval2"]        = Login.LoginUser.ManagerID;
                dr["StaffApproval"]    = 0;
                foreach (DataRow addDr in AddApplicationDT.Rows)
                {
                    addDr["TransNo"] = dr["TransNo"];
                }
                AddAppInfoDT.Rows.Add(dr);
                try
                {
                    applicationInfo.SubmitApplicationInfo(AddAppInfoDT, totalPrice, Login.LoginUser.UID, 0);
                    applicationDetail.SubmitApplicationDetail(AddApplicationDT, totalPrice, Login.LoginUser.UID, 1);
                    Thread thread = new Thread(new ThreadStart(SendEmail));
                    thread.Start();

                    MessageBox.Show("Submit Successe", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Submit Fail,Message:" + ex.Message);
                }
            }
        }
Ejemplo n.º 3
0
        private void BtnSubmitAddApp_Click(object sender, EventArgs e)
        {
            BaseData.Store store = new BaseData.Store();
            //if (store.SelectStoreInfoByStoreName(txtDeliverStore4.Text).Rows.Count == 0 || store.SelectStoreInfoByStoreName(txtReceiptStore4.Text).Rows.Count == 0)
            //{
            //    MessageBox.Show("收发店铺名错误");
            //}
            if (AddApplicationDT.Rows.Count == 0)
            {
                MessageBox.Show("申请表中未添加转货内容");
            }
            else if (txtCtrlID.Text == null || txtCtrlID.Text.Length == 0)
            {
                MessageBox.Show("请填写控制单号");
            }
            else if (cbDeliverStore.SelectedItem.ToString() == cbRecieveStore.SelectedItem.ToString())
            {
                MessageBox.Show("收发店面相同,无法添加");
            }
            else
            {
                int       TotalCount   = 0;
                double    TotalPrice   = 0;
                DataTable AddAppInfoDT = applicationInfo.SelectApplicationByCtrlID("0");
                DataRow   dr           = AddAppInfoDT.NewRow();
                dr["CtrlID"]         = txtCtrlID.Text;
                dr["DeliverStore"]   = cbDeliverStore.SelectedItem.ToString();
                dr["ReceiptStore"]   = cbRecieveStore.SelectedItem.ToString();
                dr["ApplicantsDate"] = DateTime.Now;
                dr["ApplicantsName"] = txtApplicant.Text;
                dr["ApplicantsPos"]  = txtApplicantPos.Text;
                dr["Applicants"]     = Login.LoginUser.UID;
                dr["Alert_Approval"] = 0;
                dr["Alert_Deliver"]  = 0;
                dr["Alert_Receipt"]  = 0;
                dr["ExchangeType"]   = cboExchangeType.SelectedItem.ToString();
                foreach (DataRow addDr in AddApplicationDT.Rows)
                {
                    addDr["CtrlID"] = dr["CtrlID"];
                    TotalCount     += (int)addDr["App_Count"];
                    TotalPrice     += ((int)addDr["App_Count"]) * ((double.Parse(addDr["Price"].ToString())));
                }
                dr["TotalCount"] = TotalCount;
                dr["TotalPrice"] = TotalPrice;
                AddAppInfoDT.Rows.Add(dr);

                if (TotalPrice > EmailControl.config.UpperLimit)
                {
                    DialogResult dres = MessageBox.Show("超出限额,是否继续提交?", "消息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (dres == DialogResult.OK)
                    {
                        try
                        {
                            applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                            applicationDetail.SubmitApplicationDetail(AddApplicationDT);
                            Thread thread = new Thread(new ThreadStart(SendEmail));
                            thread.Start();
                            MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("提交失败,错误信息:" + ex.Message);
                        }
                    }
                }
                else
                {
                    try
                    {
                        applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                        applicationDetail.SubmitApplicationDetail(AddApplicationDT);
                        Thread thread = new Thread(new ThreadStart(SendEmail));
                        thread.Start();
                        MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("提交失败,错误信息:" + ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void btnDataProcess_Click(object sender, EventArgs e)
        {
            AccessHelper ah = new AccessHelper();

            foreach (DataRow dr in dtStaDetail.Rows)
            {
                string    strCtrlID     = "";
                int       intNum        = int.Parse(dr["num"].ToString());
                int       intCI         = 1;
                int       intCurrentNum = 1;
                int       intTotalCount = 0;
                double    douTotalPrice = 0.00;
                string    strSQL        = "select * from applicationdetail where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                DataTable dtDataDetail  = ah.SelectToDataTable(strSQL);
                strSQL = "select * from ApplicationInfo where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                DataTable dtDataInfo   = ah.SelectToDataTable(strSQL);
                string    strOriCtrlID = "Auto" + DateTime.Now.ToString("HHmmssfff") + dtDataInfo.Rows[0]["Applicants"].ToString().Substring(0, 1);
                strCtrlID = strOriCtrlID;
                DataTable AddAppInfoDT   = applicationInfo.SelectApplicationByCtrlID("0");
                DataTable AddAppDetailDT = applicationDetail.SelectAppDetailByCtrlID("0");
                DataRow   drInfo         = AddAppInfoDT.NewRow();
                DataRow   drDetail       = AddAppDetailDT.NewRow();
                drInfo = dtDataInfo.Rows[0];

                foreach (DataRow drIN in dtDataDetail.Rows)
                {
                    drDetail = drIN;
                    if (intCurrentNum <= 20)
                    {
                        intCurrentNum++;
                        drInfo["CtrlID"]   = strCtrlID;
                        drDetail["CtrlID"] = strCtrlID;
                        intTotalCount     += (int)drDetail["App_Count"];
                        douTotalPrice     += ((int)drDetail["App_Count"]) * ((double.Parse(drDetail["Price"].ToString())));
                        AddAppDetailDT.Rows.Add(drDetail.ItemArray);
                    }
                    else
                    {
                        drInfo["TotalCount"] = intTotalCount;
                        drInfo["TotalPrice"] = douTotalPrice;
                        AddAppInfoDT.Rows.Add(drInfo.ItemArray);
                        applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                        applicationDetail.SubmitApplicationDetail(AddAppDetailDT);

                        intCurrentNum = 1;
                        intTotalCount = 0;
                        douTotalPrice = 0.00;
                        strCtrlID     = strOriCtrlID + intCI.ToString();
                        intCI++;
                        AddAppInfoDT.Clear();
                        AddAppDetailDT.Clear();
                        //drInfo = AddAppInfoDT.NewRow();
                        //drDetail = AddAppDetailDT.NewRow();
                        //drInfo = dtDataInfo.Rows[0];

                        intCurrentNum++;
                        drInfo["CtrlID"]   = strCtrlID;
                        drDetail["CtrlID"] = strCtrlID;
                        intTotalCount     += (int)drDetail["App_Count"];
                        douTotalPrice     += ((int)drDetail["App_Count"]) * ((double.Parse(drDetail["Price"].ToString())));
                        AddAppDetailDT.Rows.Add(drDetail.ItemArray);
                    }
                }
                if (AddAppDetailDT.Rows.Count > 0)
                {
                    drInfo["TotalCount"] = intTotalCount;
                    drInfo["TotalPrice"] = douTotalPrice;
                    AddAppInfoDT.Rows.Add(drInfo.ItemArray);
                    applicationInfo.SubmitApplicationInfo(AddAppInfoDT);
                    applicationDetail.SubmitApplicationDetail(AddAppDetailDT);

                    intCurrentNum = 1;
                    intTotalCount = 0;
                    douTotalPrice = 0.00;
                    //strCtrlID = strOriCtrlID + intCI.ToString();
                    //intCI++;
                    AddAppInfoDT.Clear();
                    AddAppDetailDT.Clear();
                }
                strSQL = "update applicationdetail set isdelete=1 where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                ah.ExecuteSQLNonquery(strSQL);
                strSQL = "update ApplicationInfo set isdelete=1 where CtrlID='" + dr["CtrlID"].ToString() + "' ";
                ah.ExecuteSQLNonquery(strSQL);
            }
            ah.Close();
            MessageBox.Show("处理完成!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            frmDataProcessing_Load(null, null);
        }