Example #1
0
        public Supplier GetSupplierByid(int toInt32)
        {
            Supplier aSupplier=new Supplier();
            try
            {
                this.OpenConnection();
                string sqlComm = String.Format(SqlQueries.GetQuery(Query.GetSupplierByid), toInt32);
                IDataReader aReader = this.ExecuteReader(sqlComm);
                if (aReader != null)
                {
                    while (aReader.Read())
                    {

                        aSupplier = ReaderToSupplier(aReader);

                    }
                }
            }
            catch (Exception ex)
            {

                throw new Exception("GetSupplierByid()",ex);
            }
            finally
            {
                this.CloseConnection();
            }
            return aSupplier;
        }
Example #2
0
 private void supplierSavebutton_Click(object sender, EventArgs e)
 {
     Supplier aSupplier=new Supplier();
     aSupplier.Name = supplierNametextBox.Text;
       //  replace(Request.QueryString(test), "'", "''")
        // aSupplier.ContactInformation = contactInformationtextBox.Text;
     aSupplier.ContactInformation = contactInformationtextBox.Text.Replace("'", "''");
     if (supplierNametextBox.Text.Length!=0 && contactInformationtextBox.Text.Length!=0)
     {
         SupplierBLL aBll = new SupplierBLL();
         bool check = aBll.CheckExit(aSupplier.Name);
         if (!check)
         {
             actionlabel.Visible = true;
             actionlabel.Text = aBll.InsertSupplier(aSupplier);
             if (actionlabel.Text != "Please Check Your Input")
             {
                 contactInformationtextBox.Clear();
                 supplierNametextBox.Clear();
             }
         }
         else MessageBox.Show("Supplier Already Exit");
     } else
     {
         actionlabel.Visible = true;
         actionlabel.Text = "Please Check Your Input";
     }
 }
Example #3
0
        public List<Supplier> GetAllSupplier()
        {
            List<Supplier>aList=new List<Supplier>();
            try
            {
                this.OpenConnection();
                string sqlComm = String.Format(SqlQueries.GetQuery(Query.GetAllSupplier));
                IDataReader aReader = this.ExecuteReader(sqlComm);
                if(aReader!=null)
                {
                    while(aReader.Read())
                    {
                        Supplier aSupplier=new Supplier();
                        aSupplier = ReaderToSupplier(aReader);
                        aList.Add(aSupplier);
                    }
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex + " Oooops........Please Check Your input:()");
            }
            finally
            {
                this.CloseConnection();
            }
            return aList;
        }
Example #4
0
        public void InsertIntosupplier_payment_reportForSupplierPaymentTrack(Supplier aSupplier)
        {
            try
            {
                this.OpenConnection();
                string sqlComm = String.Format(SqlQueries.GetQuery(Query.InsertIntosupplier_payment_reportForSupplierPaymentTrack),
                    aSupplier.SupplierId,aSupplier.TotalAmount,aSupplier.PaidAmount,aSupplier.PaymentType,DateTime.Now,RMSGlobal.LogInUserName);
                this.ExecuteNonQuery(sqlComm);

            }
            catch (Exception ex)
            {

                throw new Exception("InsertIntosupplier_payment_reportForSupplierPaymentTrack()",ex);
            }
            finally
            {
                this.CloseConnection();
            }
        }
Example #5
0
        private void savePaymentbutton_Click(object sender, System.EventArgs e)
        {
            if (paidPricetextBox.Text.Length > 0)
            {
                try
                {
                   // Supplier aSupplier = (Supplier) supplierNamecomboBox.SelectedItem;
                    if (Convert.ToDouble(paidPricetextBox.Text) > 0)
                    {
                        SupplierBLL aSupplierBll = new SupplierBLL();
                        Supplier aSupplier =
                            aSupplierBll.GetSupplierByid(Convert.ToInt32(supplierNamecomboBox.SelectedValue));

                        Supplier aasSupplier = new Supplier();
                        aasSupplier.SupplierId = aSupplier.SupplierId;
                        aasSupplier.TotalAmount = aSupplier.TotalAmount;
                        aasSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text);
                        aasSupplier.PaymentType = (string)paymentTypecomboBox.SelectedItem;
                        aSupplierBll.InsertIntosupplier_payment_reportForSupplierPaymentTrack(aasSupplier);
                        aSupplier.PaidAmount += Convert.ToDouble(paidPricetextBox.Text);
                        aSupplierBll.UpdateSupplierForPurchase(aSupplier);
                        purchaseActionlabel.Visible = true;
                        purchaseActionlabel.Text = "Payment Successfully";
                        paidPricetextBox.Clear();
                    }
                    else MessageBox.Show("You cannot put zero balance!");

                }
                catch (Exception ex)
                {

                   // throw new Exception("Please check input format",ex);
                    MessageBox.Show("Please check input format");
                }
            }
            else MessageBox.Show("Please Check Paid Amount, May be Empty");
        }
