protected void firstButton_Click(object sender, EventArgs e)
        {
            SupplierBillPayment supplierBillPayment = supplierBillPaymentManager.GetSupplierBillPayment(0);

            GetData(supplierBillPayment);
            Session["active"] = 0;
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            SupplierBillPayment supplierBillPayment = new SupplierBillPayment();

            supplierBillPayment.SupplierDate = dateTextBox.Value;
            supplierBillPayment.BillNo       = billNoTextBox.Text;
            supplierBillPayment.SupId        = int.Parse(supplierNameDropDownList.SelectedValue);
            supplierBillPayment.PaymentMode  = paymentModeDropDownList.SelectedValue;
            supplierBillPayment.BankId       = int.Parse(bankNameDropDownList.SelectedValue);
            supplierBillPayment.CheckNo      = checkNoTextBox.Text;
            supplierBillPayment.CheckDate    = checkDateTextBox.Value;
            string amount = amountTextBox.Text;

            if (dateTextBox.Value == "" || billNoTextBox.Text == "" ||
                paymentModeDropDownList.Text == "" || checkNoTextBox.Text == "" || checkDateTextBox.Value == "" ||
                amountTextBox.Text == "")
            {
                messageLabel.InnerText = "All Fields are Required!!";
            }
            else
            {
                supplierBillPayment.Amount = Convert.ToDouble(amount);
                messageLabel.InnerText     = supplierBillPaymentManager.Save(supplierBillPayment);
            }
            ClearTextBoxes();
        }
