Exemple #1
0
        public ActionResult SaveDeralation(decimal Declaration_Refence_Id, string Declaration_Code,
                                           DateTime Register_Date, decimal Total_Value, string Gate, decimal Receive_Number,
                                           decimal Receive_Year, string Source, string Custom_Register,
                                           decimal Declaration_Type, string STR_LIST_PRODUCTS)
        {
            try
            {
                Declaration_BL   _objBL      = new Declaration_BL();
                Declaration_Info _Importinfo = _objBL.DeclarationGetById(Declaration_Refence_Id);
                Declaration_Info _ObjInfo    = new Declaration_Info();
                _ObjInfo.Declaration_Refence_Id   = Declaration_Refence_Id;
                _ObjInfo.Declaration_Refence_Code = _Importinfo.Declaration_Code;
                _ObjInfo.Declaration_Code         = Declaration_Code;
                _ObjInfo.Contract_Id        = _Importinfo.Contract_Id;
                _ObjInfo.Register_Date      = Register_Date;
                _ObjInfo.Contract_Code      = _Importinfo.Contract_Code;
                _ObjInfo.Total_Value        = Total_Value;
                _ObjInfo.WareHouse_Id       = _Importinfo.WareHouse_Id;
                _ObjInfo.WareHouse_Name     = _Importinfo.WareHouse_Name;
                _ObjInfo.WareHouse_Location = _Importinfo.WareHouse_Location;
                _ObjInfo.Gate             = Gate;
                _ObjInfo.Receive_Number   = Receive_Number;
                _ObjInfo.Receive_Year     = Receive_Year;
                _ObjInfo.Source           = Source; _ObjInfo.Custom_Register = Custom_Register;
                _ObjInfo.Declaration_Type = Declaration_Type;
                _ObjInfo.Status           = (decimal)NaviCommon.Enum_Contract_Status.ChoDuyet;
                _ObjInfo.Type             = (decimal)NaviCommon.Enum_Declaration_Type.ToKhai_Xuat;
                _ObjInfo.Created_Date     = NaviCommon.CommonFuc.CurrentDate();
                _ObjInfo.Created_By       = SessionData.CurrentUser.User_Name;
                STR_LIST_PRODUCTS         = STR_LIST_PRODUCTS.Trim().Trim('|');
                Product_Declaration_Info        _SubInfo     = new Product_Declaration_Info();
                List <Product_Declaration_Info> _ListProduct = new List <Product_Declaration_Info>();
                decimal _rel = 0;

                _rel = _objBL.Declaration_Insert(_ObjInfo);
                if (_rel > 0)
                {
                    string[] _strProduct = STR_LIST_PRODUCTS.Split('|');
                    foreach (var _str in _strProduct)
                    {
                        _SubInfo = new Product_Declaration_Info();
                        string[] _temp = _str.Split(',');
                        if (_temp.Length == 4)
                        {
                            _SubInfo.Declaration_Id           = _rel;
                            _SubInfo.Product_Id               = Convert.ToDecimal(_temp[0]);
                            _SubInfo.Package_Quantity         = Convert.ToDecimal(_temp[1]);
                            _SubInfo.Quantity                 = Convert.ToDecimal(_temp[2]);
                            _SubInfo.Value                    = Convert.ToDecimal(_temp[3]);
                            _SubInfo.Type                     = (decimal)NaviCommon.ProductDeralationType.Export;
                            _SubInfo.Declaration_Reference_Id = Declaration_Refence_Id;
                            _ListProduct.Add(_SubInfo);
                        }
                    }
                }
                Product_Declaration_BL _PrDBL = new Product_Declaration_BL();
                foreach (Product_Declaration_Info item in _ListProduct)
                {
                    if (_PrDBL.Product_Declaration_Insert(item) == false)
                    {
                        _rel = -1;
                        break;
                    }
                }
                return(Json(new { success = _rel }));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(Json(new { success = -1 }));
            }
        }
