//提交
        private void btnOK_Click(object sender, EventArgs e)
        {
            DataTable AddAppInfoDT = applicationInfo.SelectApplicationByTransNo(OldTransNo);

            if (AddApplicationDT.Rows.Count == 0)
            {
                MessageBox.Show("申请表中未添加项目内容");
            }
            else if (txtTransNo.Text == null || txtTransNo.Text.Length == 0)
            {
                MessageBox.Show("请填写交易号");
            }
            else if (OldTransNo != applicationInfo.TransNo && applicationInfo.SelectApplicationByTransNo(applicationInfo.TransNo).Rows.Count > 0)
            {
                MessageBox.Show("已存在该交易号");
            }
            else
            {
                if (Login.LoginUser.Character == 1)
                {
                    frmEditReason fer = new frmEditReason(applicationInfo.EditReason);
                    if (fer.ShowDialog() == DialogResult.OK)
                    {
                        AddAppInfoDT.Rows[0]["EditReason"]       = fer.EditReasonString;
                        AddAppInfoDT.Rows[0]["TransNo"]          = txtTransNo.Text;
                        AddAppInfoDT.Rows[0]["ApplicantsName"]   = txtApplicantsName.Text;
                        AddAppInfoDT.Rows[0]["ApplicantsNo"]     = txtApplicantsNo.Text;
                        AddAppInfoDT.Rows[0]["Location"]         = txtLocation.Text;
                        AddAppInfoDT.Rows[0]["TotalPrice"]       = txtTotalPrice.Value;
                        AddAppInfoDT.Rows[0]["Deadline"]         = txtDeadline.Value;
                        AddAppInfoDT.Rows[0]["PurchaseLocation"] = txtPurchaseLocation.Text;
                        //AddAppInfoDT.Rows[0]["MoneyUnit"] = AddApplicationDT.Rows[0]["MoneyUnit"];
                        AddAppInfoDT.Rows[0]["MoneyUnit"] = objMoneyUnit;
                        foreach (DataRow addDr in AddApplicationDT.Rows)
                        {
                            if (addDr.RowState != DataRowState.Deleted)
                            {
                                addDr["TransNo"] = applicationInfo.TransNo;
                            }
                        }
                        try
                        {
                            applicationInfo.UpdateApplicationInfo(AddAppInfoDT, double.Parse(txtTotalPrice.Value.ToString()), AddAppInfoDT.Rows[0]["Applicants"].ToString(), 0);
                            applicationDetail.UpdateApplicationDetail(AddApplicationDT, double.Parse(txtTotalPrice.Value.ToString()), AddAppInfoDT.Rows[0]["Applicants"].ToString(), 1);
                            //if (EditState == 1)
                            //{
                            //    applicationInfo.ApprovalNotApplication(txtTransNo.Text,Login.LoginUser.UID,Login.LoginUser.UserName,2,DateTime.Now);
                            //    EmailControl.ToEmployeeConfirm(applicationInfo);
                            //}
                            MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            DialogResult = DialogResult.OK;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("提交失败,错误信息:" + ex.Message);
                        }
                    }
                }
                else
                {
                    AddAppInfoDT.Rows[0]["TransNo"]          = txtTransNo.Text;
                    AddAppInfoDT.Rows[0]["ApplicantsName"]   = txtApplicantsName.Text;
                    AddAppInfoDT.Rows[0]["ApplicantsNo"]     = txtApplicantsNo.Text;
                    AddAppInfoDT.Rows[0]["Location"]         = txtLocation.Text;
                    AddAppInfoDT.Rows[0]["TotalPrice"]       = txtTotalPrice.Value;
                    AddAppInfoDT.Rows[0]["Deadline"]         = txtDeadline.Value;
                    AddAppInfoDT.Rows[0]["PurchaseLocation"] = txtPurchaseLocation.Text;
                    //AddAppInfoDT.Rows[0]["MoneyUnit"] = AddApplicationDT.Rows[0]["MoneyUnit"];
                    AddAppInfoDT.Rows[0]["MoneyUnit"]  = objMoneyUnit;
                    AddAppInfoDT.Rows[0]["EditReason"] = txtEditReason.Text;
                    foreach (DataRow addDr in AddApplicationDT.Rows)
                    {
                        if (addDr.RowState != DataRowState.Deleted)
                        {
                            addDr["TransNo"] = applicationInfo.TransNo;
                        }
                    }
                    try
                    {
                        applicationInfo.UpdateApplicationInfo(AddAppInfoDT, double.Parse(txtTotalPrice.Value.ToString()), AddAppInfoDT.Rows[0]["Applicants"].ToString(), 0);
                        applicationDetail.UpdateApplicationDetail(AddApplicationDT, double.Parse(txtTotalPrice.Value.ToString()), AddAppInfoDT.Rows[0]["Applicants"].ToString(), 1);
                        //if (EditState == 1)
                        //{
                        //    applicationInfo.ApprovalNotApplication(txtTransNo.Text,Login.LoginUser.UID,Login.LoginUser.UserName,2,DateTime.Now);
                        //    EmailControl.ToEmployeeConfirm(applicationInfo);
                        //}
                        MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("提交失败,错误信息:" + ex.Message);
                    }
                }
            }
        }
