示例#1
0
        private void GetStockSnap()
        {
            Business.Inventory.Stock objStock = new Business.Inventory.Stock();
            string name = (string.IsNullOrEmpty(txtName.Text.Trim())) ? string.Empty : txtName.Text.Trim();

            gvStockSnap.DataSource = objStock.GetStockSnap(name);
            gvStockSnap.DataBind();
        }
        private List <Models.StockSnapModel> GetStockSnaps(int employeeId, string itemName)
        {
            List <Models.StockSnapModel> model = new List <StockSnapModel>();

            Business.Inventory.Stock objStock = new Business.Inventory.Stock();
            string name = (string.IsNullOrEmpty(itemName.Trim())) ? string.Empty : itemName.Trim();

            Business.HR.EmployeeMaster objEmployeeMaster = new Business.HR.EmployeeMaster();
            Entity.HR.EmployeeMaster   employeeMaster    = new Entity.HR.EmployeeMaster();
            DataTable dtEmployee = objEmployeeMaster.EmployeeMaster_ById(new Entity.HR.EmployeeMaster()
            {
                EmployeeMasterId = employeeId
            });

            if (dtEmployee.AsEnumerable().Any())
            {
                employeeMaster = objEmployeeMaster.AuthenticateUser(dtEmployee.Rows[0]["EmployeeCode"].ToString());
            }

            if (employeeMaster != null)
            {
                string[] roles = employeeMaster.Roles.Split(',');
                if (roles.Contains(Entity.HR.Utility.STOCK_LOOKUP))
                {
                    DataTable response = objStock.GetStockSnap(itemName);
                    if (response != null &&
                        response.AsEnumerable().Any())
                    {
                        foreach (DataRow dr in response.Rows)
                        {
                            model.Add(new Models.StockSnapModel
                            {
                                AssetLocationId = dr["AssetLocationId"].ToString(),
                                ItemId          = dr["ItemId"].ToString(),
                                ItemType        = dr["ItemType"].ToString(),
                                Location        = string.Format("Location: {0}", dr["Location"].ToString()),
                                Quantity        = string.Format("Quantity: {0}", dr["Quantity"].ToString()),
                                ItemName        = (Convert.ToInt32(dr["ItemType"].ToString()) == (int)ItemType.Product)
                                ? string.Format("Product Name: {0}", dr["ProductName"].ToString())
                                : string.Format("Spare Name: {0}", dr["SpareName"].ToString()),
                            });
                        }
                    }
                }
                else
                {
                }
            }

            return(model);
        }