Example #6
0
        private Supplier ReaderToSupplier(IDataReader aReader)
        {
            Supplier aSupplier=new Supplier();
            try
            {
                aSupplier.SupplierId = Convert.ToInt32(aReader["supplier_id"]);
            }
            catch
            {

            }
            try
            {
                aSupplier.Name = aReader["supplier_name"].ToString();
            }
            catch
            {

            }
            try
            {
                aSupplier.TotalAmount = Convert.ToDouble(aReader["suppler_amount"]);
            }
            catch
            {

            }
            try
            {
                aSupplier.PaidAmount = Convert.ToDouble(aReader["paid_amount"]);
            }
            catch
            {

            }
            try
            {
                aSupplier.ContactInformation = (aReader["contact_information"]).ToString();
            }
            catch
            {

            }

            if (aSupplier.PaidAmount > aSupplier.TotalAmount)
            {
                aSupplier.AdvanceAmount = aSupplier.PaidAmount - aSupplier.TotalAmount;
            }
            else aSupplier.AdvanceAmount = 0.0;
            if (aSupplier.PaidAmount < aSupplier.TotalAmount)
            {
                aSupplier.DueAmount = aSupplier.TotalAmount - aSupplier.PaidAmount;
            }
            else aSupplier.DueAmount = 0.0;
            return aSupplier;
        }
Example #7
0
        public void UpdateSupplierForPurchase(Supplier aSupplier)
        {
            try
            {
                this.OpenConnection();
                string sqlComm = String.Format(SqlQueries.GetQuery(Query.UpdateSupplierForPurchase),aSupplier.TotalAmount
                    ,aSupplier.PaidAmount,aSupplier.SupplierId);
                this.ExecuteNonQuery(sqlComm);
            }
            catch (Exception ex)
            {

                MessageBox.Show("Ooops " + ex);
            }

            finally
            {
                this.CloseConnection();

            }
        }
Example #8
0
        public string InsertSupplier(Supplier aSupplier)
        {
            string sr = string.Empty;
               try
               {
               this.OpenConnection();
               string sqlCommand = String.Format(SqlQueries.GetQuery(Query.InsertSupplier), aSupplier.Name,
                                                 aSupplier.ContactInformation);
               this.ExecuteNonQuery(sqlCommand);
               sr = "Supplier Create Successfully";

               }
               catch
               {

               sr = "Please Check Your Input";
               }
               finally
               {
               this.CloseConnection();
               }

               return sr;
        }
