コード例 #1
0
        public void SaveMaterial()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    if (parm.Category == null || parm.Category == "")
                    {
                        throw new Exception("请填写材料类型。");
                    }
                    //if (parm.SubCategory == null || parm.SubCategory == "")
                    //{
                    //    throw new Exception("请选择对应子类型。");
                    //}
                    //Guid guidCategory = new Guid(parm.Category);
                    //Guid guidSubCategory = new Guid(parm.SubCategory);
                    //Category category = p.Client.GetCategory(SenderUser, guidCategory);
                    //Category subCategory = p.Client.GetCategory(SenderUser, guidSubCategory);

                    SaveMaterialArgs args     = new SaveMaterialArgs();
                    Material         material = p.Client.GetMaterial(SenderUser, parm.MaterialID);
                    if (material == null)
                    {
                        material            = new Material();
                        material.MaterialID = parm.MaterialID;
                    }
                    material.MaterialID      = parm.MaterialID;
                    material.Category        = parm.Category;
                    material.SubCategory     = "";
                    material.MaterialCode    = parm.MaterialCode;
                    material.MaterialName    = parm.MaterialName;
                    material.Style           = parm.Style;
                    material.Unit            = parm.Unit;
                    material.Color           = parm.Color;
                    material.Deepth          = parm.Deepth;
                    material.QuotedPrice     = parm.QuotedPrice;
                    material.SafetyStock_Qty = parm.SafetyStock_Qty;
                    material.Withholding_Qty = parm.Withholding_Qty;
                    material.ImageUrl        = "";
                    material.Remark          = "";
                    args.Material            = material;
                    p.Client.SaveMaterial(SenderUser, args);
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
コード例 #2
0
ファイル: MaterialBE.cs プロジェクト: godsayyou/Mes-1
        public void SaveMaterial(Sender sender, SaveMaterialArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    Material obj = new Material();
                    obj.MaterialID = args.Material.MaterialID;
                    if (op.LoadMaterialByMaterialID(obj) == 0)
                    {
                        args.Material.Created    = DateTime.Now;
                        args.Material.CreatedBy  = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                        args.Material.Modified   = DateTime.Now;
                        args.Material.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                        op.InsertMaterial(args.Material);
                    }
                    else
                    {
                        args.Material.Modified   = DateTime.Now;
                        args.Material.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName);
                        op.UpdateMaterialByMaterialID(args.Material);
                    }

                    if (args.Material2Suppliers != null)
                    {
                        foreach (Material2Supplier item in args.Material2Suppliers)
                        {
                            Material2Supplier subObj = new Material2Supplier();
                            subObj.MaterialID = item.MaterialID;
                            subObj.SupplierID = item.SupplierID;
                            if (op.LoadMaterial2SupplierByMaterialID_SupplierID(subObj) == 0)
                            {
                                op.InsertMaterial2Supplier(item);
                            }
                            else
                            {
                                op.UpdateMaterial2SupplierByMaterialID_SupplierID(item);
                            }
                        }
                    }
                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }