Exemple #1
0
        // GET: IssueMaterialLoad
        //public HttpResponseMessage Index()
        //{
        //    return View();
        //}


        public HttpResponseMessage Post([FromBody] MaterialReturn retnMaterial)
        {
            if (retnMaterial.Company == null || retnMaterial.Company == "")
            {
                Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Company cannot be blank !");
            }

            if (retnMaterial.PartNum == null || retnMaterial.PartNum == "")
            {
                Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Part cannot be blank !");
            }

            BusinessLayer  BL = new BusinessLayer();
            MaterialReturn retnMaterialReturn = new MaterialReturn();

            retnMaterialReturn = BL.RetnValidatePart(retnMaterial);
            // ViewBag.message = "Success";
            return(Request.CreateResponse(HttpStatusCode.OK, retnMaterialReturn));
        }
Exemple #2
0
        public async Task <IActionResult> ProductReturn(string [] matId, string [] ItemNumber, string [] qty, string slipNumber)
        {
            var models = new List <MaterialReturn>();

            for (int i = 0; i < matId.Count(); i++)
            {
                var model = new MaterialReturn();
                model.Id              = Convert.ToInt32(HttpContext.Session.GetInt32("TransactionId"));
                model.ProductId       = Convert.ToInt32(matId[i]);
                model.UniqueItemId    = Convert.ToInt32(ItemNumber[i].ToString() ?? "0");
                model.Quantity        = Convert.ToDecimal(qty[i]);
                model.SlipNumber      = slipNumber;
                model.TransactionType = "Return";
                model.TransactionDate = DateTime.Now;
                models.Add(model);
            }
            var response = await _IProductReturnService.MaterialReturn(models);

            return(Json(""));
        }
Exemple #3
0
        private void btnSendMetrial_Click(object sender, EventArgs e)
        {
            if (this.edtMaterialLot.Value.Trim() == string.Empty)
            {
                ApplicationRun.GetInfoForm().AddEx("$Please_Input_MaterialLot");
                this.edtMaterialLot.TextFocus(false, true);
                return;
            }

            if (this.edtReturnNumber.Value.Trim() == string.Empty)
            {
                ApplicationRun.GetInfoForm().AddEx("$CS_InPut_ReturnNumber");
                this.edtReturnNumber.TextFocus(false, true);
                return;
            }

            if (Convert.ToInt32(this.edtReturnNumber.Value.Trim()) < 1)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_Retun_Qty_Should_Over_Zero"));
                this.edtReturnNumber.TextFocus(false, true);
                return;
            }

            InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
            MaterialLot     materialLot     = (MaterialLot)inventoryFacade.GetMaterialLot(FormatHelper.CleanString(this.edtMaterialLot.Value.Trim().ToUpper()));

            if (materialLot == null)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_CS_MaterialLot_Must_Exist"));
                this.edtMaterialLot.TextFocus(false, true);
                return;
            }

            if (materialLot.LotQty + Convert.ToInt32(this.edtReturnNumber.Value.Trim()) > materialLot.LotInQty)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_MaterialLot_LotQty:" + materialLot.LotQty + "$CS_MaterialLot_LotInQty:" + materialLot.LotInQty));
                this.edtReturnNumber.TextFocus(false, true);
                return;
            }

            DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);


            try
            {
                this.DataProvider.BeginTransaction();

                materialLot.LotQty      += Convert.ToInt32(this.edtReturnNumber.Value.Trim());
                materialLot.MaintainUser = ApplicationService.Current().UserCode;
                materialLot.MaintainDate = dBDateTime.DBDate;
                materialLot.MaintainTime = dBDateTime.DBTime;

                inventoryFacade.UpdateMaterialLot(materialLot);

                MaterialReturn materialReturn = new MaterialReturn();

                materialReturn.MaterialLotNo = materialLot.MaterialLotNo;
                materialReturn.PostSeq       = inventoryFacade.GetMaterialReturnsMaxSeq(materialLot.MaterialLotNo);
                materialReturn.TransQty      = Convert.ToInt32(this.edtReturnNumber.Value.Trim());
                materialReturn.MaintainUser  = ApplicationService.Current().UserCode;
                materialReturn.MaintainDate  = dBDateTime.DBDate;
                materialReturn.MaintainTime  = dBDateTime.DBTime;

                inventoryFacade.AddMaterialReturn(materialReturn);

                this.DataProvider.CommitTransaction();

                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_ReturnMaterialLot_Success"));
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();

                Messages msg = new Messages();
                msg.Add(new UserControl.Message(ex));
                ApplicationRun.GetInfoForm().Add(msg);
            }

            this.edtMaterialLot.TextFocus(false, true);
        }
        public async Task <ActionResult> Save(MaterialReturnViewModel model)
        {
            MethodReturnResult rst = new MethodReturnResult();

            try
            {
                using (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
                {
                    MaterialReturn obj = new MaterialReturn()
                    {
                        Key         = model.ReturnNo.ToUpper(),
                        OrderNumber = model.OrderNumber.ToUpper(),
                        ReturnDate  = model.ReturnDate,
                        Description = model.Description,
                        Editor      = User.Identity.Name,
                        Creator     = User.Identity.Name
                    };

                    char splitChar      = ',';
                    var  ItemNos        = Request["ItemNo"].Split(splitChar);
                    var  LineStoreNames = Request["LineStoreName"].Split(splitChar);
                    var  MaterialCodes  = Request["MaterialCode"].Split(splitChar);
                    var  MaterialLots   = Request["MaterialLot"].Split(splitChar);
                    var  Qtys           = Request["Qty"].Split(splitChar);
                    var  Descriptions   = Request["DetailDescription"].Split(splitChar);

                    List <MaterialReturnDetail> lst = new List <MaterialReturnDetail>();
                    for (int i = 0; i < ItemNos.Length; i++)
                    {
                        lst.Add(new MaterialReturnDetail()
                        {
                            Key = new MaterialReturnDetailKey()
                            {
                                ReturnNo = model.ReturnNo,
                                ItemNo   = i + 1
                            },
                            LineStoreName = LineStoreNames[i].ToUpper(),
                            MaterialCode  = MaterialCodes[i].ToUpper(),
                            MaterialLot   = MaterialLots[i].ToUpper(),
                            Qty           = Convert.ToDouble(Qtys[i]),
                            Description   = Descriptions[i],
                            Editor        = User.Identity.Name,
                            Creator       = User.Identity.Name
                        });
                    }

                    rst = await client.AddAsync(obj, lst);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(LSMResources.StringResource.MaterialReturn_Save_Success
                                                    , obj.Key);
                    }
                }
            }
            catch (Exception ex)
            {
                rst.Code    = 1000;
                rst.Message = ex.Message;
                rst.Detail  = ex.ToString();
            }
            return(Json(rst));
        }
        public async Task <ActionResult> ExportToExcel(MaterialReturnDetailQueryViewModel model)
        {
            IList <MaterialReturnDetail> lst = new List <MaterialReturnDetail>();

            using (MaterialReturnServiceClient client = new MaterialReturnServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "CreateTime Desc,Key.ReturnNo,Key.ItemNo",
                        Where    = GetWhereCondition(model)
                    };
                    MethodReturnResult <IList <MaterialReturnDetail> > result = client.GetDetail(ref cfg);

                    if (result.Code == 0)
                    {
                        lst = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.THIN;
            style.BorderLeft   = BorderStyle.THIN;
            style.BorderRight  = BorderStyle.THIN;
            style.BorderTop    = BorderStyle.THIN;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);
            ICell  cell = null;
            IRow   row  = null;
            ISheet ws   = null;

            for (int j = 0; j < lst.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws  = wb.CreateSheet();
                    row = ws.CreateRow(0);
                    #region //列名
                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnViewModel_ReturnNo);  //退料号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnViewModel_OrderNumber);  //工单号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnViewModel_ReturnDate);  //领料日期

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnDetailViewModel_ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnDetailViewModel_LineStoreName);  //线别仓

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnDetailViewModel_MaterialCode);  //物料编码

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("物料名称");  //物料名称

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnDetailViewModel_MaterialLot);  //物料批号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(LSMResources.StringResource.MaterialReturnDetailViewModel_Qty);  //数量


                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("描述");  //描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("编辑人");  //编辑人

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("编辑时间");  //编辑时间
                    #endregion
                    font.Boldweight = 5;
                }

                MaterialReturnDetail obj   = lst[j];
                MaterialReturn       mrObj = model.GetMaterialReturn(obj.Key.ReturnNo);
                Material             m     = model.GetMaterial(obj.MaterialCode);
                row = ws.CreateRow(j + 1);

                #region //数据
                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReturnNo);  //领料号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(mrObj == null ? string.Empty : mrObj.OrderNumber);  //工单号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(mrObj == null ? string.Empty : string.Format("{0:yyyy-MM-dd}", mrObj.ReturnDate));  //领料日期

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ItemNo);  //项目号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.LineStoreName);  //线别仓

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.MaterialCode);  //物料编码

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(m == null ? string.Empty : m.Name);  //物料名称

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.MaterialLot);  //物料批号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Qty);  //数量


                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Editor);  //编辑人

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime));  //编辑时间
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "MaterialReturnData.xls"));
        }