Esempio n. 1
0
        private bool Search()
        {
            List <Stock> lst   = new bllStock().GetAll();
            List <Stock> found = new List <Stock>();
            int          amount;

            if (!txtAmount.Text.Any())
            {
                amount = 0;
            }
            else
            {
                amount = int.Parse(txtAmount.Text);
            }
            string pcode = ddlstPCode.SelectedItem.Text;
            bool   flag  = false;

            foreach (Stock element in lst)
            {
                if (element.ProductCode.Equals(pcode) && element.Amount > 0)
                {
                    found.Add(element);
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }

            fillGrid(found);
            return(flag);
        }
Esempio n. 2
0
        protected void btnSevk_Click(object sender, EventArgs e)
        {
            UserTable user = (UserTable)Session["User"];

            txtSevk.Text = "0";
            List <Stock> lstStock = new List <Stock>();
            bllStock     stock    = new bllStock();
            bool         Sevkflag = false; //sevk başarılı mı kontrolü için

            if (user != null)
            {
                foreach (ListViewItem item in lstDispatchsView.Items)
                {
                    if ((item.FindControl("chckAmount") as CheckBox).Checked == true)
                    {
                        int ID          = (int.Parse((item.FindControl("lblID") as Label).Text.Trim()));
                        int StockAmount = int.Parse((item.FindControl("chckAmount") as CheckBox).Text.Trim());
                        lstStock.Add(new Stock()
                        {
                            Id     = ID,
                            Amount = StockAmount
                        });

                        int a = item.DisplayIndex;
                    }
                }
                int newAmount = int.Parse(txtAmount.Text), controlAmount = 0;
                if (lstStock.Count > 0)
                {
                    for (int i = 0; i < lstStock.Count; i++)
                    {
                        controlAmount += lstStock[i].Amount;
                        if (newAmount > lstStock[i].Amount)
                        {
                            newAmount -= lstStock[i].Amount;
                        }

                        if (newAmount > lstStock[i].Amount)
                        {
                            Sevkflag = stock.Order(lstStock[i].Id, controlAmount);

                            if (Sevkflag)
                            {
                                new bllMovements().Insert(lstStock[i].Id, DateTime.Now, constMoveType, (-controlAmount), user.Id);
                            }
                        }
                        else
                        {
                            Sevkflag = stock.Order(lstStock[i].Id, newAmount);
                            if (Sevkflag)
                            {
                                new bllMovements().Insert(lstStock[i].Id, DateTime.Now, constMoveType, (-newAmount), user.Id);
                            }
                        }
                    }
                }

                fillGrid();
            }
        }
Esempio n. 3
0
        private void fillGrid()
        {
            List <Stock> lstDispatching = new bllStock().GetAll();

            lstDispatching.Sort((a, b) => a.ExpirationDate.Date.CompareTo(b.ExpirationDate.Date));
            lstDispatchsView.DataSource = lstDispatching;
            lstDispatchsView.DataBind();
        }
Esempio n. 4
0
        /*
         * Stock tablosu icinde aranan ürünü bulur.
         * **/
        private int SearchStock(Stock stock)
        {
            List <Stock> lst = new bllStock().GetAll();

            foreach (Stock element in lst)
            {
                if (element.ProductCode.Equals(stock.ProductCode) &&
                    element.StockStatuType.Equals(stock.StockStatuType) && element.ExpirationDate.Date.Equals(stock.ExpirationDate.Date) &&
                    element.Location.Equals(stock.Location))
                {
                    return(element.Id);
                }
            }
            return(-1);
        }
Esempio n. 5
0
        protected void lstProducts_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "cmdSil")
                {
                    bool flag = new bllStock().SearchInStock(int.Parse(e.CommandArgument.ToString()));
                    if (!flag)
                    {
                        new bllProducts().Delete(int.Parse(e.CommandArgument.ToString()));
                    }
                    else
                    {
                        throw new StockException();
                    }
                }
                else if (e.CommandName == "Update")
                {
                    Products newProduct = new Products();
                    newProduct.Id           = int.Parse(e.CommandArgument.ToString());
                    newProduct.ProductCode  = (e.Item.FindControl("lblpcode") as Label).Text;
                    newProduct.ProductName  = (e.Item.FindControl("txtPName") as TextBox).Text;
                    newProduct.UnitType     = (e.Item.FindControl("lblUnitType") as Label).Text;
                    newProduct.Title        = (e.Item.FindControl("lblTitle") as Label).Text;
                    newProduct.SerialNum    = int.Parse((e.Item.FindControl("lblSerialNum") as Label).Text);
                    newProduct.StatusType   = (e.Item.FindControl("lblStatus") as Label).Text;
                    newProduct.CategoryType = (e.Item.FindControl("lblCategory") as Label).Text;
                    newProduct.Comment      = (e.Item.FindControl("txtComment") as TextBox).Text;
                    if (new bllProducts().Update(newProduct))
                    {
                        lstProductsView.EditIndex = -1;
                        // lstProductsView.DataBind();
                    }
                }

                /* else if (e.CommandName == "Cancel")
                 * {
                 *   lstProductsView.EditIndex = -1;
                 *
                 * }*/
                fillGrid();
            }
            catch (StockException)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Stokta bulunan ürünü silemezsiniz\");", true);
            }
        }
