Exemple #1
0
        /// <summary>
        ///     提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var errorRow = -1;

            try
            {
                using (var ts = new TransactionScope())
                {
                    var data = ViewState["dtData"] as DataTable;
                    if (data == null)
                    {
                        return;
                    }

                    var stringBuilder = new StringBuilder();

                    for (int i = 0; i < data.Rows.Count; i++)
                    {
                        errorRow = i + 1;

                        var item = new LHCustomerPrice
                        {
                            FCode      = data.Rows[i]["客户代码"].ToString(),
                            FItemCode  = data.Rows[i]["商品代码"].ToString(),
                            FPrice     = Convert.ToDecimal(data.Rows[i]["发货单价"]),
                            FCompanyId = CurrentUser.AccountComId,
                            FBeginDate = Convert.ToDateTime(data.Rows[i]["执行开始时间"]),
                            FFlag      = 1
                        };

                        CustomerPriceService.AddEntity(item);
                    }

                    //写入数据库
                    CustomerPriceService.SaveChanges();

                    ts.Complete();

                    Alert.Show("引入完成。", MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Alert.Show(string.Format(@"引入失败,请排查模版内容是否完善,出错定位行:{0} ", errorRow), MessageBoxIcon.Information);
            }
        }
Exemple #2
0
        /// <summary>
        ///     提交编辑
        /// </summary>
        private bool SubmintEdit()
        {
            if (CustomerPrice != null)
            {
                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@FUpdateBy", CurrentUser.AccountName);
                parms.Add("@FId", CustomerPrice.FId);

                SqlService.ExecuteProcedureCommand("proc_LHCustomerPriceLog", parms);

                CustomerPrice.FPrice = Convert.ToDecimal(txtFPrice.Text.Trim());
                CustomerPrice.FMemo  = txtFMemo.Text;


                CustomerPrice.FItemCode = txtFItemCode.Text;

                CustomerPrice.FBeginDate = dateBegin.SelectedDate;
                //CustomerPrice.FEndDate = dateEnd.SelectedDate;

                CustomerPrice.FUpdateBy   = CurrentUser.AccountName;
                CustomerPrice.FUpdateDate = DateTime.Now;

                CustomerPriceService.SaveChanges();

                var priceLog = new LHCustomerPrice_Log();

                priceLog.FCode       = CustomerPrice.FCode;
                priceLog.FCompanyId  = CustomerPrice.FCompanyId;
                priceLog.FDate       = DateTime.Now;
                priceLog.FFlag       = "变更后";
                priceLog.FItemCode   = CustomerPrice.FItemCode;
                priceLog.FPrice      = CustomerPrice.FPrice;
                priceLog.FUpdateBy   = CurrentUser.AccountName;
                priceLog.FUpdateDate = DateTime.Now;

                return(CustomerPriceLogService.Add(priceLog));
            }

            return(false);
        }