Exemple #1
0
        /// <summary>
        /// 查询仓库信息
        /// </summary>
        /// <param name="WareHouseID"></param>
        /// <returns></returns>
        public static WareHouseModel GetWareHouseItem(int WareHouseID)
        {
            string cmd = "select WareHouseID,WareHouseName,WareHouseForShort,WareHousePrincipal,WareHouseAddress,WareHouseDescr,WareControl,CPCCode from WareHouse where WareHouseID=@WareHouseID";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@WareHouseID", WareHouseID)
            };

            SqlDataReader dr = DBHelper.ExecuteReader(cmd, param, CommandType.Text);

            dr.Read();

            WareHouseModel psm = new WareHouseModel();

            psm.WareHouseID        = Convert.ToInt32(dr["WareHouseID"]);
            psm.WareHouseName      = dr["WareHouseName"].ToString();
            psm.WareHouseForShort  = dr["WareHouseForShort"].ToString();
            psm.WareHousePrincipal = dr["WareHousePrincipal"].ToString();
            psm.WareHouseAddress   = dr["WareHouseAddress"].ToString();
            psm.WareHouseDescr     = dr["WareHouseDescr"].ToString();
            psm.WareControl        = Convert.ToInt32(dr["WareControl"]);
            psm.CPCCode            = dr["CPCCode"].ToString();

            dr.Close();

            return(psm);
        }
Exemple #2
0
 public WareHouseController()
 {
     model                  = model ?? ModelManager.Instance.GetModel <WareHouseModel>();
     indexGridDict          = indexGridDict ?? new Dictionary <int, Grid>();
     itemIdGridIndexSetDict = itemIdGridIndexSetDict ?? new Dictionary <int, List <int> >();
     RefreshWareHouse();
 }
        public long SaveWareHouse(WareHouseModel _WareHouseModel)
        {
            long flg = 0;

            try
            {
                ArrayList al = new ArrayList();


                al.Add(_WareHouseModel.WareHouseID);
                al.Add(_WareHouseModel.Code);
                al.Add(_WareHouseModel.Name);
                al.Add(_WareHouseModel.Status);
                al.Add(_WareHouseModel.efDate);

                _General.Set(al, "sp_InsertUpdateWareHouse", out flg);
                // flg = DAL.ExecuteSP("sp_InsertUpdateWareHouse", Params, al);
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Class > WareHouse, Method >SaveWareHouse()", ex);
            }

            return(flg);
        }
        public WareHouseModel EditWareHouse(int ID)
        {
            WareHouseModel _WareHouseModel = new WareHouseModel();

            try
            {
                DataTable dt = GetGridData(ID);

                if (dt != null && dt.Rows.Count > 0)
                {
                    _WareHouseModel.WareHouseID = Convert.ToInt32(dt.Rows[0]["ID"].ToString());
                    _WareHouseModel.Code        = dt.Rows[0]["Code"].ToString();
                    _WareHouseModel.Name        = dt.Rows[0]["Name"].ToString();
                    _WareHouseModel.Status      = Convert.ToInt32(dt.Rows[0]["Status"].ToString());
                    if (dt.Rows[0]["eDate"] == DBNull.Value)
                    {
                        _WareHouseModel.efDate = ConverDate(DateTime.Now);
                    }
                    else
                    {
                        _WareHouseModel.efDate = ConverDate(Convert.ToDateTime(dt.Rows[0]["eDate"]));
                    }
                }
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Class > WareHouse, Method > EditWareHouse(int ID)", ex);
            }
            return(_WareHouseModel);
        }
        public ActionResult Warehouse()
        {
            PLog.Info("BEGIN::Controller > Home, Method >Warehouse() ");
            WareHouseModel objModel = new WareHouseModel();

            PLog.Info("END::Controller > Home, Method > Warehouse()");
            return(View(objModel));
        }