Example #9
0
        private void savePurchasebutton_Click(object sender, EventArgs e)
        {
            try
            {

                if (expiredateTimePicker.Value.Date == DateTime.Now.Date)
                {
                    DialogResult result = MessageBox.Show("Do you want to Empty Expire Date?", "Confirmation",
                                                          MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {

                    }
                    else if (result == DialogResult.No)
                    {
                        return;
                    }

                }

                if (pricetextBox.Text.Length != 0 && paidPricetextBox.Text.Length != 0 && quantitytextBox.Text.Length != 0)
                {
                    InventoryPurchase aInventoryPurchase = new InventoryPurchase();
                    InventoryCategory aCategory = new InventoryCategory();
                    InventoryItem aItem = new InventoryItem();
                    Supplier aSupplier = new Supplier();
                    Supplier aaSupplier = new Supplier();
                    Unit aUnit = new Unit();

                    //Add for purchase record
                    aCategory = (InventoryCategory) categoryNamecomboBox.Items[categoryNamecomboBox.SelectedIndex];

                    SupplierBLL aSupplierBll = new SupplierBLL();
                    aSupplier = aSupplierBll.GetSupplierByid(Convert.ToInt32(supplierNamecomboBox.SelectedValue));
                   // aSupplier = (Supplier) supplierNamecomboBox.Items[supplierNamecomboBox.SelectedIndex];
                    if (aSupplier.PaidAmount > aSupplier.TotalAmount)
                    {
                        aSupplier.AdvanceAmount = aSupplier.PaidAmount - aSupplier.TotalAmount;
                    }
                    else aSupplier.DueAmount = aSupplier.TotalAmount - aSupplier.PaidAmount;

                    aItem = (InventoryItem) itemNamecomboBox.Items[itemNamecomboBox.SelectedIndex];
                    aInventoryPurchase.Quantity = Convert.ToDouble(quantitytextBox.Text);
                    aInventoryPurchase.Price = Convert.ToDouble(pricetextBox.Text);
                    aInventoryPurchase.Date = DateTime.Now;
                    aInventoryPurchase.Category = aCategory;
                    aInventoryPurchase.Item = aItem;
                    aaSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text);
                    aInventoryPurchase.Supplier = aaSupplier;
                    if (((aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text) -
                          (Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount))) >= 0)
                        aInventoryPurchase.Supplier.DueAmount = aSupplier.DueAmount +
                                                                Convert.ToDouble(pricetextBox.Text) -
                                                                (Convert.ToDouble(paidPricetextBox.Text) +
                                                                 aSupplier.AdvanceAmount);
                    else aInventoryPurchase.Supplier.DueAmount = 0.0;
                    if (((Convert.ToDouble(paidPricetextBox.Text) + aSupplier.AdvanceAmount) -
                         (aSupplier.DueAmount + Convert.ToDouble(pricetextBox.Text))) >= 0)
                    {
                        aInventoryPurchase.Supplier.AdvanceAmount = (Convert.ToDouble(paidPricetextBox.Text) +
                                                                     aSupplier.AdvanceAmount) -
                                                                    (aSupplier.DueAmount +
                                                                     Convert.ToDouble(pricetextBox.Text));
                    }
                    else aInventoryPurchase.Supplier.AdvanceAmount = 0.0;
                    aInventoryPurchase.Supplier.Name = aSupplier.Name;
                    aInventoryPurchase.Supplier.SupplierId = aSupplier.SupplierId;
                    aUnit.UnitName = unittypelabel.Text;
                    aInventoryPurchase.Unit = aUnit;
                    CUserInfo aUserInfo= new CUserInfo();
                    aUserInfo.UserName= RMSGlobal.LogInUserName;
                    aInventoryPurchase.PaymentType= paymentTypecomboBox.SelectedItem.ToString();
                    aInventoryPurchase.CUserInfo= aUserInfo;
                    if (expiredateTimePicker.Value.Date == DateTime.Now.Date)
                    {

                    }
                    else
                    {
                        aInventoryPurchase.ExpireDate = expiredateTimePicker.Value.Date;
                    }

                    string res = string.Empty;

                    InventoryPurchaseBLL aInventoryPurchaseBll = new InventoryPurchaseBLL();
                    res = aInventoryPurchaseBll.InsertPurchase(aInventoryPurchase);

                    if(res=="Purchase Insert Sucessfully")
                    {
                        //Add for Supplier Update
                        aSupplier.TotalAmount += Convert.ToDouble(pricetextBox.Text);
                        aSupplier.PaidAmount += Convert.ToDouble(paidPricetextBox.Text);

                        aSupplierBll.UpdateSupplierForPurchase(aSupplier);

                        //Add for Supplier payment report
                        Supplier paymentSupplier=new Supplier();
                        paymentSupplier.PaidAmount = Convert.ToDouble(paidPricetextBox.Text);
                        paymentSupplier.TotalAmount = Convert.ToDouble(pricetextBox.Text);
                        paymentSupplier.SupplierId = aSupplier.SupplierId;
                        paymentSupplier.PaymentType = paymentTypecomboBox.SelectedItem.ToString();
                        aSupplierBll.InsertIntosupplier_payment_reportForSupplierPaymentTrack(paymentSupplier);

                        //Add for stock update
                        Stock aStock=new Stock();
                        aStock.Category = aCategory;
                        aStock.Item = aItem;
                        aStock.Unit = aUnit;
                        aStock.Stocks = Convert.ToDouble(quantitytextBox.Text);
                        aStock.UnitPrice = Convert.ToDouble(pricetextBox.Text)/aStock.Stocks;
                        StockBLL aStockBll=new StockBLL();
                        aStockBll.InsertStockOrUpdate(aStock);

                        purchaseActionlabel.Visible = true;
                        purchaseActionlabel.Text = res;
                        Clear();
                    }else
                    {
                        purchaseActionlabel.Visible = true;
                        purchaseActionlabel.Text = res;
                    }

                }else
                {
                    purchaseActionlabel.Visible = true;
                    purchaseActionlabel.Text = "Please Check Your Input";
                }

            }
            catch
            {
                MessageBox.Show("Try Again May Be Your Given Input Format Not Correct Please Given Again ");

            }
        }