Esempio n. 2
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
            {
                frmEditReason fer = new frmEditReason(applicationInfo.EditReason);
                if (fer.ShowDialog() == DialogResult.OK)
                {
                    int       TotalCount   = 0;
                    double    TotalPrice   = 0;
                    DataTable AddAppInfoDT = applicationInfo.SelectApplicationByCtrlID(applicationInfo.CtrlID);
                    AddAppInfoDT.Rows[0]["EditReason"]     = fer.EditReasonString;
                    AddAppInfoDT.Rows[0]["CtrlID"]         = txtCtrlID.Text;
                    AddAppInfoDT.Rows[0]["DeliverStore"]   = cbDeliverStore.SelectedItem.ToString();
                    AddAppInfoDT.Rows[0]["ReceiptStore"]   = cbRecieveStore.SelectedItem.ToString();
                    AddAppInfoDT.Rows[0]["ApplicantsDate"] = dtAppDate.Value;
                    AddAppInfoDT.Rows[0]["ApplicantsName"] = txtApplicant.Text;
                    AddAppInfoDT.Rows[0]["ApplicantsPos"]  = txtApplicantPos.Text;
                    AddAppInfoDT.Rows[0]["Applicants"]     = Login.LoginUser.UID;
                    AddAppInfoDT.Rows[0]["ExchangeType"]   = cboExchangeType.SelectedItem.ToString();

                    foreach (DataGridViewRow addDr in dgvApplyProducts.Rows)
                    {
                        //addDr["CtrlID"] = AddAppInfoDT.Rows[0]["CtrlID"];
                        TotalCount += (int)addDr.Cells["numbers"].Value;
                        TotalPrice += ((int)addDr.Cells["numbers"].Value) * ((double.Parse(addDr.Cells["price"].Value.ToString())));
                    }
                    AddAppInfoDT.Rows[0]["TotalCount"] = TotalCount;
                    AddAppInfoDT.Rows[0]["TotalPrice"] = TotalPrice;

                    //foreach(DataRow dr in AddApplicationDT.Rows)
                    //{
                    //    dr["CtrlID"] = txtCtrlID.Text;
                    //}

                    if (Login.LoginUser.Character == 1)
                    {
                        if ((int)AddAppInfoDT.Rows[0]["ApprovalState"] != 1)
                        {
                            AddAppInfoDT.Rows[0]["ApprovalState"] = 0;
                        }
                        if ((int)AddAppInfoDT.Rows[0]["ApprovalState2"] != 1)
                        {
                            AddAppInfoDT.Rows[0]["ApprovalState2"] = 0;
                        }
                        if ((int)AddAppInfoDT.Rows[0]["DeliverState"] != 1)
                        {
                            AddAppInfoDT.Rows[0]["DeliverState"] = 0;
                        }
                        if ((int)AddAppInfoDT.Rows[0]["ReceiptState"] != 1)
                        {
                            AddAppInfoDT.Rows[0]["ReceiptState"] = 0;
                        }
                    }
                    if (TotalPrice > EmailControl.config.UpperLimit)
                    {
                        DialogResult dres = MessageBox.Show("超出限额,是否继续提交?", "消息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        if (dres == DialogResult.OK)
                        {
                            try
                            {
                                applicationInfo.UpdateApplicationInfo(AddAppInfoDT);
                                applicationDetail.UpdateApplicationDetail(AddApplicationDT);
                                MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                DialogResult = DialogResult.OK;
                                this.Close();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("提交失败,错误信息:" + ex.Message);
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            applicationInfo.UpdateApplicationInfo(AddAppInfoDT);
                            applicationDetail.UpdateApplicationDetail(AddApplicationDT);
                            MessageBox.Show("提交成功", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("提交失败,错误信息:" + ex.Message);
                        }
                    }
                }
            }
        }