Exemple #6
0
        /// <summary>
        /// 通过仓库ID和仓库名称获取仓库名称的行数
        /// </summary>
        /// <param name="depotSeatModel">仓库模型</param>
        /// <returns>返回通过仓库ID和仓库名称获取仓库名称的行数</returns>
        public static int GetWareHouseNameCountByWareHouseIDName(WareHouseModel wareHouseModel)
        {
            SqlParameter[] sparams = new SqlParameter[]
            {
                new SqlParameter("@wareHouseID", SqlDbType.Int),
                new SqlParameter("@wareHouseName", SqlDbType.VarChar, 50)
            };
            sparams[0].Value = wareHouseModel.WareHouseID;
            sparams[1].Value = wareHouseModel.WareHouseName;

            return(Convert.ToInt32(DBHelper.ExecuteScalar("GetWareHouseNameCountByWareHouseIDName", sparams, CommandType.StoredProcedure)));
        }
Exemple #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtWareHouseName.Text) || string.IsNullOrWhiteSpace(cmbType.Text))
            {
                ClsCommon.ShowErrorToolTip(txtWareHouseName, "Please Enter The WareHouse Name");
            }
            else
            {
                var model = new WareHouseModel
                {
                    WareHouseId   = _wareHouseId,
                    WareHouseName = txtWareHouseName.Text,
                    WareHouseType = cmbType.Text,
                    Description   = txtRemarks.Text
                };

                if (_isNewMode)
                {
                    _wareHouseId = _wareHouseService.Save(model);
                    if (_wareHouseId <= 0)
                    {
                        return;
                    }
                    MessageBox.Show(@"Data Saved Successfully", @"Save", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    var frm = (FrmWareHouse)_frmForm;
                    frm.grdData.Rows.Add(_wareHouseId, model.WareHouseName, model.WareHouseType, model.Description);
                    frm.grdData.Rows[frm.grdData.Rows.Count - 1].IsSelected = true;
                    txtWareHouseName.Focus();
                    txtWareHouseName.Text = "";
                    txtRemarks.Text       = "";
                    Notify();
                }
                else
                {
                    var success = _wareHouseService.Update(model);
                    if (!success)
                    {
                        return;
                    }
                    MessageBox.Show(@"Data Updated Successfully", @"Update", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    var frm = (FrmWareHouse)_frmForm;
                    frm.grdData.CurrentRow.Cells["WareHouseName"].Value = model.WareHouseName;
                    frm.grdData.CurrentRow.Cells["WareHouseType"].Value = model.WareHouseType;

                    frm.grdData.CurrentRow.Cells["Description"].Value = model.Description;
                    Close();
                    Notify();
                }
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(lblID.Text) <= 0)
            {
                return;
            }
            var model = new WareHouseModel()
            {
                WareHouseId   = Convert.ToInt32(lblID.Text),
                WareHouseName = lblName.Text,
                WareHouseType = lblType.Text,
                Description   = lblRemarks.Text
            };

            var frm = new FrmWareHouseEntry(model, this);

            frm.ShowDialog(this);
        }
        public async Task <BaseResult> CreateOrUpdate(WareHouseModel model, int updateBy = 0, string updateByUserName = "")
        {
            var wareHouse = model.ToWareHouse();

            //Cập nhật thông tin chung của thực thể
            wareHouse = wareHouse.UpdateCommonInt(updateBy, updateByUserName);

            if (wareHouse.Id > 0)
            {
                //Cập nhật
                return(await Update(wareHouse));
            }
            else
            {
                //Thêm mới
                return(await Create(wareHouse));
            }
        }
Exemple #10
0
        /// <summary>
        /// 添加仓库信息
        /// </summary>
        /// <param name="psm">仓库模型</param>
        /// <returns>返回添加仓库模型所影响的行数</returns>
        public static int AddWareHouse(WareHouseModel psm)
        {
            string cmd = @"insert into WareHouse(CountryCode,WareHouseName,WareHouseForShort,WareHousePrincipal,WareHouseAddress,WareHouseDescr,WareControl,CPCCode) values 
                        (@CountryCode,@WareHouseName,@WareHouseForShort,@WareHousePrincipal,@WareHouseAddress,@WareHouseDescr,@WareControl,@CPCCode)";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@CountryCode", psm.CountryCode),
                new SqlParameter("@WareHouseName", psm.WareHouseName),
                new SqlParameter("@WareHouseForShort", psm.WareHouseForShort),
                new SqlParameter("@WareHousePrincipal", psm.WareHousePrincipal),
                new SqlParameter("@WareHouseAddress", psm.WareHouseAddress),
                new SqlParameter("@WareHouseDescr", psm.WareHouseDescr),
                new SqlParameter("@WareControl", psm.WareControl),
                new SqlParameter("@CPCCode", psm.CPCCode)
            };

            return(DBHelper.ExecuteNonQuery(cmd, param, CommandType.Text));
        }
