Exemplo n.º 1
0
        private void TextBoxProductCountSell_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (TextBoxProductCountSell.Text != "")
                {
                    SellBO objSellBO = new SellBO();
                    objSellBO.ProductName  = ComboBoxProductNameSell.Text;
                    objSellBO.TypeName     = ComboBoxProductTypeSell.Text;
                    objSellBO.ProductCount = Convert.ToInt32(TextBoxProductCountSell.Text);

                    SellBL  objSellBL = new SellBL();
                    decimal Price     = objSellBL.CalculatePriceBL(objSellBO);
                    string  PriceStr  = Price.ToString("0.##");

                    TextBoxTotalPrice.Text = PriceStr;
                }
                else
                {
                    TextBoxTotalPrice.Text = "";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public bool SellProductBL(SellBO objSellBO)
        {
            SellDA objSellDA = new SellDA();
            int    ProductID = objSellDA.GetProductID(objSellBO.ProductName);

            TypeDA objTypeDA    = new TypeDA();
            int    OldTypeCount = objTypeDA.GetOldTypeCount(objSellBO.TypeName, ProductID);

            Constants.RemainingProduct = OldTypeCount;
            if (OldTypeCount < objSellBO.ProductCount)
            {
                return(false);
            }
            int NewTypeCount = OldTypeCount - objSellBO.ProductCount;

            objTypeDA.DecreaseFromStock(objSellBO.TypeName, ProductID, NewTypeCount);

            decimal Price = objSellDA.GetPriceOfProduct(objSellBO, ProductID);

            objSellBO.ProductPrice = Price * objSellBO.ProductCount;
            objSellDA.SellProductDA(objSellBO);

            decimal oldLoan = objSellDA.GetOldLoan(objSellBO);
            decimal newLoan = oldLoan + objSellBO.ProductPrice;

            objSellDA.AddLoanDA(objSellBO, newLoan);

            return(true);
        }
Exemplo n.º 3
0
        public decimal CalculatePriceBL(SellBO objSellBO)
        {
            SellDA  objSellDA = new SellDA();
            int     ProductID = objSellDA.GetProductID(objSellBO.ProductName);
            decimal Price     = objSellDA.GetPriceOfProduct(objSellBO, ProductID);

            objSellBO.ProductPrice = Price * objSellBO.ProductCount;
            return(objSellBO.ProductPrice);
        }
Exemplo n.º 4
0
        public void AddLoanDA(SellBO objSellBO, decimal newLoan)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Update dbo.Costumer Set CostumerTotal=@CostumerTotal Where CostumerName=@CostumerName", con);

            cmd.Parameters.Add(new SqlParameter("@CostumerName", objSellBO.CustomerName));
            cmd.Parameters.Add(new SqlParameter("@CostumerTotal", newLoan));
            cmd.ExecuteNonQuery();
        }
Exemplo n.º 5
0
        public void SellProductDA(SellBO objSellBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Insert Into dbo.Sell (CustomerName,ProductName,TypeName,ProductCount,ProductPrice,SellDate) Values (@CostumerName,@ProductName,@TypeName,@ProductCount,@ProductPrice,@SellDate)", con);

            cmd.Parameters.Add(new SqlParameter("@CostumerName", objSellBO.CustomerName));
            cmd.Parameters.Add(new SqlParameter("@ProductName", objSellBO.ProductName));
            cmd.Parameters.Add(new SqlParameter("@TypeName", objSellBO.TypeName));
            cmd.Parameters.Add(new SqlParameter("@ProductCount", objSellBO.ProductCount));
            cmd.Parameters.Add(new SqlParameter("@ProductPrice", objSellBO.ProductPrice));
            cmd.Parameters.Add(new SqlParameter("@SellDate", objSellBO.SellDate));
            cmd.ExecuteNonQuery();
        }
