예제 #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     //DELETE CODE MOT WORKING FINE
     if (DateSelect == true)
     {
         if (MessageBox.Show("All records will be Deleted for Selected Date\nContinue ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             ItemSales.DeleteSale(dateTimeFrom);
             dataAccess.Description = "Deleted all credit Sales record for " + dateTimeFrom.Value.ToString("MM/dd/yyyy");
             dataAccess.Activities();
             CreditSales.AllCreditSales(dataGridCreditSalesRecord, "");
             DateSelect = false;
         }
     }
     else
     {
         if (MessageBox.Show("Confirm Delete of Selected Record", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             //CARRY OUT DELETE
             if (SalesID <= 0)
             {
                 throw new Exception("Select a record to Delete");
             }
             else
             {
                 ItemSales.DeleteSale(SalesID);
                 dataAccess.Description = "Deleted a Credit Sales record";
                 dataAccess.Activities();
                 CreditSales.AllCreditSales(dataGridCreditSalesRecord, "");
                 SalesID = 0;
             }
         }
     }
 }
예제 #2
0
 public Credit_Sales_Record()
 {
     InitializeComponent();
     CreditSales.AllCreditSales(dataGridCreditSalesRecord, txtItemSearch.Text);
     lblTotal.Text = string.Format("{0:00.#0}", ItemSales.TodayTotal);
     ItemSales.ItemNames(combItemName);
 }
예제 #3
0
 private void combItemName_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         CreditSales.AllCreditBetweenDate(dataGridCreditSalesRecord, dateTimeFrom, dateTimeTo, combItemName.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #4
0
 private void txtItemSearch_TextChanged(object sender, EventArgs e)
 {
     try
     {
         CreditSales.AllCreditSales(dataGridCreditSalesRecord, txtItemSearch.Text);
         lblTotal.Text = string.Format("{0:00.#0}", ItemSales.TodayTotal);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #5
0
 private void dateTimeTo_ValueChanged(object sender, EventArgs e)
 {
     try
     {
         DateSelect = false;
         CreditSales.AllCreditBetweenDate(dataGridCreditSalesRecord, dateTimeFrom, dateTimeTo);
         lblTotal.Text = string.Format("{0:00.#0}", ItemSales.TodayTotal);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #6
0
        public static void makeSale(int itemid, int qty_Avail, string Quantity, string cost, string total, DateTimePicker dDate, string discount, int credit = 0, string nameid = null)
        {
            SqlConnection con = new DBConnection().getConnection();

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@Item_Id", itemid);
                cmd.Parameters.AddWithValue("@UserName", AdminLog.Admin);
                cmd.Parameters.AddWithValue("@Qty", Quantity);
                cmd.Parameters.AddWithValue("@Cost", cost);
                cmd.Parameters.AddWithValue("@Discount", discount);
                cmd.Parameters.AddWithValue("@Amount", total);
                cmd.Parameters.AddWithValue("@Sold_Date", dDate.Value.ToString("MM/dd/yyy"));
                cmd.Parameters.AddWithValue("@Qty_Avail", qty_Avail);
                if (nameid == null)
                {
                    cmd.CommandText = "INSERT INTO Sales(Item_Id,UserName,Qty,Cost,Discount,Amount,Sold_Date,Qty_Avail) VALUES(@Item_Id,@UserName,@Qty,@Cost,@Discount,@Amount,@Sold_Date,@Qty_Avail)";
                }
                else
                {
                    cmd.Parameters.AddWithValue("@Name_id", nameid);
                    cmd.CommandText = "INSERT INTO Sales(Item_Id,UserName,Qty,Cost,Discount,Amount,Sold_Date,Name_id,Qty_Avail) VALUES(@Item_Id,@UserName,@Qty,@Cost,@Discount,@Amount,@Sold_Date,@Name_id,@Qty_Avail)";
                }
                cmd.ExecuteNonQuery();

                if (credit != 0)
                {
                    SqlDataAdapter da = new SqlDataAdapter("SELECT Max(Sales_Id) FROM  Sales  ", con);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    var saleId = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        saleId = Int32.Parse(dr[0].ToString());
                    }
                    CreditSales creditsale = new CreditSales();
                    CreditSales.RecordCreditor(saleId, creditsale.GetCreditorFirstname(), creditsale.GetCreditorLastname(), creditsale.GetCreditorContact());
                }
                SaleMade = true;
                con.Close();
            }
            catch (Exception Ex)
            {
                throw new ExceptionHandling("An Error Occurred", Ex);
            }
        }