Exemple #11
0
        /// <summary>
        /// 更新指定仓库信息
        /// </summary>
        /// <param name="psm">仓库模型</param>
        /// <returns>返回更新指定仓库信息所影响的行数</returns>
        public static int UpdWareHouseByWareHouseID(WareHouseModel psm)
        {
            string cmd = @"update WareHouse set CountryCode=@CountryCode,WareHouseName=@WareHouseName,WareHouseForShort=@WareHouseForShort,WareHousePrincipal=@WareHousePrincipal,
                        WareHouseAddress=@WareHouseAddress,WareHouseDescr=@WareHouseDescr,CPCCode=@CPCCode where WareHouseID=@WareHouseID";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@CountryCode", psm.CountryCode),
                new SqlParameter("@WareHouseName", psm.WareHouseName),
                new SqlParameter("@WareHouseForShort", psm.WareHouseForShort),
                new SqlParameter("@WareHousePrincipal", psm.WareHousePrincipal),
                new SqlParameter("@WareHouseAddress", psm.WareHouseAddress),
                new SqlParameter("@WareHouseDescr", psm.WareHouseDescr),
                new SqlParameter("@WareHouseID", psm.WareHouseID),
                new SqlParameter("@CPCCode", psm.CPCCode)
            };

            return(DBHelper.ExecuteNonQuery(cmd, param, CommandType.Text));
        }
        public ActionResult UpDateWarehouse(string ID)
        {
            PLog.Info("BEGIN::Controller > Home, Method >UpDateWarehouse(string ID) ");
            WareHouseModel  objModel   = null;
            IWareHouseImple oWareHouse = new WareHouseImple();

            try
            {
                if (!string.IsNullOrEmpty(ID))
                {
                    objModel = oWareHouse.EditWareHouse(Convert.ToInt32(ID));
                }
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Controller > Home, Method > UpDateWarehouse(string ID) ", ex);
            }
            PLog.Info("END::Controller > Home, Method > UpDateWarehouse(string ID) ");
            return(View("Warehouse", objModel));
        }
Exemple #13
0
 public FrmWareHouseEntry(WareHouseModel model, Form frmForm)
 {
     InitializeComponent();
     _frmForm          = frmForm;
     _wareHouseService = new WareHouseService();
     if (model != null)
     {
         _isNewMode            = false;
         _wareHouseId          = model.WareHouseId;
         txtWareHouseName.Text = model.WareHouseName;
         cmbType.Text          = model.WareHouseType;
         txtRemarks.Text       = model.Description;
         btnAdd.Text           = @"Update";
     }
     else
     {
         _isNewMode  = true;
         btnAdd.Text = @"Save";
     }
 }
Exemple #14
0
        /// <summary>
        /// 获取所有供应商
        /// </summary>
        /// <returns></returns>
        public static IList <WareHouseModel> GetWareHouses()
        {
            string                 sql = "select WareHouseID,WareControl,WareHouseName from WareHouse";
            SqlDataReader          dr  = DBHelper.ExecuteReader(sql, CommandType.Text);
            IList <WareHouseModel> ps  = null;

            if (dr.HasRows)
            {
                ps = new List <WareHouseModel>();
                while (dr.Read())
                {
                    WareHouseModel wm = new WareHouseModel();
                    wm.WareHouseID   = dr.GetInt32(0);
                    wm.WareControl   = dr.GetInt32(1);
                    wm.WareHouseName = dr.GetString(2);
                    ps.Add(wm);
                }
            }
            dr.Close();
            return(ps);
        }
        public ActionResult SaveWarehouse(string Data)
        {
            PLog.Info("BEGIN::Controller > Home, Method > SaveWarehouse(string Data) ");
            long flg = 0;

            try
            {
                WareHouseModel obj = JsonConvert.DeserializeObject <WareHouseModel>(Data);

                IWareHouseImple oWareHouse = new WareHouseImple();

                string[] date = obj.efDate.Split('-');

                obj.efDate = new DateTime(Convert.ToInt32(date[2]), Convert.ToInt32(date[1]), Convert.ToInt32(date[0])).ToString();
                flg        = oWareHouse.SaveWareHouse(obj);
            }
            catch (Exception ex)
            {
                PLog.Error("Error::Controller > Home, Method > SaveWarehouse(string Data)", ex);
            }
            PLog.Info("END::Controller > Home, Method > SaveWarehouse(string Data)");
            return(Content(flg.ToString()));
        }
