示例#1
0
        /// <summary>
        ///     Grid1_RowCommand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete" || e.CommandName == "Add")
            {
                var datakey = Convert.ToInt32(Grid1.DataKeys[e.RowIndex][1]);

                LeaseDetailsService.Delete(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId);

                BindDataGrid();
            }
        }
示例#2
0
        /// <summary>
        ///     作废
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnBatchDelete_Click(object sender, EventArgs e)
        {
            IEnumerable <string> selectIds = GetSelectIds();

            try
            {
                Log(string.Format(@"作废单据号:{0}成功。", selectIds));

                using (var trans = new TransactionScope())
                {
                    //
                    foreach (var ids in selectIds)
                    {
                        var status = new LHBillStatus();
                        status.FCompanyId  = CurrentUser.AccountComId;
                        status.FDeptId     = CurrentUser.AccountOrgId;
                        status.FDate       = DateTime.Now;
                        status.FOperator   = CurrentUser.AccountName;
                        status.FActionName = EnumDescription.GetFieldText(GasEnumBillStauts.Voided);
                        status.KeyId       = ids;
                        status.FMemo       = string.Format("单据号{0}被{1}作废处理。", ids, CurrentUser.AccountName);

                        GasHelper.AddBillStatus(status);
                    }

                    LeaseReturnService.Update(p => p.FCompanyId == CurrentUser.AccountComId &&
                                              selectIds.Contains(p.KeyId), p => new LHLeaseReturn
                    {
                        FFlag     = 0,                                         //
                        FStatus   = Convert.ToInt32(GasEnumBillStauts.Voided), //
                        FProgress = Convert.ToInt32(GasEnumBillStauts.Voided)
                    });

                    foreach (var ids in selectIds)
                    {
                        var parms = new Dictionary <string, object>();
                        parms.Clear();
                        parms.Add("@keyID", ids);
                        parms.Add("@companyId", CurrentUser.AccountComId);
                        var data = SqlService.ExecuteProcedureCommand("proc_LeaseKill", parms).Tables[0];

                        for (int i = 0; i < data.Rows.Count; i++)
                        {
                            int id      = Convert.ToInt32(data.Rows[i]["FDetailsFId"]);
                            int qty     = Convert.ToInt32(data.Rows[i]["FBottleQty"]);
                            var details = LeaseDetailsService.FirstOrDefault(p => p.FId == id);
                            details.FReturnQty = details.FReturnQty - qty;
                            LeaseDetailsService.SaveChanges();
                        }
                    }

                    trans.Complete();
                }
                Alert.Show("作废成功!", MessageBoxIcon.Information);
                BindDataGrid();
            }
            catch (Exception)
            {
                Alert.Show("作废失败!", MessageBoxIcon.Warning);
            }
        }
