示例#1
0
 private void Clear_Click(object sender, RoutedEventArgs e)
 {
     TB_NOP.Clear();
     TB_categoryList.Text = "";
     TB_rating.Clear();
     TB_price.Clear();
     TB_number.Clear();
     TB_size.Clear();
     TB_delete_NOP.Clear();
 }
        /// <summary>
        /// Adds Items to the bill
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_addToBill_Click(object sender, EventArgs e)
        {
            if (validation())
            {
                if (billArea.Controls.Count < 1)
                {
                    RefreshBill();
                }

                billItem bItem = new billItem();
                bItem.ItemName = TB_name.Text;
                bItem.ItemCat  = cat;

                bItem.ItemPrice    = TB_price.Text;
                bItem.ItemQty      = TB_qty.Text;
                bItem.Size         = new Size(245, 45);
                bItem.DoubleClick += BItem_DoubleClick;

                billArea.Controls.Add(bItem);
                this.ActiveControl = bItem;
                billArea.ScrollControlIntoView(bItem);

                //Add item to the bill
                try
                {
                    String Qry = "INSERT INTO Bill (Bill_ID, ItemID , ItemName, ItemCategory, ItemDiscount, ItemPrice, Qty, Total, Date, Time) " +
                                 "VALUES (" +
                                 BillID + "," +
                                 itemID + "," +
                                 "'" + TB_name.Text + "'," +
                                 "'" + cat + "'," +
                                 TB_dis.Text + "," +
                                 TB_price.Text + "," +
                                 TB_qty.Text + "," +
                                 float.Parse(TB_qty.Text) * float.Parse(TB_price.Text) +
                                 ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "'" +
                                 ",'" + DateTime.Now.ToString("hh:mm:ss") + "')";

                    SqlCommand cmd = new SqlCommand(Qry, Connection);
                    Connection.Open();
                    cmd.ExecuteNonQuery();
                    itemID = 0;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Connection.Close();
                }

                CalculateTotal();

                ReportAnalysis analysis = new ReportAnalysis();
                analysis.UpdatePopularity();

                TB_dis.Clear();
                TB_name.Clear();
                TB_price.Clear();
                TB_qty.Clear();
                MaskAdd(TB_name, "Enter Item Name");
                MaskAdd(TB_price, "Enter Item Price");
                MaskAdd(TB_qty, "Qty");
                MaskAdd(TB_dis, "Discount");
                MaskAdd(TB_search, "Search Items");
            }
        }