Exemple #16
0
 public ActionResult Edit(WareHouseModel model)
 {
     if (ModelState.IsValid)
     {
         if (ModelState.IsValid)
         {
             if (model.Id > 0)
             {
                 model.ModifiedBy = currentUser.Id;
                 model.DateModify = DateTime.Now;
                 warehouseSevices.UpdateWareHouse(model);
             }
             else
             {
                 model.CreatedBy  = currentUser.Id;
                 model.DateCreate = DateTime.Now;
                 warehouseSevices.InsertWareHouse(model);
             }
         }
         return(Json(1));
     }
     return(PartialView("_formEditView", model));
 }
        private void fillForm()
        {
            foreach (var trans in transaction.FetchAll())
            {
                if (trans.TransactionNumber == SelectedTransactionNumber)
                {
                    //transaction type
                    foreach (var transType in transactionType.FetchAll())
                    {
                        if (transType.Code == trans.TransactionCode)
                        {
                            IndexTransactionType    = transType.Id;
                            SelectedTransactionType = transType;
                            break;
                        }
                    }
                    //document number
                    DocumentNumber = trans.DocumentNumber;

                    //transaction date
                    TransactionDate = trans.TransactionDate.ToString("MM/dd/yyyy");

                    //warehouse
                    foreach (var wh in warehouse.FetchAll())
                    {
                        if (wh.Code == trans.SourceWarehouseCode)
                        {
                            IndexSourceWarehouse = wh.Id;
                            //strSourceWarehouse[0] = wh.Code;
                            //strSourceWarehouse[1] = wh.Name;
                            //SelectedSourceWarehouse.Code = strSourceWarehouse[0];
                            //SelectedSourceWarehouse.Name = strSourceWarehouse[1];
                            selectedSourceWarehouse = wh;
                            break;
                        }
                    }


                    foreach (var wh2 in warehouse.FetchAll())
                    {
                        if (wh2.Code == trans.DestinationWarehouseCode)
                        {
                            IndexDestinationWarehouse    = wh2.Id;
                            SelectedDestinationWarehouse = wh2; //new WareHouseModel(wh2);
                        }
                        break;
                    }

                    //location
                    foreach (var loc in location.FetchAll())
                    {
                        if (loc.Code == trans.SourceLocationCode)
                        {
                            IndexSourceLocation    = loc.Id;
                            SelectedSourceLocation = loc; //new LocationModel(loc);
                        }
                        break;
                    }

                    foreach (var loc2 in location.FetchAll())
                    {
                        if (loc2.Code == trans.DestinationLocationCode)
                        {
                            IndexDestinationLocation    = loc2.Id;
                            SelectedDestinationLocation = loc2; //new LocationModel(loc2);
                        }
                        break;
                    }

                    //price category
                    switch (trans.PriceCategory)
                    {
                    case "Selling Price":
                        IndexPriceCategory = 1;
                        break;

                    case "Purchase Price":
                        IndexPriceCategory = 2;
                        break;
                    }

                    //price type
                    switch (trans.PriceType)
                    {
                    case "Current":
                        IndexPriceType = 1;
                        break;

                    case "3 Months Ago":
                        IndexPriceType = 2;
                        break;

                    case "6 Months Ago":
                        IndexPriceType = 3;
                        break;
                    }

                    //reason code
                    foreach (var reason in reason.FetchAll())
                    {
                        if (reason.ReasonCode == trans.ReasonCode)
                        {
                            IndexReason    = int.Parse(reason.ReasonCode.Substring(2));
                            SelectedReason = reason; //new ReasonsModel(reason);
                            break;
                        }
                    }

                    //comment
                    Comment = trans.Comment;
                }
            }
        }
 public static WareHouse ToWareHouse(this WareHouseModel model)
 {
     return(model.MapTo <WareHouseModel, WareHouse>());
 }