Exemplo n.º 6
0
        public bool PayLoanDA(SellBO objSellBO, decimal payment)
        {
            SellDA     objSellDA     = new SellDA();
            CostumerDA objCostumerDA = new CostumerDA();
            decimal    oldLoan       = objSellDA.GetOldLoan(objSellBO);
            decimal    newLoan       = 0;

            if (oldLoan < payment)
            {
                return(false);
            }
            else
            {
                newLoan = oldLoan - payment;
                objCostumerDA.PayLoanDA(objSellBO, newLoan);
                return(true);
            }
        }
Exemplo n.º 7
0
        public decimal GetOldLoan(SellBO objSellBO)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Select CostumerTotal From dbo.Costumer Where CostumerName=@CostumerName", con);

            cmd.Parameters.Add(new SqlParameter("@CostumerName", objSellBO.CustomerName));
            SqlDataReader dr      = cmd.ExecuteReader();
            decimal       oldLoan = 0;

            if (dr.Read())
            {
                oldLoan = dr.GetDecimal(0);
            }
            return(oldLoan);
        }
Exemplo n.º 8
0
        private void ButtonSell_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextBoxProductCountSell.Text != "")
                {
                    SellBO objSellBO = new SellBO();
                    objSellBO.CustomerName = ComboBoxCompanyNameSell.Text;
                    objSellBO.ProductName  = ComboBoxProductNameSell.Text;
                    objSellBO.TypeName     = ComboBoxProductTypeSell.Text;
                    objSellBO.ProductCount = Convert.ToInt32(TextBoxProductCountSell.Text);
                    string Date = DateTimePicker.Value.ToString("dd/MM/yyyy");
                    objSellBO.SellDate = Convert.ToDateTime(Date);

                    SellBL objSellBL = new SellBL();
                    bool   Sold      = objSellBL.SellProductBL(objSellBO);

                    if (Sold == true)
                    {
                        MessageBox.Show("Satış başarı ile gerçekleştirilmiştir");

                        TextBoxProductCountSell.Clear();
                        ComboBoxCompanyNameSell.SelectedIndex = 0;
                        ComboBoxProductNameSell.SelectedIndex = 0;
                        DateTimePicker.Value = DateTime.Today;

                        PopulateGridViewSell();
                    }
                    else
                    {
                        MessageBox.Show("Seçilen ürün için yeterli stoğunuz bulunmamaktadır. Kalan ürün sayısı: " + Constants.RemainingProduct);
                    }
                }
                else
                {
                    MessageBox.Show("Lütfen satış adedi giriniz");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        public decimal GetPriceOfProduct(SellBO objSellBO, int ProductID)
        {
            DbConnection  objDbConnection = DbConnection.GetInstance();
            SqlConnection con             = objDbConnection.GetConnection();

            con.Open();
            SqlCommand cmd = new SqlCommand("Select TypePrice From dbo.Type Where TypeName=@TypeName And ProductID=@ProductID", con);

            cmd.Parameters.Add(new SqlParameter("@TypeName", objSellBO.TypeName));
            cmd.Parameters.Add(new SqlParameter("@ProductID", ProductID));
            SqlDataReader dr    = cmd.ExecuteReader();
            decimal       Price = 0;

            if (dr.Read())
            {
                Price = dr.GetDecimal(0);
            }
            return(Price);
        }
Exemplo n.º 10
0
        private void ButtonPayLoan_Click(object sender, EventArgs e)
        {
            SellBL objSellBL = new SellBL();
            SellBO objSellBO = new SellBO();

            objSellBO.CustomerName = Constants.CompanyNameCustomerHistory;
            bool payed = objSellBL.PayLoanDA(objSellBO, Convert.ToDecimal(TextBoxPayment.Text));

            if (payed == false)
            {
                MessageBox.Show("Borçtan daha fazla ödeme yapılamaz");
            }
            else
            {
                MessageBox.Show("Ödeme Gerçekleşti");

                string decStr = objSellBL.GetTotalLoanBL().ToString("0.##");
                TextBoxTotalLoan.Text = decStr;

                TextBoxPayment.Text = "";
            }
        }