コード例 #3
0
        private void dgv_Bills_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int billID = int.Parse(dgv_Bills.SelectedRows[0].Cells[0].Value.ToString());

            supplierBill = context.SupplierBills.FirstOrDefault(b => b.ID == billID);

            //label3.Text = supplierBill.suppliers.Name;
            dtp_GBillDate.Value = supplierBill.BillDate;
            numTotalCost.Value  = 0;
            numTotalCost.Value  = Convert.ToDecimal(supplierBill.BillValue);

            ///sales order payment

            supplierBillPayment    = context.supplierBillPayment.FirstOrDefault(b => b.SupplierBill_Id == billID);
            numericPaiedCost.Value = 0;
            numericPaiedCost.Value = Convert.ToDecimal(supplierBillPayment.Paied);
            numResCost.Value       = 0;
            numResCost.Value       = Convert.ToDecimal(supplierBillPayment.Rest);

            details = context.SuppliersBillDetails.Where(b => b.SupplierBill_Id == billID).ToList();
            dgv_SuplierBill.Rows.Clear();
            for (var item = 0; item < details.Count; item++)
            {
                int    pID      = details[item].products_Id;
                var    product  = context.products.FirstOrDefault(p => p.ID == pID);
                string pName    = product.ProductName;
                double quantity = product.quantityPerProducts;
                double price    = product.Price_customer;
                double discount = product.Discount; // error we have to add discount column to generalBillDetail table
                dgv_SuplierBill.Rows.Add(discount, price, quantity, pName, pID);
            }
        }
 public string Save(SupplierBillPayment supplierBillPayment)
 {
     if (supplierBillPaymentGateway.Insert(supplierBillPayment) > 0)
     {
         return("Saved Successfully!!");
     }
     return("Could Not Save data in Database!!");
 }
        protected void lastButton_Click(object sender, EventArgs e)
        {
            List <SupplierBillPayment> supplierBillPaymentList = (List <SupplierBillPayment>)(Session["supplierBillPayment"]);
            int x = supplierBillPaymentList.Count - 1;
            SupplierBillPayment supplierBillPayment = supplierBillPaymentManager.GetSupplierBillPayment(x);

            GetData(supplierBillPayment);
            Session["active"] = x;
        }
 private void GetData(SupplierBillPayment supplierBillPayment)
 {
     dateTextBox.Value             = supplierBillPayment.SupplierDate;
     billNoTextBox.Text            = supplierBillPayment.BillNo;
     supplierNameDropDownList.Text = supplierBillPayment.SupplierName;
     paymentModeDropDownList.Text  = supplierBillPayment.PaymentMode;
     bankNameDropDownList.Text     = supplierBillPayment.BankAccountName;
     checkNoTextBox.Text           = supplierBillPayment.CheckNo;
     checkDateTextBox.Value        = supplierBillPayment.CheckDate;
     amountTextBox.Text            = supplierBillPayment.Amount.ToString();
 }
 private static void GetValueFromDatabase(SupplierBillPayment supplierBillPayment, SqlDataReader reader)
 {
     supplierBillPayment.SupplierBillPaymentId = int.Parse(reader["id"].ToString());
     supplierBillPayment.SupplierDate          = reader["date"].ToString();
     supplierBillPayment.BillNo          = reader["bill_no"].ToString();
     supplierBillPayment.SupplierName    = reader["supplier_id"].ToString();
     supplierBillPayment.PaymentMode     = reader["payment_mode"].ToString();
     supplierBillPayment.BankAccountName = reader["bank_id"].ToString();
     supplierBillPayment.CheckNo         = reader["check_no"].ToString();
     supplierBillPayment.CheckDate       = reader["check_date"].ToString();
     supplierBillPayment.Amount          = Convert.ToDouble(reader["amount"].ToString());
 }
        public int Insert(SupplierBillPayment supplierBillPayment)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "INSERT INTO tbl_supplierBillPayment VALUES('" + supplierBillPayment.SupplierDate + "','" +
                                       supplierBillPayment.BillNo + "','" + supplierBillPayment.SupId + "','" +
                                       supplierBillPayment.PaymentMode + "','" + supplierBillPayment.BankId + "','" + supplierBillPayment.CheckNo + "','" +
                                       supplierBillPayment.CheckDate + "','" + supplierBillPayment.Amount + "')";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
        protected void nextButton_Click(object sender, EventArgs e)
        {
            int active = (int)Session["active"];

            active++;
            List <SupplierBillPayment> supplierBillPaymentList = (List <SupplierBillPayment>)(Session["supplierBillPayment"]);

            if (active >= supplierBillPaymentList.Count)
            {
                active = 0;
            }
            SupplierBillPayment supplierBillPayment = supplierBillPaymentManager.GetSupplierBillPayment(active);

            GetData(supplierBillPayment);
            Session["active"] = active;
        }
        public SupplierBillPayment GetSupplierBillPayment(int i)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_supplierBillPayment ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader       reader = command.ExecuteReader();
            SupplierBillPayment supplierBillPayment = new SupplierBillPayment();

            while (reader.Read())
            {
                GetValueFromDatabase(supplierBillPayment, reader);
            }
            reader.Close();
            connection.Close();
            return(supplierBillPayment);
        }
        private string LoadNextBillNo()
        {
            SupplierBillPayment supplierBillPayment = supplierBillPaymentManager.GetNextBillNo();
            string billNo = supplierBillPayment.BillNo;
            int    count;

            if (billNo == null)
            {
                count = 1;
            }
            else
            {
                count = (billNo[4] - '0') * 10 + (billNo[5] - '0') + 1;
            }

            string nextBillNo = "Bi-0" + count.ToString("00");

            return(nextBillNo);
        }
        public SupplierBillPayment GetNextBillNo()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT TOP 1 * FROM tbl_supplierBillPayment ORDER BY id DESC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader       reader = command.ExecuteReader();
            SupplierBillPayment supplierBillPayment = new SupplierBillPayment();

            while (reader.Read())
            {
                supplierBillPayment.SupplierBillPaymentId = int.Parse(reader["id"].ToString());
                supplierBillPayment.BillNo = reader["bill_no"].ToString();
            }
            reader.Close();
            connection.Close();
            return(supplierBillPayment);
        }
        public List <SupplierBillPayment> GetAllSupplierBillPaymentList()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_supplierBillPayment";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            List <SupplierBillPayment> supplierBillPaymentList = new List <SupplierBillPayment>();

            while (reader.Read())
            {
                SupplierBillPayment supplierBillPayment = new SupplierBillPayment();
                GetValueFromDatabase(supplierBillPayment, reader);

                supplierBillPaymentList.Add(supplierBillPayment);
            }
            reader.Close();
            connection.Close();
            return(supplierBillPaymentList);
        }