Exemplo n.º 1
0
        // GET: StockIns/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockIn stockIn = db.StockIn.Find(id);

            if (stockIn == null)
            {
                return(HttpNotFound());
            }
            var    da        = db.StockIn.Where(w => w.StockInID == id).Select(s => s.SignStatus).ToList();
            string datastust = stut(da[0]);
            var    dat       = db.StockIn.Where(w => w.StockInID == id).Select(s => s.CreateDate).ToList();
            var    date      = dat[0].ToShortDateString();

            var datas = db.StockIn.AsEnumerable().Where(w => w.StockInID == id).
                        Select(s => new
            {
                s.StockInID,
                s.PurchaseOrderReceiveID,
                s.Remark,
                s.AddStockDate,
                s.CreateEmployeeID,
                date,
                datastust
            });

            return(Json(datas, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult StockInItem(StockIn stockIn)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    stockIn.Month      = stockIn.Date.Substring(0, 2);
                    stockIn.Year       = stockIn.Date.Substring(6, 4);
                    stockIn.ActionDate = DateTime.Now.ToString();
                    stockIn.ActionType = ActionType.Insert;
                    stockIn.ActionBy   = ActionType.User;

                    ViewBag.Response = stockInManager.AddStockIn(stockIn);
                }
                else
                {
                    ViewBag.Response = 3;
                }

                ViewBag.Companies = companyManager.GetCompaniesForDropDown();

                ModelState.Clear();
                return(View());
            }
            else
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 3
0
        protected void itemDropdownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            reorderLevelTextBox.Enabled = false;
            quantityTextBox.Enabled     = false;
            int id = Convert.ToInt32(itemDropdownList.SelectedValue);

            if (id == 0)
            {
                reorderLevelTextBox.Text = 0.ToString();
            }
            else
            {
                Item item = stockInManager.GetReorderLevelByItemId(id);
                reorderLevelTextBox.Text = item.ReorderLevel.ToString();
            }
            StockIn stockIn  = stockInManager.GetAvailableQuantityByItemId(id);
            int     quantity = stockIn.AvailableQuantity;

            if (quantity == 0)
            {
                quantityTextBox.Text = 0.ToString();
            }
            else
            {
                quantityTextBox.Text = quantity.ToString();
            }
        }
Exemplo n.º 4
0
        protected void itemDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int  itemId = Convert.ToInt32(itemDropDownList.SelectedValue);
            Item item   = stockInManager.GetReorderLevel(itemId);

            reorderLevelTextBox.Text = item.ReorderLavel.ToString();

            StockIn stockIn = new StockIn();

            stockIn.ItemID = itemId;


            StockIn stock = stockInManager.IsExist(stockIn);

            if (stock == null)
            {
                stockInTextBox.Text = " ";
                messageLabel.Text   = "Insert Stock In";
            }
            else
            {
                StockIn aStockIn = stockInManager.GetAvailableQuantity(stockIn);
                stockInTextBox.Text = aStockIn.AvailableQuantity;
                messageLabel.Text   = "Output";
            }
        }