示例#3
0
        /// <summary>
        ///     提交添加
        /// </summary>
        private bool SubmintAdd()
        {
            var leaseReturn = LeaseReturnService.Where(p => p.KeyId == txtKeyId.Text.Trim() && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

            if (leaseReturn != null)
            {
                ModifiedGrid();

                leaseReturn.FCode            = txtFCode.Text;
                leaseReturn.FName            = tbxFCustomer.Text;
                leaseReturn.FAddress         = txtFAddress.Text.Trim();
                leaseReturn.FCompanyId       = CurrentUser.AccountComId;
                leaseReturn.FFlag            = 1;
                leaseReturn.FDeleteFlag      = 0;
                leaseReturn.FLinkman         = txtFLinkman.Text.Trim();
                leaseReturn.FMemo            = txtFMemo.Text.Trim();
                leaseReturn.FPhone           = txtFPhone.Text.Trim();
                leaseReturn.FShipper         = !ddlFShipper.SelectedValue.Equals("-1") ? ddlFShipper.SelectedText : "";
                leaseReturn.FVehicleNum      = !ddlFVehicleNum.SelectedValue.Equals("-1") ? ddlFVehicleNum.SelectedText : "";
                leaseReturn.FSupercargo      = GasHelper.GetDropDownListArrayString(ddlFSupercargo.SelectedItemArray);
                leaseReturn.FDriver          = GasHelper.GetDropDownListArrayString(ddlFDriver.SelectedItemArray);
                leaseReturn.FPaymentRentals  = string.IsNullOrEmpty(txtFPaymentRentals.Text.Trim()) ? 0 : Convert.ToDecimal(txtFPaymentRentals.Text.Trim());
                leaseReturn.FDepositSecurity = string.IsNullOrEmpty(txtFDepositSecurity.Text.Trim()) ? 0 : Convert.ToDecimal(txtFDepositSecurity.Text.Trim());

                leaseReturn.FSubjectCodeIn = ddlSubjectIn.SelectedValue;
                leaseReturn.FSubjectNameIn = ddlSubjectIn.SelectedText;

                leaseReturn.FSubjectCodeOut = ddlSubjectOut.SelectedValue;
                leaseReturn.FSubjectNameOut = ddlSubjectOut.SelectedText;
                leaseReturn.FSKNum          = "";
                leaseReturn.FCate           = hfdClass.Text;
                leaseReturn.FFKNum          = "";
                LeaseReturnService.SaveChanges();


                var parms = new Dictionary <string, object>();
                parms.Clear();
                parms.Add("@keyID", leaseReturn.KeyId);
                parms.Add("@companyId", CurrentUser.AccountComId);
                var data = SqlService.ExecuteProcedureCommand("proc_LeaseReturnAmt", parms).Tables[0];

                for (int i = 0; i < data.Rows.Count; i++)
                {
                    int ids     = Convert.ToInt32(data.Rows[i]["FDetailsFId"]);
                    int qty     = Convert.ToInt32(data.Rows[i]["Qty"]);
                    var details = LeaseDetailsService.FirstOrDefault(p => p.FId == ids);
                    details.FReturnQty = details.FReturnQty + qty;
                    LeaseDetailsService.SaveChanges();
                }

                if (txtKeyId.Text.Contains("TM"))
                {
                    //单据号问题
                    string newKeyId   = SequenceService.CreateSequence(Convert.ToDateTime(txtFDate.SelectedDate), "TZ", CurrentUser.AccountComId);
                    var    orderParms = new Dictionary <string, object>();
                    orderParms.Clear();
                    orderParms.Add("@oldKeyId", txtKeyId.Text);
                    orderParms.Add("@newKeyId", newKeyId);
                    orderParms.Add("@Bill", "8");
                    orderParms.Add("@companyId", CurrentUser.AccountComId);
                    SqlService.ExecuteProcedureCommand("proc_num", orderParms);
                    txtKeyId.Text = newKeyId;

                    //新增日志
                    var billStatus = new LHBillStatus
                    {
                        KeyId       = newKeyId,
                        FCompanyId  = CurrentUser.AccountComId,
                        FActionName = "新增",
                        FDate       = DateTime.Now,
                        FDeptId     = CurrentUser.AccountOrgId,
                        FOperator   = CurrentUser.AccountName,
                        FMemo       = String.Format("单据号{0},{1}新增租赁归还单据。", newKeyId, CurrentUser.AccountName)
                    };
                    GasHelper.AddBillStatus(billStatus);

                    //生成财务凭证
                    var parmsAuto = new Dictionary <string, object>();
                    parmsAuto.Clear();

                    parmsAuto.Add("@KeyId", newKeyId);
                    parmsAuto.Add("@companyId", CurrentUser.AccountComId);
                    parmsAuto.Add("@FCate", hfdClass.Text);
                    parmsAuto.Add("@date", Convert.ToDateTime(leaseReturn.FDate).ToString("yyyy-MM-dd"));
                    parmsAuto.Add("@FSKNum", leaseReturn.FSKNum);
                    parmsAuto.Add("@FAbstract", "退租");

                    SqlService.ExecuteProcedureCommand("proc_SFKLeaseReturnAuto", parmsAuto);
                }

                return(true);
            }


            return(false);
        }
示例#4
0
        /// <summary>
        ///     提交编辑
        /// </summary>
        private bool SubmintEdit()
        {
            if (LeaseReturn != null)
            {
                ModifiedGrid();

                LeaseReturn.FCode      = txtFCode.Text;
                LeaseReturn.FName      = tbxFCustomer.Text;
                LeaseReturn.FAddress   = txtFAddress.Text.Trim();
                LeaseReturn.FCompanyId = CurrentUser.AccountComId;

                //StockOut.FDriver = !ddlFDriver.SelectedValue.Equals("-1") ? ddlFDriver.SelectedText : "";
                LeaseReturn.FShipper = !ddlFShipper.SelectedValue.Equals("-1") ? ddlFShipper.SelectedText : "";
                //StockOut.FSupercargo = !ddlFSupercargo.SelectedValue.Equals("-1") ? ddlFSupercargo.SelectedText : "";
                LeaseReturn.FVehicleNum = !ddlFVehicleNum.SelectedValue.Equals("-1") ? ddlFVehicleNum.SelectedText : "";


                LeaseReturn.FFlag = 1;
                //LeaseReturn.FFreight = Convert.ToDecimal(txtFFreight.Text.Trim());
                LeaseReturn.FLinkman = txtFLinkman.Text.Trim();
                LeaseReturn.FMemo    = txtFMemo.Text.Trim();
                LeaseReturn.FPhone   = txtFPhone.Text.Trim();

                LeaseReturn.FSupercargo = GasHelper.GetDropDownListArrayString(ddlFSupercargo.SelectedItemArray);
                LeaseReturn.FDriver     = GasHelper.GetDropDownListArrayString(ddlFDriver.SelectedItemArray);

                LeaseReturn.FPaymentRentals  = string.IsNullOrEmpty(txtFPaymentRentals.Text.Trim()) ? 0 : Convert.ToDecimal(txtFPaymentRentals.Text.Trim());
                LeaseReturn.FDepositSecurity = string.IsNullOrEmpty(txtFDepositSecurity.Text.Trim()) ? 0 : Convert.ToDecimal(txtFDepositSecurity.Text.Trim());

                LeaseReturn.FSubjectCodeIn  = ddlSubjectIn.SelectedValue;
                LeaseReturn.FSubjectNameIn  = ddlSubjectIn.SelectedText;
                LeaseReturn.FSubjectCodeOut = ddlSubjectOut.SelectedValue;
                LeaseReturn.FSubjectNameOut = ddlSubjectOut.SelectedText;
                LeaseReturn.FCate           = hfdClass.Text;
                LeaseReturn.CreateBy        = CurrentUser.AccountName;

                LeaseReturnService.SaveChanges();

                var parms = new Dictionary <string, object>();
                parms.Clear();
                parms.Add("@keyID", LeaseReturn.KeyId);
                parms.Add("@companyId", CurrentUser.AccountComId);

                var data = SqlService.ExecuteProcedureCommand("proc_LeaseReturnAmt", parms).Tables[0];
                for (int i = 0; i < data.Rows.Count; i++)
                {
                    int ids     = Convert.ToInt32(data.Rows[i]["FDetailsFId"]);
                    int qty     = Convert.ToInt32(data.Rows[i]["Qty"]);
                    var details = LeaseDetailsService.FirstOrDefault(p => p.FId == ids);
                    details.FReturnQty = details.FReturnQty + qty;
                    LeaseDetailsService.SaveChanges();
                }


                //生成财务凭证
                var parmsAuto = new Dictionary <string, object>();
                parmsAuto.Clear();

                parmsAuto.Add("@KeyId", LeaseReturn.KeyId);
                parmsAuto.Add("@companyId", CurrentUser.AccountComId);
                parmsAuto.Add("@FCate", hfdClass.Text);
                parmsAuto.Add("@date", Convert.ToDateTime(LeaseReturn.FDate).ToString("yyyy-MM-dd"));
                parmsAuto.Add("@FSKNum", LeaseReturn.FSKNum);
                parmsAuto.Add("@FAbstract", "退租");

                SqlService.ExecuteProcedureCommand("proc_SFKLeaseReturnAuto", parmsAuto);

                return(true);
            }
            return(false);
        }
示例#5
0
        /// <summary>
        ///     ModifiedGrid
        /// </summary>
        private void ModifiedGrid()
        {
            var dictModified = Grid1.GetModifiedDict();

            foreach (var rowKey in dictModified.Keys)
            {
                int datakey = Convert.ToInt32(Grid1.DataKeys[rowKey][1].ToString());

                var sKeys   = new StringBuilder();
                var sValues = new StringBuilder();
                foreach (var key in dictModified[rowKey].Keys)
                {
                    sKeys.AppendFormat("{0},", key);
                }

                foreach (var dictValue in dictModified[rowKey].Values)
                {
                    sValues.AppendFormat("{0},", dictValue);
                }

                var details = LeaseDetailsService.Where(p => p.FId == datakey && p.FCompanyId == CurrentUser.AccountComId).FirstOrDefault();

                //写入原始,通过存储过程完成明细复制
                var parms = new Dictionary <string, object>();
                parms.Clear();

                parms.Add("@fid", datakey);
                parms.Add("@opr", CurrentUser.AccountName);
                parms.Add("@companyId", CurrentUser.AccountComId);
                SqlService.ExecuteProcedureCommand("proc_LeaseDetails_Log", parms);

                var keys   = sKeys.ToString().Split(',');
                var values = sValues.ToString().Split(',');
                for (int i = 0; i < keys.Count(); i++)
                {
                    #region 修改内容

                    var key   = keys[i];
                    var value = values[i];

                    if (!string.IsNullOrEmpty(key))
                    {
                        if (details != null)
                        {
                            if (key.Equals("FBottleQty"))
                            {
                                details.FBottleQty = Convert.ToInt32(value);
                                details.FAmount    = details.FBottleQty * details.FPrice;
                            }

                            if (key.Equals("FRentDay"))
                            {//租金/天
                                details.FRentDay = Convert.ToDecimal(value);
                            }

                            if (key.Equals("FPrice"))
                            {//押金/个
                                details.FPrice  = Convert.ToDecimal(value);
                                details.FAmount = details.FPrice * details.FBottleQty;
                            }

                            if (key.Equals("FAmount"))
                            {//押金
                                details.FAmount = details.FBottleQty * details.FPrice;
                            }
                        }

                        var detailslog = new LHLeaseDetails_Log
                        {
                            FUpdateBy   = CurrentUser.AccountName,
                            FUpdateDate = DateTime.Now,
                            FBottle     = details.FBottle,
                            FPrice      = details.FPrice,
                            FBottleQty  = details.FBottleQty,
                            FAmount     = details.FAmount,
                            KeyId       = details.KeyId,
                            FRentDay    = details.FRentDay,
                            FStatus     = "变更",
                            FCompanyId  = CurrentUser.AccountComId,
                            //FMemo = string.Format(@"时间:{0} 变更人:{1}", DateTime.Now, CurrentUser.AccountName)
                        };

                        LeaseDetailsLogService.Add(detailslog);
                    }
                    #endregion
                }

                LeaseDetailsService.SaveChanges();
            }
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            var addList = Grid1.GetNewAddedList();

            foreach (var add in addList)
            {
                var dictValues = add.Values;

                //商品代码
                var firstOrDefault = dictValues.First();

                if (firstOrDefault != null && !string.IsNullOrEmpty(firstOrDefault.ToString()))
                {
                    DataSet dataSet = GasHelper.GetSalesItem(firstOrDefault.ToString(), CurrentUser.AccountComId);

                    DataTable table = dataSet.Tables[0];

                    if (table != null && table.Rows.Count > 0)
                    {
                        decimal price = GasHelper.GeCustomerPrice(txtFCode.Text,//
                                                                  table.Rows[0]["FItemCode"].ToString(), CurrentUser.AccountComId);

                        table.Rows[0]["FPrice"] = price;

                        var details = new LHLeaseDetails
                        {
                            FBottle    = table.Rows[0]["FItemCode"].ToString(),
                            FPrice     = price,
                            FBottleQty = 1,
                            FAmount    = price,
                            //单日租金
                            FRentDay   = 1,
                            FCompanyId = CurrentUser.AccountComId,
                            KeyId      = txtKeyId.Text.Trim(),
                            FCateId    = Convert.ToInt32(table.Rows[0]["FId"].ToString())
                        };

                        switch (Actions)
                        {
                        case WebAction.Add:
                            break;

                        case WebAction.Edit:
                            //记录一下当前新增人操作内容
                            var detailslog = new LHLeaseDetails_Log
                            {
                                FUpdateBy   = CurrentUser.AccountName,
                                FUpdateDate = DateTime.Now,
                                FBottle     = table.Rows[0]["FItemCode"].ToString(),
                                FPrice      = price,
                                FBottleQty  = 1,
                                FAmount     = price,
                                KeyId       = txtKeyId.Text.Trim(),
                                FRentDay    = 1,
                                FCompanyId  = CurrentUser.AccountComId,
                                FStatus     = "新增",
                                //FMemo = string.Format(@"时间:{0} 新增人:{1}", DateTime.Now, CurrentUser.AccountName)
                            };

                            //detailslog.FCompanyId = CurrentUser.AccountComId;
                            //detailslog.FCateId = Convert.ToInt32(table.Rows[0]["FId"].ToString());

                            LeaseDetailsLogService.Add(detailslog);

                            break;
                        }

                        LeaseDetailsService.Add(details);
                    }
                }
            }



            if (addList.Count > 0)
            {
                BindDataGrid();
            }
        }
示例#7
0
        /// <summary>
        ///     Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //初始化控件数据
                InitData();

                //加载数据
                LoadData();
            }
            else
            {
                #region reloadGrid
                if (GetRequestEventArgument().Contains("reloadGrid:"))
                {
                    //查找所选商品代码,查访产品集合
                    string keys = GetRequestEventArgument().Split(':')[1];

                    var values = keys.Split(',');

                    string codes = String.Empty;
                    for (int i = 0; i < values.Count(); i++)
                    {
                        codes += string.Format("'{0}',", values[i]);
                    }

                    var value = codes.Substring(0, codes.Length - 1);

                    var data = SqlService.Where(string.Format("SELECT * FROM dbo.vm_SalesItem a WHERE a.FItemCode IN ({0}) and FCompanyId={1}", value, CurrentUser.AccountComId));

                    if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
                    {
                        var table = data.Tables[0];
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            var details = new LHLeaseDetails();

                            decimal price = GasHelper.GeCustomerPrice(txtFCode.Text, //
                                                                      table.Rows[i]["FItemCode"].ToString(), CurrentUser.AccountComId);

                            details.FBottle    = table.Rows[i]["FItemCode"].ToString();
                            details.FPrice     = price;
                            details.FBottleQty = 1;
                            details.FAmount    = price;
                            details.FBottleQty = 1;
                            //details.FBottleOweQty = 0;
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();
                            details.FCateId    = Convert.ToInt32(table.Rows[i]["FId"].ToString());
                            //每天租赁费
                            details.FRentDay = 0;
                            //押金
                            details.FAmount = price;

                            //已归还量
                            details.FReturnQty = 0;

                            LeaseDetailsService.AddEntity(details);

                            //日志
                            switch (Actions)
                            {
                            case WebAction.Add:
                                break;

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHLeaseDetails_Log
                                {
                                    FUpdateBy   = CurrentUser.AccountName,
                                    FUpdateDate = DateTime.Now,
                                    FBottle     = details.FBottle,
                                    FPrice      = price,
                                    FBottleQty  = 1,
                                    FAmount     = price,
                                    FCompanyId  = CurrentUser.AccountComId,
                                    KeyId       = txtKeyId.Text.Trim(),
                                    FStatus     = "新增",
                                };

                                LeaseDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        LeaseDetailsService.SaveChanges();

                        //重新绑定值
                        BindDataGrid();
                    }
                }
                else if (GetRequestEventArgument().Contains("reloadSalesGrid:"))
                {
                    string key = GetRequestEventArgument().Split(':')[1];

                    tbxFSalesNum.Text = key;

                    var sales = new StockOutService().Where(p => p.KeyId == key && p.FCompanyId == CurrentUser.AccountComId
                                                            ).FirstOrDefault();
                    if (sales != null)
                    {
                        txtFCode.Text     = sales.FCode;
                        tbxFCustomer.Text = sales.FName;
                        txtFAddress.Text  = sales.FAddress;
                        txtFPhone.Text    = sales.FPhone;
                        txtFLinkman.Text  = sales.FLinkman;
                    }

                    var data = SqlService.Where(string.Format(@"SELECT * FROM dbo.vm_SalesDetails WHERE FCateId =2000 AND keyId='{0}' and FCompanyId={1}", tbxFSalesNum.Text, CurrentUser.AccountComId));

                    if (data != null && data.Tables.Count > 0 && data.Tables[0].Rows.Count > 0)
                    {
                        var table = data.Tables[0];
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            var details = new LHLeaseDetails();

                            decimal price = GasHelper.GeCustomerPrice(txtFCode.Text, //
                                                                      table.Rows[i]["FBottleCode"].ToString(), CurrentUser.AccountComId);

                            details.FBottle    = table.Rows[i]["FBottleCode"].ToString();
                            details.FPrice     = price;
                            details.FAmount    = price;
                            details.FBottleQty = Convert.ToInt32(table.Rows[i]["FBottleQty"]);
                            details.FCompanyId = CurrentUser.AccountComId;
                            details.KeyId      = txtKeyId.Text.Trim();

                            //钢瓶
                            details.FCateId = Convert.ToInt32(table.Rows[i]["FCateId"].ToString());
                            //每天租赁费
                            details.FRentDay = 0;
                            //押金
                            details.FAmount = price;

                            //已归还量
                            details.FReturnQty = 0;

                            LeaseDetailsService.AddEntity(details);

                            //日志
                            switch (Actions)
                            {
                            case WebAction.Add:
                                break;

                            case WebAction.Edit:
                                //记录一下当前新增人操作内容
                                var detailslog = new LHLeaseDetails_Log
                                {
                                    FUpdateBy   = CurrentUser.AccountName,
                                    FUpdateDate = DateTime.Now,
                                    FBottle     = details.FBottle,
                                    FPrice      = price,
                                    FBottleQty  = 1,
                                    FAmount     = price,
                                    KeyId       = txtKeyId.Text.Trim(),
                                    FCompanyId  = CurrentUser.AccountComId,
                                    FStatus     = "新增",
                                };

                                LeaseDetailsLogService.Add(detailslog);

                                break;
                            }
                        }

                        LeaseDetailsService.SaveChanges();

                        //重新绑定值
                        BindDataGrid();
                    }
                }

                #endregion


                #region 更新合计

                //if (Grid1.Rows.Count > 0)
                //{
                //    if (GetRequestEventArgument() == "UPDATE_SUMMARY")
                //    {
                // 页面要求重新计算合计行的值
                OutputSummaryData();

                //写入
                ModifiedGrid();

                // 为了保持前后台上传,回发更新合计行值后,必须进行数据绑定或者提交更改
                Grid1.CommitChanges();
                //    }
                //}

                #endregion
            }
        }