Example #10
0
        private void showButton_Click(object sender, System.EventArgs e)
        {
            SupplierBLL aSupplierBll=new SupplierBLL();
            List<Supplier>aList=new List<Supplier>();
            if(viewAllsuppliercheckBox.Checked)
            {
                aList = aSupplierBll.GetAllSupplier();
                supplierdataGridView.DataSource = aList;
            }
            else
            {
                Supplier aSupplier=new Supplier();
                aSupplier = aSupplierBll.GetSupplierByid(Convert.ToInt32(supplierNamecomboBox.SelectedValue));
                aList = new List<Supplier> {aSupplier};
                supplierdataGridView.DataSource = aList;

            }
        }
Example #11
0
        private InventoryPurchase ReaderToReadInventoryPurchase(IDataReader aReader)
        {
            InventoryPurchase aInventoryPurchase = new InventoryPurchase();
               InventoryCategory aCategory=new InventoryCategory();
               InventoryItem aItem=new InventoryItem();
               Supplier aSupplier=new Supplier();
               Unit aUnit = new Unit();
               CUserInfo aCUserInfo=new CUserInfo();

               try
               {
               aCategory.CategoryId = Convert.ToInt32(aReader["category_id"]);

               }
               catch
               {

               }
               try
               {

               aCategory.CategoryName = aReader["category_name"].ToString();
               }
               catch
               {
               }

               try
               {
              aItem.ItemId = Convert.ToInt32(aReader["item_id"]);

               }
               catch
               {

               }
               try
               {
               aItem.ItemName = (aReader["item_name"]).ToString();

               }
               catch
               {

               }
               try
               {
               aSupplier.SupplierId = Convert.ToInt32(aReader["supplier_id"]);

               }
               catch
               {

               }
               try
               {
               aSupplier.Name =(aReader["supplier_name"]).ToString();

               }
               catch
               {

               }
               try
               {
               aInventoryPurchase.PurchaseId = Convert.ToInt32((aReader["purchase_id"]));

               }
               catch
               {

               }

               try
               {
               aInventoryPurchase.Quantity = Convert.ToDouble((aReader["quantity"]));

               }
               catch
               {
               }
               try
               {
              aUnit.UnitName = (aReader["unit"]).ToString();

               }
               catch
               {
               }

               try
               {
               aInventoryPurchase.Price = Convert.ToDouble((aReader["total_price"]));

               }
               catch
               {
               }
               try
               {
               aSupplier.PaidAmount = Convert.ToDouble((aReader["paid_amount"]));

               }
               catch
               {

               }
               try
               {
               aSupplier.AdvanceAmount = Convert.ToDouble((aReader["advance_amount"]));

               }
               catch
               {

               }
               try
               {
               aSupplier.DueAmount = Convert.ToDouble((aReader["due_amount"]));

               }
               catch
               {

               }
               try
               {
               aInventoryPurchase.Date = Convert.ToDateTime((aReader["date"]));

               }
               catch
               {
               }
               try
               {
               aInventoryPurchase.PaymentType = ((aReader["payment_type"])).ToString();

               }
               catch
               {
               }

               try
               {
               aCUserInfo.UserName = ((aReader["user_name"])).ToString();

               }
               catch
               {
               }

               try
               {
               aInventoryPurchase.ExpireDate = Convert.ToDateTime((aReader["ExpireDate"]));

               }
               catch
               {
               }

               aInventoryPurchase.Category = aCategory;
               aInventoryPurchase.Item = aItem;
               aInventoryPurchase.Supplier = aSupplier;
               aInventoryPurchase.Unit = aUnit;
               aInventoryPurchase.CUserInfo = aCUserInfo;

               return aInventoryPurchase;

              // DateTime aTime = DateTime.Now.AddDays(-1);
        }