Exemplo n.º 5
0
        public ActionResult SaveStockIn(string InvoiceNo, string Notes, List <StockInRequest> stockIns)
        {
            StockIn result      = new StockIn();
            StockIn FinalResult = new StockIn();

            //if (ModelState.IsValid)
            {
                foreach (var item in stockIns)
                {
                    result.InvoiceNo      = InvoiceNo;
                    result.Notes          = Notes;
                    result.IsActive       = true;
                    result.CreatedDate    = DateTime.Now;
                    result.ProductionDate = DateTime.Now;
                    result.CreatedBy      = CurrentSession.GetCurrentSession().UserName;
                    result.SupplierId     = 0;
                    result.ProductId      = item.ProductId;
                    result.BaleWeight     = 0;
                    result.WarehouseId    = item.WarehouseId;
                    result.SupplierId     = 1;
                    result.BaleQty        = item.Qty;
                    result.WeightInMon    = item.Qty;
                    FinalResult           = serviceStockIn.Save(result, Notes);
                }
            }

            return(Json(FinalResult, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public string SaveManager(StockIn stockIn)
        {
            if (stockIn.StockQuantity == 0)
            {
                return("Stock Quantity should be filled");
            }
            else if (stockInGateway.IsStockExist(stockIn))
            {
                int stockQuantityAvailable = stockInGateway.StockQuantityAvailable(stockIn);

                stockIn.StockQuantity = stockIn.StockQuantity + stockQuantityAvailable;
                int row = stockInGateway.Update(stockIn);
                if (row > 0)
                {
                    return("Save Successful !");
                }
                else
                {
                    return("Saving Failed !");
                }
            }
            else
            {
                int row = stockInGateway.SaveGateway(stockIn);
                if (row > 0)
                {
                    return("Save Successful !");
                }
                else
                {
                    return("Saving Failed !");
                }
            }
        }
Exemplo n.º 7
0
        public async Task <ActionResult <StockIn> > PostStockIn(StockIn stockIn)
        {
            _context.StockIns.Add(stockIn);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStockIn", new { id = stockIn.StockInNo }, stockIn));
        }
Exemplo n.º 8
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsNameEmpty())
            {
                return;
            }

            int      stockInId   = EditStockInId;
            string   name        = txtBatch.Text.Trim();
            int      count       = Convert.ToInt32(txtCount.Text.Trim());
            int      productId   = Convert.ToInt32(txtProductId.Text.Trim());
            decimal  subtotal    = Convert.ToDecimal(txtSubtotal.Text.Trim());
            int      userId      = UserLogined.UserId;
            DateTime inStockTime = dtpInStockTime.Value;

            StockIn stockIn = new StockIn()
            {
                StockInId   = stockInId,
                Batch       = name,
                Count       = count,
                ProductId   = productId,
                Subtotal    = subtotal,
                UserId      = userId,
                InStockTime = inStockTime,
            };

            StockInService.UpdateInventoryByInventory(stockIn);
            BindData();
            ResetUIInputtdData();
        }
        public ActionResult StockIn(StockInViewModel stockInViewModel)
        {
            if (ModelState.IsValid)
            {
                StockIn stockIn = Mapper.Map <StockIn>(stockInViewModel);
                db.StockIns.Add(stockIn);

                if (db.SaveChanges() > 0)
                {
                    ModelState.Clear();
                    TempData["msg"] = "StockIn information has been successfully saved.";
                    return(RedirectToAction("Index", "StockInDetails", new { area = "" }));
                }
            }

            var model = new StockInViewModel();

            model.Categories        = db.Categories.ToList();
            model.Parties           = _partyManager.PartyList();
            ViewBag.ProductDropDown = new SelectList(new[] { new SelectListItem()
                                                             {
                                                                 Value = "", Text = "Select Product"
                                                             } }, "Value", "Text");
            TempData["msg"] = "StockIn information has been failed to save!";
            return(View(model));
        }
 public IHttpActionResult AddStock(StockIn data)
 {
     //return new string[] { "value1", "value2" };
     // return new Vishnu { name = "rams", password = "******" };
     Console.WriteLine(data);
     return(Ok(data));
 }
        public string StockSaveUpdate(StockIn stockIn)
        {
            if (stockInGateway.StockUpdate(stockIn) > 0)
            {
                int available = stockIn.AvailableQuantity;
                stockIn.StockInQuantity += available;
                int rowAffect = stockInGateway.StockUpdate(stockIn);

                if (rowAffect > 0)
                {
                    return("Stock Update");
                }
                else
                {
                    return("Update Failed");
                }
            }

            else
            {
                int rowAffect = stockInGateway.StockSave(stockIn);
                if (rowAffect > 0)
                {
                    return("Stock Saved");
                }
                else
                {
                    return("Save Failed");
                }
            }
        }
Exemplo n.º 12
0
        public void DeleteInventoryById(int inventoryId)
        {
            StockIn inventory = GetInventoryById(inventoryId);

            Context.StockIns.Remove(inventory);
            Context.SaveChanges();
        }
Exemplo n.º 13
0
        public int SaveStockIn(StockIn stockIn)
        {
            string query = "INSERT INTO StockIn (BranchId, PartyId, EmployeeId, Date, Quantity, ItemId, PurchaseTransactionId) " +
                           "VALUES(@branchId, @partyId, @employeeId, @puchaseDateTime, @quantity, @itemId, @purchaseTransactionId)";

            var     purchaseTransactionId = GetPurchaseTransactionId(stockIn.PurchaseTransaction.Total, stockIn.PurchaseTransaction.Paid, stockIn.PurchaseTransaction.Return);
            Gateway gateway     = new Gateway(query);
            int     rowAffected = -1;

            foreach (Item anItem in stockIn.Items)
            {
                gateway.SqlCommand.Parameters.Clear();
                gateway.SqlCommand.Parameters.AddWithValue("@branchId", stockIn.BranchId);
                gateway.SqlCommand.Parameters.AddWithValue("@partyId", stockIn.PartyId);
                gateway.SqlCommand.Parameters.AddWithValue("@employeeId", stockIn.EmployeeId);
                gateway.SqlCommand.Parameters.AddWithValue("@puchaseDateTime", stockIn.PurchaseDateTime);
                gateway.SqlCommand.Parameters.AddWithValue("@quantity", anItem.Quantity);
                gateway.SqlCommand.Parameters.AddWithValue("@itemId", anItem.ItemId);
                gateway.SqlCommand.Parameters.AddWithValue("@purchaseTransactionId", purchaseTransactionId);

                rowAffected = gateway.SqlCommand.ExecuteNonQuery();
                if (rowAffected <= 0)
                {
                    gateway.Connection.Close();
                    return(rowAffected);
                }
            }

            gateway.Connection.Close();
            return(rowAffected);
        }
Exemplo n.º 14
0
        public StockIn Save(StockIn stockIn, string Notes)
        {
            var existingItem = inventory.GetAll(a => a.ProductId == stockIn.ProductId && a.IsActive == true && a.WarehouseId == stockIn.WarehouseId).ToList();

            if (existingItem.Count > 0)
            {
                foreach (var inv in existingItem)
                {
                    inv.UpdatedDate = DateTime.Now;
                    inv.UpdatedBy   = CurrentSession.GetCurrentSession().UserName;
                    inv.ReceiveQty  = stockIn.BaleQty;
                    inv.GoodsType   = "2";
                    inventory.Update(inv, inv.Id);
                }
            }
            else
            {
                Inventory result      = new Inventory();
                Inventory FinalResult = new Inventory();

                result.ProductId   = (int)stockIn.ProductId;
                result.QtyInBale   = (int?)stockIn.BaleWeight;
                result.SupplierId  = 1;
                result.WarehouseId = (int)stockIn.WarehouseId;
                result.ReceiveQty  = stockIn.BaleQty;
                result.Notes       = Notes;
                result.GoodsType   = "2";
                result.CreatedBy   = CurrentSession.GetCurrentSession().UserName;
                result.CreatedDate = DateTime.Now;
                result.IsActive    = true;

                FinalResult = inventory.Save(result);
            }
            return(service.Save(stockIn));
        }
 public ItemSummaryUi()
 {
     InitializeComponent();
     itemSummary = new ItemSummary();
     stockIn     = new StockIn();
     stockOut    = new StockOut();
 }
Exemplo n.º 16
0
        public string StockOut(string type)
        {
            DateTime date     = DateTime.Today;
            StockOut stockOut = new StockOut();
            StockIn  stockIn  = new StockIn();

            for (int i = 0; i < stockOutGridView.Rows.Count; i++)
            {
                HiddenField hiddenField   = stockOutGridView.Rows[i].FindControl("HiddenField1") as HiddenField;
                Label       quantityLabel = stockOutGridView.Rows[i].FindControl("ItemQuantity") as Label;
                stockOut.ItemId           = Convert.ToInt32(hiddenField.Value);
                stockOut.StockOutQuantity = Convert.ToInt32(quantityLabel.Text);
                stockOut.Date             = date;
                stockOut.Type             = type;
                stockOutManager.SaveStockOut(stockOut);

                stockIn.ItemId = Convert.ToInt32(hiddenField.Value);
                int realQuantity = stockInManager.GetAvailableQuantity(stockIn.ItemId);
                if (realQuantity >= Convert.ToInt32(quantityLabel.Text))
                {
                    stockIn.AvailableQuantity = realQuantity - Convert.ToInt32(quantityLabel.Text);
                }
                else
                {
                    errorMessegeLabel.Text = "Insufficient stock";
                }
                stockInManager.SaveStockIn(stockIn);
            }
            return(type);
        }
Exemplo n.º 17
0
        public string StockSaveUpdate(StockIn stock)
        {
            if (stockInGateway.IsItemExists(stock.ItemId))
            {
                int available = stock.AvailableQuantity;
                stock.StockInQuantity += available;
                int rowAffect = stockInGateway.StockUpdate(stock);

                if (rowAffect > 0)
                {
                    return("Stock Update");
                }
                else
                {
                    return("! Faild");
                }
            }

            else
            {
                int rowAffect = stockInGateway.StockSave(stock);
                if (rowAffect > 0)
                {
                    return("Stock Save");
                }
                else
                {
                    return("! Fail");
                }
            }
        }
        public ActionResult StockIn(StockCreateVM model)
        {
            //var stck = new StockIn()
            //{
            //    StocInDate = model.StocInDate,
            //    Description = model.Description,
            //    StockInDetails = model.StockInDetails
            //};


            StockIn stockIn = Mapper.Map <StockIn>(model);

            db.StockIns.Add(stockIn);
            int isSaved = db.SaveChanges();

            if (isSaved > 0)
            {
                TempData["msg"] = "Successful";
            }

            model.Categories        = db.Categories.ToList();
            model.Parties           = _partyManager.GetAll().ToList();
            ViewBag.ProductDropDown = new SelectListItem[] { new SelectListItem()
                                                             {
                                                                 Value = "", Text = "Select...."
                                                             } };
            return(View(model));
        }
Exemplo n.º 19
0
        public List <StockIn> GetAllitem(int companyId)
        {
            SetConnection();
            string     query   = "SELECT * FROM Item WHERE CompanyID=" + companyId;
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();

            List <StockIn> StockInlist = new List <StockIn>();
            SqlDataReader  reader      = command.ExecuteReader();

            while (reader.Read())
            {
                int     itemID   = (int)reader["ItemID"];
                string  itemName = reader["ItemName"].ToString();
                StockIn astock   = new StockIn();
                astock.ItemId   = itemID;
                astock.ItemName = itemName;
                StockInlist.Add(astock);
            }
            reader.Close();
            connection.Close();

            return(StockInlist);
        }
Exemplo n.º 20
0
        public int SaveStockin(StockIn stockIn)
        {
            string query = @"INSERT INTO [dbo].[tb_StockIn]
           ([CategoryId]
           ,[ItemId]
           ,[Quentity]
           ,[EntryDate]
           ,[EmployeeId])
     VALUES
           ('" + stockIn.CategoryId + "','" + stockIn.ItemId + "','" + stockIn.TotalQuantity + "','" +
                           stockIn.EntryDate + "','" + stockIn.EmployeeId + "')";

            try
            {
                SqlCommand command = new SqlCommand(query, _connection);
                _connection.Open();
                int rowAffected = command.ExecuteNonQuery();
                _connection.Close();

                return(rowAffected);
            }
            catch (Exception exception)
            {
                throw new Exception("Unable to connect Server", exception);
            }
            finally
            {
                _connection.Close();
            }
        }
Exemplo n.º 21
0
        public async Task <IActionResult> PutStockIn(int id, StockIn stockIn)
        {
            if (id != stockIn.StockInNo)
            {
                return(BadRequest());
            }

            _context.Entry(stockIn).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StockInExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 22
0
 public bool IsItemNameExists(StockIn stockIn)
 {
     try
     {
         string     Query   = "SELECT * FROM tb_StockIn WHERE (CategoryId = @CategoryId and ItemId = @ItemId)";
         SqlCommand Command = new SqlCommand(Query, _connection);
         _connection.Open();
         Command.Parameters.Clear();
         Command.Parameters.Add("CategoryId", SqlDbType.Int);
         Command.Parameters["CategoryId"].Value = stockIn.CategoryId;
         Command.Parameters.Add("ItemId", SqlDbType.Int);
         Command.Parameters["ItemId"].Value = stockIn.ItemId;
         SqlDataReader Reader = Command.ExecuteReader();
         Reader.Read();
         bool isExist = Reader.HasRows;
         Reader.Close();
         return(isExist);
     }
     catch (Exception exception)
     {
         throw new Exception("Unable to connect Server", exception);
     }
     finally
     {
         _connection.Close();
     }
 }
Exemplo n.º 23
0
        private void Init()
        {
            tempSIO                = new StockIn();
            tempSIO.U8Details      = new List <StockInDetail>();
            tempSIO.OperateDetails = new List <StockInDetail>();
            tempSIO.OperaPositions = new List <InvPositionInfo>();

            cbxBatch.DataSource = null;
            cbxBatch.Items.Clear();
            cbxBatch.Refresh();
            cbxBatch.Enabled = false;

            InputPannel.Enabled = false;
            txtOrder.Enabled    = true;
            rbtOther.Enabled    = true;
            rbtRecord.Enabled   = true;
            txtPosition.Enabled = false;
            txtLabel.Enabled    = false;
            btnSource.Enabled   = false;
            btnDone.Enabled     = false;
            btnSubmit.Enabled   = false;

            txtOrder.Text    = "";
            txtPosition.Text = "";
            lblStore.Text    = "";

            SetFocus();
        }
        public int AddStockIn(StockIn stockIn)
        {
            Context.StockIns.Add(stockIn);
            int rowsAffected = Context.SaveChanges();

            return(rowsAffected);
        }
Exemplo n.º 25
0
        public string SaveStockIn(StockIn stockIn)
        {
            bool isItemExist = stockInGateway.IsItemExist(stockIn.ItemId);

            if (isItemExist)
            {
                int rowAffect = stockInGateway.UpdateAvailableQuantityByItem(stockIn);
                if (rowAffect > 0)
                {
                    return("Stocked in successfully");
                }
                else
                {
                    return("Stocked in failed");
                }
            }
            else
            {
                int rowAffect = stockInGateway.SaveStockIn(stockIn);
                if (rowAffect > 0)
                {
                    return("Stocked in successfully");
                }
                else
                {
                    return("Stocked in failed");
                }
            }
        }
Exemplo n.º 26
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            StockIn stockIn = new StockIn();

            if (availableQuantityTextBox.Text == "")
            {
                stockIn.ItemId   = Convert.ToInt32(itemDropDownList.SelectedValue);
                stockIn.Quantity = Convert.ToInt32(stockInQuantityTextBox.Text);
                string message = stockInManager.Save(stockIn);
                stockInQuantityTextBox.Text    = "";
                reorderLevelTextBox.Text       = "";
                itemDropDownList.SelectedValue = "0";
                messageLabel.Text = message;
            }
            else
            {
                stockIn.ItemId = Convert.ToInt32(itemDropDownList.SelectedValue);
                int quantity = Convert.ToInt32(availableQuantityTextBox.Text);
                stockIn.Quantity = quantity + Convert.ToInt32(stockInQuantityTextBox.Text);
                string message = stockInManager.UpdateStockInById(stockIn);
                stockInQuantityTextBox.Text    = "";
                availableQuantityTextBox.Text  = "";
                reorderLevelTextBox.Text       = "";
                itemDropDownList.SelectedValue = "0";
                messageLabel.Text = message;
            }
        }
        public string StockInQuantity(StockIn stockInObj)
        {
            StockInRepository stockInRepoObj = new StockInRepository();
            string            stockInInfo    = stockInRepoObj.StockInQuantity(stockInObj);

            return(stockInInfo);
        }
Exemplo n.º 28
0
        private void Init()
        {
            tempSIO                = new StockIn();
            tempSIO.U8Details      = new List <StockInDetail>();
            tempSIO.OperateDetails = new List <StockInDetail>();
            tempSIO.OperaPositions = new List <InvPositionInfo>();

            MODetails = new List <Om_MoHeadInfo>();
            tempSDL   = new List <StockInDetail>();

            cbxMoDetails.DataSource = null;
            cbxMoDetails.Items.Clear();
            cbxMoDetails.Enabled = false;

            InputPannel.Enabled = false;
            txtOrder.Enabled    = true;
            txtPosition.Enabled = false;
            txtLabel.Enabled    = false;
            btnSource.Enabled   = false;
            btnDone.Enabled     = false;
            btnSubmit.Enabled   = false;

            txtOrder.Text    = "";
            txtPosition.Text = "";

            SetFocus();
        }
Exemplo n.º 29
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            if (stockInQuantityTextBox.Text == "")
            {
                errorMessegeLabel.Text = "*Stock In quantity required";
            }
            else if (Convert.ToInt32(stockInQuantityTextBox.Text) < 0)
            {
                errorMessegeLabel.Text = "*Stock In quantity can not be negetive";
            }
            else
            {
                StockIn stockIn = new StockIn();

                stockIn.ItemId = Convert.ToInt32(itemDropDownList.SelectedValue);
                int realQuantity = stockInManager.GetAvailableQuantity(stockIn.ItemId);

                stockIn.AvailableQuantity = Convert.ToInt32(stockInQuantityTextBox.Text) + realQuantity;

                string message = stockInManager.SaveStockIn(stockIn);

                messegeLabel.Text = message;


                //int temp = Convert.ToInt32(availableQuantityTextBox.Text);
                int stockInQuantity = Convert.ToInt32(stockInQuantityTextBox.Text);
                int TotalQuantity   = stockInQuantity + realQuantity;
                availableQuantityTextBox.Text = TotalQuantity.ToString();
                stockInQuantityTextBox.Text   = String.Empty;
            }
        }
Exemplo n.º 30
0
        public ActionResult Edit(StockIn stockIn)
        {
            string message = "修改成功!!";
            bool   status  = true;

            switch (stockIn.SignStatus)
            {
            case "同意":
                stockIn.SignStatus = "Y";
                break;

            case "拒絕":
                stockIn.SignStatus = "N";
                break;

            case "簽核中":
                stockIn.SignStatus = "S";
                break;
            }

            if (ModelState.IsValid)
            {
                db.Entry(stockIn).State = EntityState.Modified;
                db.SaveChanges();
                return(Json(new { status = status, message = message, id = db.StockIn.Max(x => x.StockInOID) }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                message = "修改失敗!!";
                status  = false;
                return(Json(new { status = status, message = message }, JsonRequestBehavior.AllowGet));
            }
        }