Пример #1
0
        /// <summary>
        /// get all priceadjustdetail
        /// <summary>
        /// <param name=formidlist>formidlist</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all priceadjustdetail</returns>
        public BindingCollection <modPriceAdjustDetail> GetDetail(string formidlist, out string emsg)
        {
            try
            {
                string formidwhere = string.Empty;
                if (!string.IsNullOrEmpty(formidlist) && formidlist.CompareTo("ALL") != 0)
                {
                    formidwhere = "and form_id in ('" + formidlist.Replace(",", "','") + "') ";
                }

                BindingCollection <modPriceAdjustDetail> modellist = new BindingCollection <modPriceAdjustDetail>();
                //Execute a query to read the categories
                string sql = "select form_id,seq,product_id,product_name,current_price,true_price,qty,remark from price_adjust_detail where 1=1 " + formidwhere + "order by form_id,seq";
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modPriceAdjustDetail model = new modPriceAdjustDetail();
                        model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                        model.Seq          = dalUtility.ConvertToInt(rdr["seq"]);
                        model.ProductId    = dalUtility.ConvertToString(rdr["product_id"]);
                        model.ProductName  = dalUtility.ConvertToString(rdr["product_name"]);
                        model.CurrentPrice = dalUtility.ConvertToDecimal(rdr["current_price"]);
                        model.TruePrice    = dalUtility.ConvertToDecimal(rdr["true_price"]);
                        model.Qty          = dalUtility.ConvertToDecimal(rdr["qty"]);
                        model.CurrentMny   = model.Qty * model.CurrentPrice;
                        model.TrueMny      = model.Qty * model.TruePrice;
                        model.Differ       = model.TrueMny - model.CurrentMny;
                        model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                        modellist.Add(model);
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// get new credence list
        /// <summary>
        /// <param name=accname>accname</param>
        /// <param name=accseq>accseq</param>
        /// <param name=out emsg>return error message</param>
        ///<returns>details of all salesshipment</returns>
        public BindingCollection <modPriceAdjustDetail> GetCredenceList(string accname, int?accseq, out string emsg)
        {
            try
            {
                BindingCollection <modPriceAdjustDetail> modellist = new BindingCollection <modPriceAdjustDetail>();
                //Execute a query to read the categories

                string sql = string.Format("select a.form_id,a.seq,a.product_id,a.product_name,a.current_price,a.true_price,a.qty,a.remark "
                                           + "from price_adjust_detail a, price_adjust_form b where a.form_id=b.form_id and b.acc_name='{0}' and b.acc_seq={1} order by a.form_id,a.seq", accname, accseq);
                using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
                {
                    while (rdr.Read())
                    {
                        modPriceAdjustDetail model = new modPriceAdjustDetail();
                        model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                        model.Seq          = dalUtility.ConvertToInt(rdr["seq"]);
                        model.ProductId    = dalUtility.ConvertToString(rdr["product_id"]);
                        model.ProductName  = dalUtility.ConvertToString(rdr["product_name"]);
                        model.CurrentPrice = dalUtility.ConvertToDecimal(rdr["current_price"]);
                        model.TruePrice    = dalUtility.ConvertToDecimal(rdr["true_price"]);
                        model.Qty          = dalUtility.ConvertToDecimal(rdr["qty"]);
                        model.CurrentMny   = model.Qty * model.CurrentPrice;
                        model.TrueMny      = model.Qty * model.TruePrice;
                        model.Differ       = model.TrueMny - model.CurrentMny;
                        model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                        modellist.Add(model);
                    }
                }
                emsg = null;
                return(modellist);
            }
            catch (Exception ex)
            {
                emsg = dalUtility.ErrorMessage(ex.Message);
                return(null);
            }
        }
Пример #3
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 (DBGrid.RowCount == 0)
                {
                    MessageBox.Show("没有明细数据", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    if (DBGrid.Rows[i].Cells[0].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[0].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Product id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    if (DBGrid.Rows[i].Cells[1].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[1].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Product name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (DBGrid.Rows[i].Cells[4].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[4].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Current Price") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (!Util.IsNumeric(DBGrid.Rows[i].Cells[4].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Current Price") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                modPriceAdjustForm mod = new modPriceAdjustForm();
                mod.FormId     = txtFormId.Text.Trim();
                mod.FormDate   = dtpFormDate.Value;
                mod.Remark     = txtRemark.Text.Trim();
                mod.UpdateUser = Util.UserId;
                mod.Status     = 0;
                string detaillist = string.Empty;
                BindingCollection <modPriceAdjustDetail> list = new BindingCollection <modPriceAdjustDetail>();
                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    modPriceAdjustDetail modd = new modPriceAdjustDetail();
                    modd.Seq          = i + 1;
                    modd.ProductId    = DBGrid.Rows[i].Cells[0].Value.ToString();
                    modd.ProductName  = DBGrid.Rows[i].Cells[1].Value.ToString();
                    modd.Qty          = Convert.ToDecimal(DBGrid.Rows[i].Cells[2].Value.ToString());
                    modd.CurrentPrice = Convert.ToDecimal(DBGrid.Rows[i].Cells[3].Value.ToString());
                    modd.TruePrice    = Convert.ToDecimal(DBGrid.Rows[i].Cells[4].Value.ToString());
                    modd.CurrentMny   = Convert.ToDecimal(DBGrid.Rows[i].Cells[5].Value.ToString());
                    modd.TrueMny      = Convert.ToDecimal(DBGrid.Rows[i].Cells[6].Value.ToString());
                    modd.Differ       = Convert.ToDecimal(DBGrid.Rows[i].Cells[7].Value.ToString());
                    modd.Remark       = DBGrid.Rows[i].Cells[8].Value == null ? string.Empty : DBGrid.Rows[i].Cells[8].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;
            }
        }