Exemple #2
0
 public ActionResult SaveDeralation(string Declaration_Code, decimal Contract_Id, string Contract_Code, DateTime Register_Date,
                                    decimal Total_Value, decimal WareHouse_Id, string WareHouse_Name, string Gate, decimal Receive_Number,
                                    decimal Receive_Year, decimal VANDON_NUMBER, DateTime VANDON_DATE, string Source, string Custom_Register,
                                    decimal Declaration_Type, string STR_LIST_PRODUCTS)
 {
     try
     {
         Declaration_Info _ObjInfo = new Declaration_Info();
         _ObjInfo.Declaration_Code = Declaration_Code;
         _ObjInfo.Contract_Id      = Contract_Id; _ObjInfo.Register_Date = Register_Date;
         _ObjInfo.Contract_Code    = Contract_Code.Trim();
         _ObjInfo.Total_Value      = Total_Value;  _ObjInfo.WareHouse_Id = WareHouse_Id;
         _ObjInfo.WareHouse_Name   = WareHouse_Name;  _ObjInfo.Gate = Gate;
         _ObjInfo.Receive_Number   = Receive_Number;
         _ObjInfo.Receive_Year     = Receive_Year; _ObjInfo.VANDON_NUMBER = VANDON_NUMBER;
         _ObjInfo.VANDON_DATE      = VANDON_DATE; _ObjInfo.VANDON_DATE = VANDON_DATE;
         _ObjInfo.Source           = Source; _ObjInfo.Custom_Register = Custom_Register;
         _ObjInfo.Declaration_Type = Declaration_Type;
         _ObjInfo.Status           = (decimal)NaviCommon.Enum_Contract_Status.ChoDuyet;
         _ObjInfo.Type             = (decimal)NaviCommon.Enum_Declaration_Type.ToKhai_Nhap;
         _ObjInfo.Created_Date     = NaviCommon.CommonFuc.CurrentDate();
         _ObjInfo.Created_By       = SessionData.CurrentUser.User_Name;
         STR_LIST_PRODUCTS         = STR_LIST_PRODUCTS.Trim().Trim('|');
         Product_Declaration_Info        _SubInfo     = new Product_Declaration_Info();
         List <Product_Declaration_Info> _ListProduct = new List <Product_Declaration_Info>();
         decimal        _rel   = 0;
         Declaration_BL _objBL = new Declaration_BL();
         _rel = _objBL.Declaration_Insert(_ObjInfo);
         if (_rel > 0)
         {
             string[] _strProduct = STR_LIST_PRODUCTS.Split('|');
             foreach (var _str in _strProduct)
             {
                 _SubInfo = new Product_Declaration_Info();
                 string[] _temp = _str.Split(',');
                 if (_temp.Length == 5)
                 {
                     _SubInfo.Declaration_Id   = _rel;
                     _SubInfo.Product_Id       = Convert.ToDecimal(_temp[0]);
                     _SubInfo.Package_Quantity = Convert.ToDecimal(_temp[1]);
                     _SubInfo.Quantity         = Convert.ToDecimal(_temp[2]);
                     _SubInfo.Made_In          = _temp[3];
                     _SubInfo.Value            = Convert.ToDecimal(_temp[4]);
                     _SubInfo.Type             = (decimal)NaviCommon.ProductDeralationType.Import;
                     // nếu là nhập import thì trường sl còn lại nhâp = luôn số lượng nhập
                     _SubInfo.Package_Quantity_Delivery = _SubInfo.Package_Quantity;
                     _SubInfo.Quantity_Delivery         = _SubInfo.Quantity;
                     _ListProduct.Add(_SubInfo);
                 }
             }
         }
         Product_Declaration_BL _PrDBL = new Product_Declaration_BL();
         foreach (Product_Declaration_Info item in _ListProduct)
         {
             if (_PrDBL.Product_Declaration_Insert(item) == false)
             {
                 _rel = -1;
                 break;
             }
         }
         return(Json(new { success = _rel }));
     }
     catch (Exception ex)
     {
         NaviCommon.Common.log.Error(ex.ToString());
         return(Json(new { success = -1 }));
     }
 }