public bool Product_Declaration_Insert(Product_Declaration_Info Product_Declaration_Info) { try { return(CommonData.c_serviceWCF.Product_Declaration_Insert(Product_Declaration_Info.Product_Id, Product_Declaration_Info.Declaration_Id, Product_Declaration_Info.Type, Product_Declaration_Info.Unit, Product_Declaration_Info.Made_In, Product_Declaration_Info.Wrong_Number, Product_Declaration_Info.Package_Quantity, Product_Declaration_Info.Quantity, Product_Declaration_Info.Value, Product_Declaration_Info.Package_Quantity_Delivery, Product_Declaration_Info.Quantity_Delivery, Product_Declaration_Info.Declaration_Reference_Id)); } catch (Exception ex) { NaviCommon.Common.log.Error(ex.ToString()); return(false); } }
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 })); } }
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 })); } }
public ActionResult Products_ImportFile(HttpPostedFileBase uploadFile) { string filePath = ""; try { int _rel = 1; List <Product_Declaration_Info> lst_product_Dec = new List <Product_Declaration_Info>(); if (uploadFile != null) { if (!string.IsNullOrEmpty(uploadFile.FileName)) { // lấy ds sản phẩm lên trước Product_BL _Product_BL = new Product_BL(); List <Product_Info> _lst_data = _Product_BL.Product_GetAll(); Hashtable _hsProduct = new Hashtable(); foreach (Product_Info item in _lst_data) { _hsProduct[item.Product_Code.ToUpper()] = item; } string _temp = uploadFile.FileName; string _file_name = NaviCommon.CommonFuc.Get_File_name(ref _temp); // Lưu file vao server filePath = Server.MapPath(NaviCommon.Config_Info.c_file_Upload_Sync + _file_name); // Nếu có file rồi delete cho chắc if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } uploadFile.SaveAs(filePath); string file_extension = System.IO.Path.GetExtension(filePath); DataSet ds = new DataSet(); ds = CommonFuc.ReadXlsxFile(filePath); System.IO.File.Delete(filePath); #region Đọc file if (ds.Tables.Count > 0) { int i = 0; foreach (DataRow dr in ds.Tables[0].Rows) { i++; if (i < 3) { // chỉ lấy dòng thứ 3 trở đi continue; } Product_Declaration_Info _PruductInfo = new Product_Declaration_Info(); string _ProductCode = ""; decimal _Pack_Quantity = 0; decimal _Quantity = 0; string _MadeIn = ""; decimal _Value = 0; _ProductCode = dr[0].ToString(); if (!_hsProduct.ContainsKey(_ProductCode.ToUpper())) { // không tồn tại sản phẩm _rel = -10; break; } // số kiện try { _Pack_Quantity = Convert.ToDecimal(dr[1].ToString()); } catch (Exception) { _rel = -11;// ko phải là số break; } // số lượng try { _Quantity = Convert.ToDecimal(dr[2].ToString()); } catch (Exception) { _rel = -11;// ko phải là số break; } //nơi xuất xứ _MadeIn = dr[3].ToString(); try { _Value = Convert.ToDecimal(dr[4].ToString()); } catch (Exception) { _rel = -11;// ko phải là số break; } Product_Info _tempInfo = (Product_Info)_hsProduct[_ProductCode.ToUpper()]; _PruductInfo.Product_Id = _tempInfo.Product_Id; _PruductInfo.Product_Code = _ProductCode; _PruductInfo.Package_Quantity = _Pack_Quantity; _PruductInfo.Quantity = _Quantity; _PruductInfo.Made_In = _MadeIn; _PruductInfo.Value = _Value; lst_product_Dec.Add(_PruductInfo); } #endregion } } } if (_rel > 0) { ViewBag.ListProduct = lst_product_Dec; return(PartialView("/Areas/ModuleDeclaration/Views/YShare/PartialListProduct.cshtml")); } else { return(null); } } catch (Exception ex) { System.IO.File.Delete(filePath); NaviCommon.Common.log.Error(ex.ToString()); return(PartialView("/Areas/ModuleDeclaration/Views/YShare/PartialListProduct.cshtml")); } }