Esempio n. 6
0
        /*
         * Girilen değerlere ait bir stock Listede var mı kontrol edilecek
         *
         * **/
        private bool FillGridByPCode(string pCode)
        {
            List <Stock> lst   = new bllStock().GetAll();
            List <Stock> found = new List <Stock>();
            //string pcode = ddlstProduct.SelectedItem.Text.ToString();
            bool flag = false;

            foreach (Stock element in lst)
            {
                if (element.ProductCode.Equals(pCode) && element.Amount > 0)
                {
                    found.Add(element);
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            fillGrid(found);
            return(flag);
        }
Esempio n. 7
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            bllStock stockTable = new bllStock();
            Stock    _stock     = new Stock();

            bool flag = false;  //Mal alımı başarılı mı kontrolü için

            Calendar1.Visible = false;
            try
            {
                int      pID = (FindProductID(ddlstProduct.SelectedItem.Text));
                int      amount = int.Parse(txtAmount.Text);
                DateTime dt1, dt2;

                int    locId    = stockTable.GetLocationID(ddlstLocStore.SelectedValue, ddlstLocHall.SelectedValue, ddlstColon.SelectedItem.Text, ddlstShelf.SelectedItem.Text);
                string LocStr   = ddlstLocStore.SelectedItem.Text + " " + ddlstLocHall.SelectedItem.Text + "-" + ddlstColon.SelectedItem.Text + "-" + ddlstShelf.SelectedItem.Text;
                int    statusId = int.Parse(ddlstStatus.SelectedValue);
                dt1 = DateTime.Now;
                dt2 = Calendar1.SelectedDate.Date.Add(DateTime.Now.TimeOfDay);
                if (dt2.CompareTo(dt1) < 0)
                {
                    throw new DateException();
                }
                _stock.Location         = LocStr;
                _stock.ProductCode      = ddlstProduct.SelectedItem.Text;
                _stock.ExpirationDate   = dt2;
                _stock.RegistrationDate = dt1;
                _stock.StockStatuType   = ddlstStatus.SelectedItem.Text;

                int StockID = SearchStock(_stock);
                if (StockID != -1)
                {
                    flag = stockTable.Purchase(StockID, amount);
                }
                else
                {
                    if ((stockTable.LocationControl(locId, pID)))
                    {
                        flag = stockTable.Insert(pID, amount, dt1, dt2, locId, statusId);
                    }
                    else
                    {
                        throw new LocationException();
                    }
                    StockID = SearchStock(_stock);
                }
                if (flag)
                {
                    UserTable user = (UserTable)Session["User"];

                    new bllMovements().Insert(StockID, DateTime.Now, constMoveType, amount, user.Id);
                }
                FillGridByPCode(_stock.ProductCode);
            }
            catch (FormatException)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Yanlış bilgi girdiniz.Tekrar deneyiniz\");", true);
            }
            catch (DateException)
            {
                txtExpDate.Text = "";
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"son kullanma tarihi kayıt tarihinden önce olamaz.Lütfen tekrar deneyiniz.\");", true);
            }
            catch (LocationException)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Seçtiğiniz lokasyon dolu.Lütfen tekrar deneyiniz\");", true);
            }
        }