Exemple #19
0
 /// <summary>
 /// 更新指定仓库信息
 /// </summary>
 /// <param name="psm">仓库模型</param>
 /// <returns>返回更新指定仓库信息所影响的行数</returns>
 public static int UpdWareHouseByWareHouseID(WareHouseModel psm)
 {
     return(WareHouseDAL.UpdWareHouseByWareHouseID(psm));
 }
Exemple #20
0
 /// <summary>
 /// 添加仓库信息
 /// </summary>
 /// <param name="psm">仓库模型</param>
 /// <returns>返回添加仓库模型所影响的行数</returns>
 public static int AddWareHouse(WareHouseModel psm)
 {
     return(WareHouseDAL.AddWareHouse(psm));
 }
Exemple #21
0
 /// <summary>
 /// 通过仓库ID和仓库名称获取仓库名称的行数
 /// </summary>
 /// <param name="depotSeatModel">仓库模型</param>
 /// <returns>返回通过仓库ID和仓库名称获取仓库名称的行数</returns>
 public static int GetWareHouseNameCountByWareHouseIDName(WareHouseModel wareHouseModel)
 {
     return(WareHouseDAL.GetWareHouseNameCountByWareHouseIDName(wareHouseModel));
 }
Exemple #22
0
        private async Task <BaseResult> Update(Ward ward, int updateBy = 0, string updateByUserName = "")
        {
            var result = new BaseResult()
            {
                Result = Result.Success
            };
            var wardForUpdate = _wardRepository.Query().FirstOrDefault(c => c.Id == ward.Id);

            if (wardForUpdate == null || ward.Id <= 0)
            {
                result.Result  = Result.Failed;
                result.Message = "Không tìm thấy phường yêu cầu!";
                return(result);
            }
            else
            {
                var district = _districtRepository.Query()
                               .Include(d => d.City)
                               .Include(d => d.Wards)
                               .AsNoTracking()
                               .FirstOrDefault(d => d.Id == ward.ParentId);
                var exists = _wardRepository.Query()
                             .Include(w => w.District)
                             .ThenInclude(d => d.City)
                             .AsNoTracking()
                             .Any(w => !w.IsDeleted && w.District.Name == district.Name && w.Name == ward.Name && w.Id != wardForUpdate.Id);
                if (exists)
                {
                    result.Result  = Result.Failed;
                    result.Message = "Xã/Phường đã tồn tại!";
                    return(result);
                }
                ward.CityRealm  = district.CityRealm;
                ward.Name       = ward.Name.Trim();
                ward.UnsignName = !string.IsNullOrEmpty(ward.Name) ? ward.Name.Unsigned() : "";
            }
            try
            {
                wardForUpdate = ward.ToWard(wardForUpdate);

                //Cập nhật thông tin chung của thực thể
                wardForUpdate = wardForUpdate.UpdateCommonInt(updateBy, updateByUserName);

                await _wardRepository.UpdateAsync(wardForUpdate);

                var warehouses = _wareHouseRepository.Query()
                                 .Where(w => w.ParentId == wardForUpdate.Id)
                                 .Include(w => w.Ward)
                                 .ThenInclude(w => w.District)
                                 .ThenInclude(d => d.City)
                                 .ToList();
                foreach (WareHouse w in warehouses)
                {
                    WareHouseModel wareHouse = w.ToModel();
                    await _wareHouseService.CreateOrUpdate(wareHouse);
                }
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }
Exemple #23
0
        public async Task <IActionResult> CreateOrUpdate([FromBody] WareHouseModel wareHouse)
        {
            var result = await _wareHouseService.CreateOrUpdate(wareHouse);

            return(Ok(result));
        }