/// <summary> /// /// </summary> private void InsertSaleReturnBarCodes(int saleReturnDetailID, int PID, int returnCount) { if (Session["SaleReturn"] != null) { List <BarCodeInfo> BarCodeList = Session["SaleReturn"] as List <BarCodeInfo>; if (BarCodeList != null && BarCodeList.Count > 0) { foreach (BarCodeInfo str in BarCodeList) { if (str.PID == PID) { if (str.BarCodeStr != "" && str.BarCodeStr.Length > 0) { string[] p = str.BarCodeStr.Split(';'); if (p.Count() != returnCount) { base.ShowMessage("退货商品条形码数量不一致,请重新录入!"); return; } if (p.Count() > 0) { foreach (string parm in p) { //判断当前产品条形码是否存在 如不存在新增 var info = base.XMSaleReturnBarCodeDetailService.GetXMSaleReturnBarCodeDetailByParm(saleReturnDetailID, parm); if (info == null) //新增 { XMSaleReturnBarCodeDetail rDetail = new XMSaleReturnBarCodeDetail(); rDetail.SpdId = saleReturnDetailID; var saleReturnDetails = base.XMSaleReturnProductDetailsService.GetXMSaleReturnProductDetailsById(saleReturnDetailID); if (saleReturnDetails != null) { rDetail.ProductId = saleReturnDetails.ProductId; } rDetail.BarCode = parm; rDetail.CreateDate = rDetail.UpdateDate = DateTime.Now; rDetail.CreateID = rDetail.UpdateID = HozestERPContext.Current.User.CustomerID; rDetail.IsEnable = false; base.XMSaleReturnBarCodeDetailService.InsertXMSaleReturnBarCodeDetail(rDetail); } } } } } } } } }
protected void btnSaveBarCodes_Click(object sender, EventArgs e) { TextBox txtBarCode = grdvBarCodeList.Rows[grdvBarCodeList.Rows.Count - 1].FindControl("txtBarCodes") as TextBox; if (txtBarCode != null) { switch (this.Status) { case "Storage": if (txtBarCode.Text.Trim() != "") { var info = base.XMStorageProductBarCodeDetailService.GetXMStorageProductBarCodeDetailByParm(this.PID, txtBarCode.Text.Trim()); if (info != null) { ShowMessage("条形码已经存在,无法添加条形码!"); return; } } else { ShowMessage("请录入条形码!"); return; } var storageBarCodes = base.XMStorageProductBarCodeDetailService.GetXMStorageProductBarCodeDetailListBySpdID(this.PID); var storageProductDetails = base.XMStorageProductDetailsService.GetXMStorageProductDetailsById(this.PID); if (storageProductDetails != null) { int storageCount = storageProductDetails.ProductsCount; if (storageBarCodes.Count < storageCount) //入库商品条形码数量小于入库数量 可以新增 { XMStorageProductBarCodeDetail sDetails = new XMStorageProductBarCodeDetail(); sDetails.SpdId = this.PID; sDetails.ProductId = storageProductDetails.ProductId; sDetails.PlatformMerchantCode = storageProductDetails.PlatformMerchantCode; sDetails.BarCode = txtBarCode.Text.Trim(); sDetails.CreateDate = sDetails.UpdateDate = DateTime.Now; sDetails.CreateID = sDetails.UpdateID = HozestERPContext.Current.User.CustomerID; sDetails.IsEnable = false; base.XMStorageProductBarCodeDetailService.InsertXMStorageProductBarCodeDetail(sDetails); } else { ShowMessage("入库商品条形码数量大于入库数量,无法添加条形码!"); return; } } break; case "Delivery": if (txtBarCode.Text.Trim() != "") { var info = base.XMSaleDeliveryBarCodeDetailService.GetXMSaleDeliveryBarCodeDetailByParm(this.PID, txtBarCode.Text.Trim()); if (info != null) { ShowMessage("条形码已经存在,无法添加条形码!"); return; } } else { ShowMessage("请录入条形码!"); return; } var deliveryBarcodes = base.XMSaleDeliveryBarCodeDetailService.GetXMSaleDeliveryBarCodeDetailListBySpdID(this.PID); var deliveryPorductDetails = base.XMSaleDeliveryProductDetailsService.GetXMSaleDeliveryProductDetailsById(this.PID); if (deliveryPorductDetails != null) { int deliveryCount = deliveryPorductDetails.SaleCount.Value; //销售出库数量 if (deliveryBarcodes.Count < deliveryCount) //出库商品条形码数量小于出库数量 可以新增 { XMSaleDeliveryBarCodeDetail dDetail = new XMSaleDeliveryBarCodeDetail(); dDetail.SpdId = this.PID; dDetail.ProductId = deliveryPorductDetails.ProductId; dDetail.PlatformMerchantCode = deliveryPorductDetails.PlatformMerchantCode; dDetail.BarCode = txtBarCode.Text.Trim(); dDetail.CreateDate = dDetail.UpdateDate = DateTime.Now; dDetail.CreateID = dDetail.UpdateID = HozestERPContext.Current.User.CustomerID; dDetail.IsEnable = false; base.XMSaleDeliveryBarCodeDetailService.InsertXMSaleDeliveryBarCodeDetail(dDetail); } else { ShowMessage("出库商品条形码数量大于出库数量,无法添加条形码!"); return; } } break; case "SaleReturn": if (txtBarCode.Text.Trim() != "") { var info = base.XMSaleReturnBarCodeDetailService.GetXMSaleReturnBarCodeDetailByParm(this.PID, txtBarCode.Text.Trim()); if (info != null) { ShowMessage("条形码已经存在,无法添加条形码!"); return; } } else { ShowMessage("请录入条形码!"); return; } var saleReturnBarcodes = base.XMSaleReturnBarCodeDetailService.GetXMSaleReturnBarCodeDetailListBySrdID(this.PID); var saleReturnPorductDetails = base.XMSaleReturnProductDetailsService.GetXMSaleReturnProductDetailsById(this.PID); if (saleReturnPorductDetails != null) { int saleReturnCount = saleReturnPorductDetails.RejectionProdcutsCount.Value; if (saleReturnBarcodes.Count < saleReturnCount) { XMSaleReturnBarCodeDetail rDetails = new XMSaleReturnBarCodeDetail(); rDetails.SpdId = this.PID; rDetails.ProductId = saleReturnPorductDetails.ProductId; rDetails.BarCode = txtBarCode.Text.Trim(); rDetails.CreateDate = rDetails.UpdateDate = DateTime.Now; rDetails.CreateID = rDetails.UpdateID = HozestERPContext.Current.User.CustomerID; rDetails.IsEnable = false; base.XMSaleReturnBarCodeDetailService.InsertXMSaleReturnBarCodeDetail(rDetails); } else { ShowMessage("退货商品条形码数量大于退货数量,无法添加条形码!"); return; } } break; } } this.BindGrid(this.Master.PageIndex, this.Master.PageSize); }
protected void grdvBarCodeList_RowUpdating(object sender, GridViewUpdateEventArgs e) { int id = 0; int.TryParse(this.grdvBarCodeList.DataKeys[e.RowIndex].Value.ToString(), out id); if (id != 0) //编辑 { var row = this.grdvBarCodeList.Rows[e.RowIndex]; TextBox txtBarCode = row.FindControl("txtBarCodes") as TextBox; switch (this.Status) { case "Storage": var storageBarcodes = base.XMStorageProductBarCodeDetailService.GetXMStorageProductBarCodeDetailById(id); if (storageBarcodes != null) { if (txtBarCode != null) { storageBarcodes.BarCode = txtBarCode.Text.Trim(); storageBarcodes.UpdateDate = DateTime.Now; storageBarcodes.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMStorageProductBarCodeDetailService.UpdateXMStorageProductBarCodeDetail(storageBarcodes); } } break; case "Delivery": var deliveryBarcodes = base.XMSaleDeliveryBarCodeDetailService.GetXMSaleDeliveryBarCodeDetailById(id); if (deliveryBarcodes != null) { if (txtBarCode != null) { deliveryBarcodes.BarCode = txtBarCode.Text.Trim(); deliveryBarcodes.UpdateDate = DateTime.Now; deliveryBarcodes.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMSaleDeliveryBarCodeDetailService.UpdateXMSaleDeliveryBarCodeDetail(deliveryBarcodes); } } break; case "SaleReturn": var saleReturnBarcodes = base.XMSaleReturnBarCodeDetailService.GetXMSaleReturnBarCodeDetailById(id); if (saleReturnBarcodes != null) { if (txtBarCode != null) { saleReturnBarcodes.BarCode = txtBarCode.Text.Trim(); saleReturnBarcodes.UpdateDate = DateTime.Now; saleReturnBarcodes.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMSaleReturnBarCodeDetailService.UpdateXMSaleReturnBarCodeDetail(saleReturnBarcodes); } } break; case "Allocate": var allocateBarcodes = base.XMAllocateProductBarCodeDetailService.GetXMAllocateProductBarCodeDetailById(id); if (allocateBarcodes != null) { if (txtBarCode != null) { allocateBarcodes.BarCode = txtBarCode.Text.Trim(); allocateBarcodes.UpdateDate = DateTime.Now; allocateBarcodes.UpdateID = HozestERPContext.Current.User.CustomerID; base.XMAllocateProductBarCodeDetailService.UpdateXMAllocateProductBarCodeDetail(allocateBarcodes); } } break; } this.RowEditIndex = -1; this.BindGrid(this.Master.PageIndex, this.Master.PageSize); } else //新增 { var row = this.grdvBarCodeList.Rows[e.RowIndex]; TextBox txtBarCode = row.FindControl("txtBarCodes") as TextBox; switch (this.Status) { case "Storage": var storageBarCodes = base.XMStorageProductBarCodeDetailService.GetXMStorageProductBarCodeDetailListBySpdID(this.PID); var storageProductDetails = base.XMStorageProductDetailsService.GetXMStorageProductDetailsById(this.PID); if (storageProductDetails != null) { int storageCount = storageProductDetails.ProductsCount; if (storageBarCodes.Count < storageCount) //入库商品条形码数量小于入库数量 可以新增 { XMStorageProductBarCodeDetail sDetails = new XMStorageProductBarCodeDetail(); sDetails.SpdId = this.PID; sDetails.ProductId = storageProductDetails.ProductId; sDetails.PlatformMerchantCode = storageProductDetails.PlatformMerchantCode; sDetails.BarCode = txtBarCode.Text.Trim(); sDetails.CreateDate = sDetails.UpdateDate = DateTime.Now; sDetails.CreateID = sDetails.UpdateID = HozestERPContext.Current.User.CustomerID; sDetails.IsEnable = false; base.XMStorageProductBarCodeDetailService.InsertXMStorageProductBarCodeDetail(sDetails); } else { ShowMessage("入库商品条形码数量大于入库数量,无法添加条形码!"); return; } } break; case "Delivery": var deliveryBarcodes = base.XMSaleDeliveryBarCodeDetailService.GetXMSaleDeliveryBarCodeDetailListBySpdID(this.PID); var deliveryPorductDetails = base.XMSaleDeliveryProductDetailsService.GetXMSaleDeliveryProductDetailsById(this.PID); if (deliveryPorductDetails != null) { int deliveryCount = deliveryPorductDetails.SaleCount.Value; //销售出库数量 if (deliveryBarcodes.Count < deliveryCount) //出库商品条形码数量小于出库数量 可以新增 { XMSaleDeliveryBarCodeDetail dDetail = new XMSaleDeliveryBarCodeDetail(); dDetail.SpdId = this.PID; dDetail.ProductId = deliveryPorductDetails.ProductId; dDetail.PlatformMerchantCode = deliveryPorductDetails.PlatformMerchantCode; dDetail.BarCode = txtBarCode.Text.Trim(); dDetail.CreateDate = dDetail.UpdateDate = DateTime.Now; dDetail.CreateID = dDetail.UpdateID = HozestERPContext.Current.User.CustomerID; dDetail.IsEnable = false; base.XMSaleDeliveryBarCodeDetailService.InsertXMSaleDeliveryBarCodeDetail(dDetail); } else { ShowMessage("出库商品条形码数量大于出库数量,无法添加条形码!"); return; } } break; case "SaleReturn": var saleReturnBarcodes = base.XMSaleReturnBarCodeDetailService.GetXMSaleReturnBarCodeDetailListBySrdID(this.PID); var saleReturnPorductDetails = base.XMSaleReturnProductDetailsService.GetXMSaleReturnProductDetailsById(this.PID); if (saleReturnPorductDetails != null) { int saleReturnCount = saleReturnPorductDetails.RejectionProdcutsCount.Value; if (saleReturnBarcodes.Count < saleReturnCount) { XMSaleReturnBarCodeDetail rDetails = new XMSaleReturnBarCodeDetail(); rDetails.SpdId = this.PID; rDetails.ProductId = saleReturnPorductDetails.ProductId; rDetails.BarCode = txtBarCode.Text.Trim(); rDetails.CreateDate = rDetails.UpdateDate = DateTime.Now; rDetails.CreateID = rDetails.UpdateID = HozestERPContext.Current.User.CustomerID; rDetails.IsEnable = false; base.XMSaleReturnBarCodeDetailService.InsertXMSaleReturnBarCodeDetail(rDetails); } else { ShowMessage("退货商品条形码数量大于退货数量,无法添加条形码!"); return; } } break; //case "Allocate": // break; } this.BindGrid(this.Master.PageIndex, this.Master.PageSize); } }