Esempio n. 1
0
 /// <summary>
 /// get all acccheckformdetail
 /// <summary>
 /// <param name=formid>formid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all acccheckformdetail</returns>
 public BindingCollection <modAccCheckFormDetail> GetDetail(string formid, out string emsg)
 {
     try
     {
         BindingCollection <modAccCheckFormDetail> modellist = new BindingCollection <modAccCheckFormDetail>();
         //Execute a query to read the categories
         string sql = string.Format("select a.form_id,a.seq,a.subject_id,b.subject_name,a.detail_id,a.detail_name,a.currency,mny,a.exchange_rate,a.check_no,a.check_type,a.bank_name,a.promise_date,a.remark "
                                    + "from acc_check_form_detail a inner join acc_subject_list b on a.subject_id=b.subject_id where a.form_id='{0}' order by a.form_id,a.seq", formid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modAccCheckFormDetail model = new modAccCheckFormDetail();
                 model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                 model.Seq          = dalUtility.ConvertToInt(rdr["seq"]);
                 model.SubjectId    = dalUtility.ConvertToString(rdr["subject_id"]);
                 model.SubjectName  = dalUtility.ConvertToString(rdr["subject_name"]);
                 model.DetailId     = dalUtility.ConvertToString(rdr["detail_id"]);
                 model.DetailName   = dalUtility.ConvertToString(rdr["detail_name"]);
                 model.Currency     = dalUtility.ConvertToString(rdr["currency"]);
                 model.Mny          = dalUtility.ConvertToDecimal(rdr["mny"]);
                 model.ExchangeRate = dalUtility.ConvertToDecimal(rdr["exchange_rate"]);
                 model.CheckNo      = dalUtility.ConvertToString(rdr["check_no"]);
                 model.CheckType    = dalUtility.ConvertToString(rdr["check_type"]);
                 model.BankName     = dalUtility.ConvertToString(rdr["bank_name"]);
                 model.PromiseDate  = dalUtility.ConvertToDateTime(rdr["promise_date"]);
                 model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                 modellist.Add(model);
             }
         }
         emsg = null;
         return(modellist);
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Esempio n. 2
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.EndEdit();
                if (dtpFormDate.Value < Util.modperiod.StartDate)
                {
                    MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dtpFormDate.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtCheckId.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Check Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCheckId.Focus();
                    return;
                }
                if (DBGrid.RowCount == 0)
                {
                    MessageBox.Show("没有明细数据", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    switch (DBGrid.Rows[i].Cells[0].Value.ToString().Trim())
                    {
                    case "1055":        //应收帐款
                        dalCustomerList dalcust = new dalCustomerList();
                        if (!dalcust.Exists(DBGrid.Rows[i].Cells["DetailId"].Value.ToString().Trim(), out Util.emsg))
                        {
                            MessageBox.Show("应收帐款明细不正确!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        break;

                    case "5145":        //应付帐款
                        dalVendorList dalvendor = new dalVendorList();
                        if (!dalvendor.Exists(DBGrid.Rows[i].Cells["DetailId"].Value.ToString().Trim(), out Util.emsg))
                        {
                            MessageBox.Show("应付帐款明细不正确!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        break;

                    case "1060":        //其它应收款
                        dalOtherReceivableObject dalrec = new dalOtherReceivableObject();
                        if (!dalrec.Exists(DBGrid.Rows[i].Cells["DetailId"].Value.ToString().Trim(), out Util.emsg))
                        {
                            MessageBox.Show("其它应收款明细不正确!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        break;

                    case "5155":        //其它应付款
                        dalOtherReceivableObject dalpay = new dalOtherReceivableObject();
                        if (!dalpay.Exists(DBGrid.Rows[i].Cells["DetailId"].Value.ToString().Trim(), out Util.emsg))
                        {
                            MessageBox.Show("其它应付款明细不正确!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        break;

                    case "1075":       //应收票据
                    case "5125":       //应付票据
                        if (DBGrid.Rows[i].Cells[7].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[7].Value.ToString()))
                        {
                            MessageBox.Show(clsTranslate.TranslateString("Check No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        if (DBGrid.Rows[i].Cells[8].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[8].Value.ToString()))
                        {
                            MessageBox.Show(clsTranslate.TranslateString("Check Type") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        if (DBGrid.Rows[i].Cells[9].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[9].Value.ToString()))
                        {
                            MessageBox.Show(clsTranslate.TranslateString("Bank Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        if (DBGrid.Rows[i].Cells[10].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[10].Value.ToString()))
                        {
                            MessageBox.Show(clsTranslate.TranslateString("Promise Date") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        break;
                    }
                }
                if (Math.Abs(Convert.ToDecimal(txtMny.Text) - GetDetailSum()) > Convert.ToDecimal("0.001"))
                {
                    MessageBox.Show("金额不平衡!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                modAccCheckForm mod = new modAccCheckForm();
                mod.FormId     = txtFormId.Text.Trim();
                mod.FormDate   = dtpFormDate.Value;
                mod.CheckId    = Convert.ToInt32(txtCheckId.Text);
                mod.Remark     = txtRemark.Text.Trim();
                mod.UpdateUser = Util.UserId;
                mod.Status     = 0;

                string detaillist = string.Empty;
                BindingCollection <modAccCheckFormDetail> list = new BindingCollection <modAccCheckFormDetail>();
                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    modAccCheckFormDetail modd = new modAccCheckFormDetail();
                    modd.Seq          = i + 1;
                    modd.SubjectId    = DBGrid.Rows[i].Cells[0].Value.ToString();
                    modd.SubjectName  = DBGrid.Rows[i].Cells[1].Value.ToString();
                    modd.DetailId     = DBGrid.Rows[i].Cells[2].Value == null ? string.Empty : DBGrid.Rows[i].Cells[2].Value.ToString();
                    modd.DetailName   = DBGrid.Rows[i].Cells[3].Value.ToString();
                    modd.Currency     = DBGrid.Rows[i].Cells[4].Value == null ? string.Empty : DBGrid.Rows[i].Cells[4].Value.ToString();
                    modd.Mny          = Convert.ToDecimal(DBGrid.Rows[i].Cells[5].Value.ToString());
                    modd.ExchangeRate = Convert.ToDecimal(DBGrid.Rows[i].Cells[6].Value.ToString());
                    modd.CheckNo      = DBGrid.Rows[i].Cells[7].Value == null ? string.Empty : DBGrid.Rows[i].Cells[7].Value.ToString();
                    modd.CheckType    = DBGrid.Rows[i].Cells[8].Value == null ? string.Empty : DBGrid.Rows[i].Cells[8].Value.ToString();
                    modd.BankName     = DBGrid.Rows[i].Cells[9].Value == null ? string.Empty : DBGrid.Rows[i].Cells[9].Value.ToString();
                    modd.PromiseDate  = Convert.ToDateTime(DBGrid.Rows[i].Cells[10].Value);
                    modd.Remark       = DBGrid.Rows[i].Cells[11].Value == null ? string.Empty : DBGrid.Rows[i].Cells[11].Value.ToString();
                    list.Add(modd);
                }
                bool ret = _dal.Save(_action, mod, list, out Util.emsg);
                if (ret)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }