Ejemplo n.º 1
0
        public ActionResult SaveModify(MaterialScrapTypeViewModels model)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (MaterialScrapServiceClient client = new MaterialScrapServiceClient())
            {
                MaterialScrap woReport = new MaterialScrap()
                {
                    Key         = model.BillCode,
                    ScrapDate   = model.ScrapDate,
                    Type        = model.ScrapType,
                    OrderNumber = model.OrderNumber,
                    Creator     = model.Creator,
                    Editor      = User.Identity.Name,
                    Description = model.Description,
                };

                //result = client.EditWOReport(woReport);

                if (result.Code == 0)
                {
                    result.Message = string.Format(StringResource.MaterialScrap_Edit_Success, model.BillCode);
                }
            }
            return(Json(result));
        }
Ejemplo n.º 2
0
        public ActionResult Save(MaterialScrapTypeViewModels model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                if (string.IsNullOrWhiteSpace(model.BillCode))
                {
                    string BillCode = string.Format("SC{0:yyMMdd}", DateTime.Now);
                    int    itemNo   = 0;
                    using (MaterialScrapServiceClient client = new MaterialScrapServiceClient())
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = 0,
                            PageSize = 1,
                            Where    = string.Format("Key LIKE '{0}%'"
                                                     , BillCode),
                            OrderBy = "Key Desc"
                        };
                        MethodReturnResult <IList <MaterialScrap> > rst = client.Get(ref cfg);
                        if (rst.Code <= 0 && rst.Data.Count > 0)
                        {
                            string maxBillNo = rst.Data[0].Key.Replace(BillCode, "");
                            int.TryParse(maxBillNo, out itemNo);
                        }
                        itemNo++;

                        model.BillCode = BillCode + itemNo.ToString("000");
                    }
                    model.BillCode = model.BillCode.ToUpper();
                }

                using (MaterialScrapServiceClient client = new MaterialScrapServiceClient())
                {
                    IList <MaterialScrapDetail> lstMS = new List <MaterialScrapDetail>();
                    lstMS.Clear();
                    MaterialScrap woReport = new MaterialScrap()
                    {
                        Key       = model.BillCode,
                        ScrapDate = model.ScrapDate,

                        Type        = EnumScrapType.Normal,
                        OrderNumber = model.OrderNumber,
                        Editor      = User.Identity.Name,
                        Creator     = User.Identity.Name,
                        Description = model.Description,
                    };
                    MaterialScrapDetailKey msdKey = new MaterialScrapDetailKey()
                    {
                        ScrapNo = model.BillCode,
                        ItemNo  = 1
                    };
                    MaterialScrapDetail MSDetail = new MaterialScrapDetail()
                    {
                        Key           = msdKey,
                        MaterialCode  = model.MaterialCode,
                        MaterialLot   = model.MaterialLot,
                        OrderNumber   = model.OrderNumber,
                        Qty           = model.Qty,
                        LineStoreName = model.LineStoreName,
                        Description   = model.Description,
                        Editor        = User.Identity.Name,
                        Creator       = User.Identity.Name,
                    };
                    lstMS.Add(MSDetail);
                    result = client.Add(woReport, lstMS);
                    if (result.Code == 0)
                    {
                        result.Message = string.Format(StringResource.MaterialScrap_Save_Success, model.BillCode);
                        result.Detail  = woReport.Key;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            return(Json(result));
        }