Exemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (this.PaymentRequestID != 0)
     {
         XMPaymentApply payment = base.XMPaymentApplyService.GetXMPaymentApplyById(this.PaymentRequestID);
         if ((bool)payment.IsAudit || (bool)payment.FinancialStatus)
         {
             base.ShowMessage("申请单已审核,不能修改!");
             return;
         }
         payment.ContractNumber     = txtNumber.Text.Trim();
         payment.RequestFundsReason = txtNote.Text.Trim();
         payment.PayMode            = int.Parse(ddlPayType.SelectedValue);
         payment.SupplierID         = ddlSupplierList.SelectedValue != "" ? int.Parse(ddlSupplierList.SelectedValue) : 1;
         payment.BankAcount         = txtBankAcount.Text.Trim();
         payment.UpdateID           = HozestERPContext.Current.User.CustomerID;
         payment.UpdateDate         = DateTime.Now;
         base.XMPaymentApplyService.UpdateXMPaymentApply(payment);
         base.ShowMessage("操作成功!");
         BindGrid(payment.Id);
     }
     else
     {
         XMPaymentApply xmPaymentApply = new XMPaymentApply();
         decimal        payAmounts     = 0;
         decimal.TryParse(ltPayMoney.Text, out payAmounts);
         xmPaymentApply.PayAmounts       = payAmounts;
         xmPaymentApply.PayMode          = int.Parse(ddlPayType.SelectedValue);;
         xmPaymentApply.SupplierID       = ddlSupplierList.SelectedValue != "" ? int.Parse(ddlSupplierList.SelectedValue) : 1;
         xmPaymentApply.RequstDate       = DateTime.Now;
         xmPaymentApply.UserDate         = DateTime.Now;
         xmPaymentApply.IsAudit          = false;
         xmPaymentApply.FinancialStatus  = false;
         xmPaymentApply.ApplicantID      = HozestERPContext.Current.User.CustomerID;
         xmPaymentApply.UpdateDate       = DateTime.Now;
         xmPaymentApply.UpdateID         = HozestERPContext.Current.User.CustomerID;
         xmPaymentApply.IsEnable         = false;
         xmPaymentApply.FinancialConfirm = false;
         XMPaymentApplyService.InsertXMPaymentApply(xmPaymentApply);
         base.ShowMessage("操作成功!");
         BindGrid(xmPaymentApply.Id);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 新增请款单数据
        /// </summary>
        /// <param name="id"></param>
        private void InsertPaymentRequstData(XMPurchase purchases)
        {
            XMPaymentApply paymentApply = new XMPaymentApply();

            paymentApply.PurchaseID       = purchases.Id;
            paymentApply.PayAmounts       = purchases.ProductsMoney.Value;
            paymentApply.PayMode          = purchases.PaymentType.Value;
            paymentApply.SupplierID       = purchases.SupplierId;
            paymentApply.RequstDate       = DateTime.Now;
            paymentApply.UserDate         = purchases.PurchaseDate;
            paymentApply.ApplicantID      = HozestERPContext.Current.User.CustomerID;
            paymentApply.UpdateDate       = DateTime.Now;
            paymentApply.UpdateID         = HozestERPContext.Current.User.CustomerID;
            paymentApply.IsAudit          = false;
            paymentApply.FinancialStatus  = false;
            paymentApply.FinancialConfirm = false;
            paymentApply.IsEnable         = false;
            base.XMPaymentApplyService.InsertXMPaymentApply(paymentApply);
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, Ext.Net.DirectEventArgs e)
        {
            var purchases = base.XMPurchaseService.GetXMPurchaseById(PayID);

            var XMPaymentApplyList = XMPaymentApplyService.GetXMPaymentApplyListByPurchaseID(PayID);

            decimal amount = XMPaymentApplyList.Sum(a => a.PayAmounts);

            decimal payamount = decimal.Parse(txtAmount.Text);

            if (amount + payamount > purchases.ProductsMoney)
            {
                Ext.Net.ExtNet.Msg.Alert("提示", "金额超出范围!").Show();
            }
            else
            {
                XMPaymentApply paymentApply = new XMPaymentApply();
                paymentApply.PurchaseID         = purchases.Id;
                paymentApply.PayAmounts         = decimal.Parse(txtAmount.Text);
                paymentApply.PayMode            = purchases.PaymentType.Value;
                paymentApply.SupplierID         = purchases.SupplierId;
                paymentApply.RequstDate         = DateTime.Now;
                paymentApply.UserDate           = purchases.PurchaseDate;
                paymentApply.ApplicantID        = HozestERPContext.Current.User.CustomerID;
                paymentApply.UpdateDate         = DateTime.Now;
                paymentApply.UpdateID           = HozestERPContext.Current.User.CustomerID;
                paymentApply.IsAudit            = false;
                paymentApply.FinancialStatus    = false;
                paymentApply.FinancialConfirm   = false;
                paymentApply.IsEnable           = false;
                paymentApply.RequestFundsReason = txtReason.Text;
                base.XMPaymentApplyService.InsertXMPaymentApply(paymentApply);

                window1.Hide();
                Ext.Net.ExtNet.Msg.Alert("提示", "操作成功!").Show();
            }
        }
Exemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            decimal value = 0;

            if (this.type == 0)                        //新增
            {
                bool   isEmpty = false;                //判断厂家编码是否填写(厂家编码必填)
                bool   isFlase = false;                //判断入库数量值是否正确
                string rf      = AutoRejectedNumber(); //自动生成退货单号

                var InventoryInfo = base.XMInventoryInfoService.GetXMInventoryInfoById(this.ID);
                int storageID     = -1;
                if (InventoryInfo != null)
                {
                    storageID = InventoryInfo.WfId;
                }
                int      supplierId         = ddlSuppliers.SelectedValue == "" ? -1 : int.Parse(ddlSuppliers.SelectedValue);
                int      BizUserId          = HozestERPContext.Current.User.CustomerID;                                                                                 // 退货人
                DateTime BizDt              = txtStorageDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtStorageDate.Value); //退货时间
                int      paymentType        = int.Parse(ddlPayment.SelectedValue);
                string   note               = txtNote.Text.Trim();
                decimal  totalRejectedMoney = 0;
                string   hiddjsonContent    = hdfJsonContent.Value;
                if (hiddjsonContent != "")
                {
                    JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                    if (ja_goods.Count == 0)
                    {
                        isEmpty = true;
                    }
                    for (int i = 0; i < ja_goods.Count; i++)
                    {
                        int  rejecedCount = ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim());     //可退货数量
                        bool t            = IsNumeric(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim());
                        if (!t)
                        {
                            base.ShowMessage("商品退货数量格式不正确!");
                            BindGrid(hiddjsonContent);
                            return;
                        }
                        int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim());      //退货数量
                        if (productCount == 0 || productCount > rejecedCount)
                        {
                            isFlase = true;
                        }
                    }
                }
                if (isFlase)
                {
                    base.ShowMessage("商品退货数量不能为0 或 大于可退货数量!");
                    BindGrid(hiddjsonContent);
                    return;
                }
                if (isEmpty)
                {
                    base.ShowMessage("厂家编码不能为空,请输入厂家编码 或商品信息不存在!");
                    BindGrid(hiddjsonContent);
                    return;
                }
                XMPurchaseRejected rejected = new XMPurchaseRejected();
                rejected.Ref            = rf;
                rejected.SupplierId     = supplierId;
                rejected.BizUserId      = BizUserId;
                rejected.BizDt          = BizDt;
                rejected.BillStatus     = 0; //待退货
                rejected.RejectionMoney = totalRejectedMoney;
                rejected.ReceivingType  = paymentType;
                rejected.BillMemo       = note;
                rejected.CreateID       = HozestERPContext.Current.User.CustomerID;
                rejected.CreateDate     = DateTime.Now;
                rejected.UpdateID       = HozestERPContext.Current.User.CustomerID;
                rejected.UpdateDate     = DateTime.Now;
                rejected.IsEnable       = false;
                rejected.IsAudit        = false;
                rejected.IsStoraged     = true; //已经入库
                base.XMPurchaseRejectedService.InsertXMPurchaseRejected(rejected);
                int rejectedID = rejected.Id;
                if (hiddjsonContent != "")
                {
                    JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                    for (int i = 0; i < ja_goods.Count; i++)
                    {
                        string productCode  = ja_goods[i]["PlatformMerchantCode"].ToString().Replace('\"', ' ').Trim();                                                                                 //厂家编码
                        int    productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量
                        XMPurchaseRejectedProductDetails details = new XMPurchaseRejectedProductDetails();
                        details.PrId = rejectedID;
                        var product = base.XMProductService.getXMProductByManufacturersCode(productCode);
                        if (product != null)
                        {
                            details.ProductId = product.Id;
                        }
                        details.InventoryInfoID      = this.ID;      //库存ID
                        details.PlatformMerchantCode = productCode;
                        details.RejectionCount       = productCount; // 退货数量
                        details.CreateDate           = DateTime.Now;
                        details.CreateID             = HozestERPContext.Current.User.CustomerID;
                        details.UpdateDate           = DateTime.Now;
                        details.UpdateID             = HozestERPContext.Current.User.CustomerID;
                        details.IsEnable             = false;
                        base.XMPurchaseRejectedProductDetailsService.InsertXMPurchaseRejectedProductDetails(details);
                    }
                }

                XMPaymentApply xmPaymentApply = new XMPaymentApply();
                //xmPaymentApply.PurchaseID = this.PurchaseID;
                xmPaymentApply.PayAmounts       = 0 - totalRejectedMoney;
                xmPaymentApply.PayMode          = paymentType;
                xmPaymentApply.SupplierID       = supplierId;
                xmPaymentApply.RequstDate       = DateTime.Now;
                xmPaymentApply.UserDate         = DateTime.Now;
                xmPaymentApply.IsAudit          = false;
                xmPaymentApply.FinancialStatus  = false;
                xmPaymentApply.ApplicantID      = HozestERPContext.Current.User.CustomerID;
                xmPaymentApply.UpdateDate       = DateTime.Now;
                xmPaymentApply.UpdateID         = HozestERPContext.Current.User.CustomerID;
                xmPaymentApply.IsEnable         = false;
                xmPaymentApply.FinancialConfirm = false;
                XMPaymentApplyService.InsertXMPaymentApply(xmPaymentApply);

                base.ShowMessage("操作成功!");
                BindGrid(rejected.Id);
            }
            else                            //编辑
            {
                bool    isEmpty    = false; //判断厂家编码是否填写(厂家编码必填)
                bool    isFlase    = false; //判断入库数量值是否正确
                int     id         = this.RejectedID;
                decimal totalMoney = 0;     //总价
                var     rejected   = base.XMPurchaseRejectedService.GetXMPurchaseRejectedById(id);
                if (rejected != null)
                {
                    var rejectedDetails = base.XMPurchaseRejectedProductDetailsService.GetXMPurchaseRejectedProductDetailsByRejectedID(rejected.Id);
                    rejected.SupplierId = ddlSuppliers.SelectedValue == "" ? -1 : int.Parse(ddlSuppliers.SelectedValue);
                    rejected.BizUserId  = HozestERPContext.Current.User.CustomerID;
                    rejected.BizDt      = txtStorageDate.Value == "" ? DateTime.Parse(DateTime.Now.ToShortDateString()) : Convert.ToDateTime(txtStorageDate.Value); //业务时间
                    string hiddjsonContent = hdfJsonContent.Value;
                    if (hiddjsonContent != "")
                    {
                        JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                        if (ja_goods.Count == 0)
                        {
                            isEmpty = true;
                        }
                        for (int i = 0; i < ja_goods.Count; i++)
                        {
                            int  rejecedCount = ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["Count"].ToString().Replace('\"', ' ').Trim());     //可退货数量
                            bool t            = IsNumeric(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? "0" : ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim());
                            if (!t)
                            {
                                base.ShowMessage("商品采购数量数量格式不正确!");
                                BindGrid(hiddjsonContent);
                                return;
                            }
                            int productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim());      //退货数量
                            if (productCount == 0 || productCount > rejecedCount)
                            {
                                isFlase = true;
                            }
                        }
                    }
                    if (isFlase)
                    {
                        base.ShowMessage("商品退货数量不能为0 或 大于可退货数量!");
                        BindGrid(hiddjsonContent);
                        return;
                    }
                    if (isEmpty)
                    {
                        base.ShowMessage("厂家编码不能为空,请输入厂家编码或 商品信息不存在");
                        BindGrid(hiddjsonContent);
                        return;
                    }
                    rejected.RejectionMoney = totalMoney;
                    rejected.ReceivingType  = int.Parse(ddlPayment.SelectedValue);
                    rejected.BillMemo       = txtNote.Text.Trim();
                    rejected.UpdateDate     = DateTime.Now;
                    rejected.UpdateID       = HozestERPContext.Current.User.CustomerID;
                    base.XMPurchaseRejectedService.UpdateXMPurchaseRejected(rejected);
                    if (rejectedDetails != null && rejectedDetails.Count() > 0)
                    {
                        if (hiddjsonContent != "")
                        {
                            JArray ja_goods = (JArray)JsonConvert.DeserializeObject(hiddjsonContent);
                            for (int i = 0; i < ja_goods.Count; i++)
                            {
                                string productCode  = ja_goods[i]["PlatformMerchantCode"].ToString().Replace('\"', ' ').Trim();                                                                                 //厂家编码
                                int    productCount = ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim() == "" ? 0 : int.Parse(ja_goods[i]["ProductCount"].ToString().Replace('\"', ' ').Trim()); //退货数量
                                foreach (XMPurchaseRejectedProductDetails info in rejectedDetails)
                                {
                                    if (productCode == info.PlatformMerchantCode)
                                    {
                                        info.InventoryInfoID = this.ID;//库存ID
                                        info.RejectionCount  = productCount;
                                        info.UpdateID        = HozestERPContext.Current.User.CustomerID;
                                        info.UpdateDate      = DateTime.Now;
                                        base.XMPurchaseRejectedProductDetailsService.UpdateXMPurchaseRejectedProductDetails(info);
                                    }
                                }
                            }
                        }
                    }
                }
                base.ShowMessage("操作成功!");
                BindGrid(rejected.Id);
            }
        }