예제 #1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     try
     {
         var confirmResult = MessageBox.Show("Add Discount ?? Click yes to confirm",
                                             "Confirm!!",
                                             MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             using (SqlConnection sqlConnection = new SqlConnection(DBConnection.MyConnection()))
             {
                 sqlConnection.Open();
                 SqlCommand sqlCommand = new SqlCommand("update tblCart set disc =@disc where id = @id ", sqlConnection);
                 sqlCommand.Parameters.AddWithValue("@disc", Double.Parse(txtDiscountAmount.Text));
                 sqlCommand.Parameters.AddWithValue("@id", int.Parse(lblID.Text));
                 sqlCommand.ExecuteNonQuery();
                 sqlConnection.Close();
                 _pOS.loadCart();
                 this.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, _msg, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        private void txtQty_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar == 13) && (!string.IsNullOrEmpty(txtQty.Text.Trim())))
            {
                using (SqlConnection sqlConnection = new SqlConnection(DBConnection.MyConnection()))
                {
                    string query = "insert into tblCart (transno,pcode,price,qty,sdate) values (@transno,@pcode,@price,@qty,@sdate)";
                    sqlConnection.Open();
                    SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
                    sqlCommand.Parameters.AddWithValue("@transno", transno);
                    sqlCommand.Parameters.AddWithValue("@pcode", pcode);
                    sqlCommand.Parameters.AddWithValue("@price", double.Parse(price.ToString()));
                    sqlCommand.Parameters.AddWithValue("@qty", int.Parse(txtQty.Text.Trim()));
                    sqlCommand.Parameters.AddWithValue("@sdate", DateTime.Now);
                    sqlCommand.ExecuteNonQuery();
                    sqlConnection.Close();

                    _pOS.txtSearchBarcode.Clear();
                    _pOS.txtSearchBarcode.Focus();
                    _pOS.loadCart();
                    this.Dispose();
                }
            }
        }