protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (this.ProductId > 0) { XMProduct xMProduct = base.XMProductService.GetXMProductById(this.ProductId); if (xMProduct != null) { this.lblBrandTypeId.Text = xMProduct.BrandTypeCodeName != null ? xMProduct.BrandTypeCodeName : ""; this.lblProductName.Text = xMProduct.ProductName != null ? xMProduct.ProductName : ""; this.lblManufacturersCode.Text = xMProduct.ManufacturersCode != null ? xMProduct.ManufacturersCode : ""; this.lblSpecifications.Text = xMProduct.Specifications != null ? xMProduct.Specifications : ""; this.lblManufacturersInventory.Text = xMProduct.ManufacturersInventory != null?xMProduct.ManufacturersInventory.Value.ToString() : ""; this.lblWarningQuantity.Text = xMProduct.WarningQuantity != null?xMProduct.WarningQuantity.Value.ToString() : ""; this.lblProductColors.Text = xMProduct.ProductColors != null ? xMProduct.ProductColors : ""; this.lblProductUnit.Text = xMProduct.ProductUnit != null ? xMProduct.ProductUnit : ""; if (xMProduct.IsPremiums != null) { this.ckbIsPremiums.Checked = xMProduct.IsPremiums.Value; } } BindGrid(); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { int PlatformTypeId = Convert.ToInt32(this.ddlPlatformTypeId.SelectedValue.ToString()); decimal PurchasePrice = string.IsNullOrEmpty(txtAdjustPurchasePrice.Text.Trim()) ? 0 : Convert.ToDecimal(txtAdjustPurchasePrice.Text.Trim()); if (this.txtPayDateStart.Value.Trim() != "" && this.txtPayDateEnd.Value.Trim() != "") { DateTime DateStart = Convert.ToDateTime(txtPayDateStart.Value.Trim()); DateTime DateEnd = Convert.ToDateTime(txtPayDateEnd.Value.Trim()); if (DateStart >= DateEnd) { base.ShowMessage("开始日期不能大于结束日期,请重新选择!"); return; } XMProduct info = base.XMProductService.getXMProductByManufacturersCode(this.MerchantCode); if (info != null) { //采购订单 var PurchaseList = base.XMPurchaseService.GetXMPurchaseByParm(PlatformTypeId, MerchantCode, DateStart, DateEnd); if (PurchaseList != null && PurchaseList.Count > 0) { UpdatePurchase(PlatformTypeId, MerchantCode, PurchasePrice, PurchaseList); } var ProductDetail = base.XMProductDetailsService.GetXMProductDetailsListByProductId(info.Id).Where(x => x.PlatformTypeId == PlatformTypeId).ToList(); if (ProductDetail != null && ProductDetail.Count > 0) { PurchaseList = base.XMPurchaseService.GetXMPurchaseByParm(PlatformTypeId, ProductDetail[0].PlatformMerchantCode, DateStart, DateEnd); if (PurchaseList != null && PurchaseList.Count > 0) { UpdatePurchase(PlatformTypeId, ProductDetail[0].PlatformMerchantCode, PurchasePrice, PurchaseList); } } else { base.ShowMessage("该产品该平台的商品编码不存在!"); return; } } else { base.ShowMessage("该厂家编码不存在!"); return; } base.ShowMessage("操作成功!"); } else { base.ShowMessage("请先填写开始与结束日期!"); return; } } }
/// <summary> /// 记录行 操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvXMProduct_RowUpdating(object sender, GridViewUpdateEventArgs e) { int paramparse = 0; //decimal param = 0; if (int.TryParse(this.gvXMProduct.DataKeys[e.RowIndex].Value.ToString(), out paramparse)) { var row = this.gvXMProduct.Rows[e.RowIndex]; #region 字符验证 if (this.NickId == -1) { var ddlNick = row.FindControl("ddlNick") as DropDownList; ddlNick.Enabled = false; } else { var ddlNick = row.FindControl("ddlNick") as DropDownList; ddlNick.Enabled = true; } //品牌 CodeControl CCBrandTypeId = (CodeControl)row.FindControl("CCBrandTypeId"); var txtProductName = row.FindControl("txtProductName") as TextBox; var lblMsgProductNameVaule = row.FindControl("lblMsgProductNameVaule") as Label; lblMsgProductNameVaule.Text = ""; if (txtProductName.Text.Trim() == "") { lblMsgProductNameVaule.Text = "不允许为空"; } //厂家编码 var txtManufacturersCode = row.FindControl("txtManufacturersCode") as TextBox; var hfManufacturersCode = row.FindControl("hfManufacturersCode") as HiddenField; var lblMsgManufacturersCodeVaule = row.FindControl("lblMsgManufacturersCodeVaule") as Label; lblMsgManufacturersCodeVaule.Text = ""; if (txtManufacturersCode.Text.Trim() == "") { lblMsgManufacturersCodeVaule.Text = "不允许为空"; } //尺寸 var txtSpecifications = row.FindControl("txtSpecifications") as TextBox; var lblMsgSpecificationsVaule = row.FindControl("lblMsgSpecificationsVaule") as Label; lblMsgSpecificationsVaule.Text = ""; if (txtSpecifications.Text.Trim() == "") { lblMsgSpecificationsVaule.Text = "不允许为空"; } //厂家库存 var txtManufacturersInventoryE = row.FindControl("txtManufacturersInventoryE") as TextBox; var lblMsgManufacturersInventoryEVaule = row.FindControl("lblMsgManufacturersInventoryEVaule") as Label; lblMsgManufacturersInventoryEVaule.Text = ""; if (txtManufacturersInventoryE.Text.Trim() == "") { lblMsgManufacturersInventoryEVaule.Text = "不允许为空"; } if (!int.TryParse(txtManufacturersInventoryE.Text.Trim(), out paramparse)) { if (txtManufacturersInventoryE.Text.Trim() != "") { lblMsgManufacturersInventoryEVaule.Text = "请输入正确的数值"; } } //预警库存数 var txtWarningQuantityE = row.FindControl("txtWarningQuantityE") as TextBox; var lblMsgWarningQuantityEVaule = row.FindControl("lblMsgWarningQuantityEVaule") as Label; lblMsgWarningQuantityEVaule.Text = ""; if (txtWarningQuantityE.Text.Trim() == "") { lblMsgWarningQuantityEVaule.Text = "不允许为空"; } if (!int.TryParse(txtWarningQuantityE.Text.Trim(), out paramparse)) { if (txtWarningQuantityE.Text.Trim() != "") { lblMsgWarningQuantityEVaule.Text = "请输入正确的数值"; } } //颜色 var txtProductColors = row.FindControl("txtProductColors") as TextBox; //var lblMsgProductColorsVaule = row.FindControl("lblMsgProductColorsVaule") as Label; //lblMsgProductColorsVaule.Text = ""; //if (txtProductColors.Text.Trim() == "") //{ // lblMsgProductColorsVaule.Text = "不允许为空"; //} //计量单位 var txtProductUnit = row.FindControl("txtProductUnit") as TextBox; //体重 var txtProductWeight = row.FindControl("txtProductWeight") as TextBox; //体积 var txtProductVolume = row.FindControl("txtProductVolume") as TextBox; // 是否赠品 var chkIsPremiums = row.FindControl("chkIsPremiums") as CheckBox; //|| lblMsgProductColorsVaule.Text != "" if (lblMsgProductNameVaule.Text != "" || lblMsgManufacturersCodeVaule.Text != "" || lblMsgSpecificationsVaule.Text != "" || lblMsgManufacturersInventoryEVaule.Text != "" || lblMsgWarningQuantityEVaule.Text != "") { return; } #endregion var Product = base.XMProductService.GetXMProductById(int.Parse(this.gvXMProduct.DataKeys[e.RowIndex].Value.ToString())); List <XMProduct> ProductManufacturersCodeList = new List <XMProduct>(); if (txtManufacturersCode.Text.Trim() != "") { ProductManufacturersCodeList = base.XMProductService.getXMProductListByEqusManufacturersCode(txtManufacturersCode.Text.Trim()); } //修改 if (Product != null) { #region if (ProductManufacturersCodeList.Count > 0) { if (!txtManufacturersCode.Text.Trim().Equals(hfManufacturersCode.Value)) { base.ShowMessage("厂家编码已存在"); return; } } Product.BrandTypeId = CCBrandTypeId.SelectedValue; Product.ProductName = txtProductName.Text.Trim(); Product.ManufacturersCode = txtManufacturersCode.Text.Trim(); Product.Specifications = txtSpecifications.Text.Trim(); int paramparse1 = 0; #region 数据转换 if (int.TryParse(txtManufacturersInventoryE.Text.Trim(), out paramparse1)) { Product.ManufacturersInventory = int.Parse(txtManufacturersInventoryE.Text.Trim()); } else { Product.ManufacturersInventory = 0; } if (int.TryParse(txtWarningQuantityE.Text.Trim(), out paramparse1)) { Product.WarningQuantity = int.Parse(txtWarningQuantityE.Text.Trim()); } else { Product.WarningQuantity = 0; } #endregion Product.ProductColors = txtProductColors.Text.Trim(); Product.ProductUnit = txtProductUnit.Text.Trim(); Product.ProductWeight = txtProductWeight.Text.Trim(); Product.ProductVolume = txtProductVolume.Text.Trim(); Product.IsPremiums = chkIsPremiums.Checked; Product.UpdateID = HozestERPContext.Current.User.SCustomerInfo.CustomerID; Product.UpdateDate = DateTime.Now; //修改产品信息 base.XMProductService.UpdateXMProduct(Product); #endregion } // 新增 else { if (ProductManufacturersCodeList.Count > 0) { base.ShowMessage("厂家编码已存在"); return; } XMProduct ProductNew = new XMProduct(); ProductNew.BrandTypeId = CCBrandTypeId.SelectedValue; ProductNew.ProductName = txtProductName.Text.Trim(); ProductNew.ManufacturersCode = txtManufacturersCode.Text.Trim(); ProductNew.Specifications = txtSpecifications.Text.Trim(); int paramparse1 = 0; #region 数据转换 if (int.TryParse(txtManufacturersInventoryE.Text.Trim(), out paramparse1)) { ProductNew.ManufacturersInventory = int.Parse(txtManufacturersInventoryE.Text.Trim()); } else { ProductNew.ManufacturersInventory = 0; } if (int.TryParse(txtWarningQuantityE.Text.Trim(), out paramparse1)) { ProductNew.WarningQuantity = int.Parse(txtWarningQuantityE.Text.Trim()); } else { ProductNew.WarningQuantity = 0; } #endregion ProductNew.ProductColors = txtProductColors.Text.Trim(); ProductNew.ProductUnit = txtProductUnit.Text.Trim(); ProductNew.ProductWeight = txtProductWeight.Text.Trim(); ProductNew.ProductVolume = txtProductVolume.Text.Trim(); ProductNew.IsPremiums = chkIsPremiums.Checked; ProductNew.UpdateID = HozestERPContext.Current.User.SCustomerInfo.CustomerID; ProductNew.UpdateDate = DateTime.Now; ProductNew.IsEnable = false;//默认可用 ProductNew.CreateID = HozestERPContext.Current.User.SCustomerInfo.CustomerID; ProductNew.CreateDate = DateTime.Now; ProductNew.UpdateID = HozestERPContext.Current.User.SCustomerInfo.CustomerID; ProductNew.UpdateDate = DateTime.Now; //新增产品 base.XMProductService.InsertXMProduct(ProductNew); } this.RowEditIndex = -1; this.BindGrid(this.Master.PageIndex, this.Master.PageSize); } }
protected void btnCalculate_Click(object sender, DirectEventArgs e) { string OrderID = CommonHelper.QueryString("ID"); XMOrderInfo entity_Order = XMOrderInfoService.GetXMOrderInfoByID(int.Parse(OrderID)); if (entity_Order == null) { ExtNet.Msg.Alert("提示", "订单信息不存在").Show(); return; } XMProject entity_Project = XMProjectService.GetXMProjectById(entity_Order.ProjectId); if (entity_Project == null) { ExtNet.Msg.Alert("提示", "项目信息不存在").Show(); return; } if (entity_Project.ProjectName == "曲美") { //干线费用 decimal mainMoney = 0; //支线费用 decimal branchMoney = 0; string province = entity_Order.Province; string city = entity_Order.City; string region = entity_Order.County; string[] mes = entity_Order.CustomerServiceRemark.Split(new string[] { "///" }, StringSplitOptions.RemoveEmptyEntries); if (mes.Count() <= 0) { ExtNet.Msg.Alert("提示", "解析错误").Show(); return; } string[] mes1 = mes[0].Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries); if (mes1.Count() <= 0) { ExtNet.Msg.Alert("提示", "解析错误").Show(); return; } //查询干线物流公司信息 List <CodeList> codeList = CodeService.GetCodeListInfoByCodeTypeIDAndCodeName(243, mes1[0]); if (codeList.Count <= 0) { ExtNet.Msg.Alert("提示", "找不到干线物流公司信息").Show(); return; } int logisticsMainID = codeList[0].CodeID; //查询干线物流单价费率 BusinessLogic.ManageProject.XMLogisticsFeeMain entityMain = XMLogisticsFeeMainService. getSingle(a => a.ProjectID == entity_Project.Id && a.WareHouseID == 758 && province.StartsWith(a.Province) && city.StartsWith(a.City) && region.StartsWith(a.Area) && a.LogisticsID == logisticsMainID); if (entityMain == null) { ExtNet.Msg.Alert("提示", "找不到对应干线单价费率").Show(); return; } //只计算干线费用 if (mes1.Count() == 1) { //对应干线单价费率 decimal main = (decimal)entityMain.Fee; List <XMOrderInfoProductDetails> list_OrderProductDetails = XMOrderInfoProductDetailsService.GetXMOrderInfoProductDetailsList(entity_Order.ID); foreach (var item in list_OrderProductDetails) { string ProductVolume = string.IsNullOrEmpty(item.ProductVolume) ? "0" : item.ProductVolume; mainMoney = mainMoney + main * decimal.Parse(ProductVolume) * (int)item.ProductNum; } } //计算干线和支线费用 else if (mes1.Count() == 2) { //对应干线单价费率 decimal main = (decimal)entityMain.Fee; //查询支线物流公司信息 List <CodeList> codeList1 = CodeService.GetCodeListInfoByCodeTypeIDAndCodeName(244, mes1[1]); if (codeList.Count <= 0) { ExtNet.Msg.Alert("提示", "找不到支线物流公司信息").Show(); return; } List <XMOrderInfoProductDetails> list_OrderProductDetails = XMOrderInfoProductDetailsService.GetXMOrderInfoProductDetailsList(entity_Order.ID); foreach (var item in list_OrderProductDetails) { //对应支线单价费率 decimal Branch = 0; XMProduct entityProduct = XMProductService.getXMProductByManufacturersCode(item.TManufacturersCode); XMProductDetails entityProductDetails = XMProductDetailsService.GetXMProductDetailsListByProductId(entityProduct.Id)[0]; //查询支线物流单价费率 int logisticsBranchID = codeList1[0].CodeID; BusinessLogic.ManageProject.XMLogisticsFeeBranch entityBranch = XMLogisticsFeeBranchService. getSingle(a => a.ProjectID == entity_Project.Id && a.LogisticsID == logisticsBranchID && a.ProductCategoryID == entityProductDetails.ProductTypeId); if (entityBranch == null) { ExtNet.Msg.Alert("提示", "找不到对应支线单价费率").Show(); return; } Branch = (decimal)entityBranch.Fee; //商品体积 string ProductVolume = string.IsNullOrEmpty(entityProduct.ProductVolume) ? "0" : entityProduct.ProductVolume; mainMoney = mainMoney + main * decimal.Parse(ProductVolume) * (int)item.ProductNum; branchMoney = branchMoney + Branch * (int)item.ProductNum; } } //事务 using (TransactionScope scope = new TransactionScope()) { List <BusinessLogic.ManageProject.XMLogisticsFeeDetail> list = XMLogisticsFeeDetailService.getList(a => a.Type != 3); foreach (var item in list) { XMLogisticsFeeDetailService.delete(item); } if (mainMoney >= 0) { XMLogisticsFeeDetailService.InsertXMLogisticsFeeDetail(new BusinessLogic.ManageProject.XMLogisticsFeeDetail() { OrderID = entity_Order.ID, Type = 1, Fee = mainMoney, CreateID = HozestERPContext.Current.User.CustomerID, CreateDate = DateTime.Now, }); } if (branchMoney >= 0) { XMLogisticsFeeDetailService.InsertXMLogisticsFeeDetail(new BusinessLogic.ManageProject.XMLogisticsFeeDetail() { OrderID = entity_Order.ID, Type = 2, Fee = branchMoney, CreateID = HozestERPContext.Current.User.CustomerID, CreateDate = DateTime.Now, }); } scope.Complete(); } } else { ExtNet.Msg.Alert("提示", "不在计算范围内").Show(); return; } }