Ejemplo n.º 1
0
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar == 13) && (textBox1.Text != String.Empty))
            {
                string id    = "";
                bool   found = false;
                cn.Open();
                cm = new SqlCommand("select * from tblCart where transno = @transno and pcode = @pcode", cn);
                cm.Parameters.AddWithValue("@transno", fpos.lblTransaction.Text);
                cm.Parameters.AddWithValue("@pcode", pcode);
                dr = cm.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    found = true;
                    id    = dr["id"].ToString();
                }
                else
                {
                    found = false;
                }
                dr.Close();
                cn.Close();

                if (found == true)
                {
                    cn.Open();
                    cm = new SqlCommand("update tblCart set qty = (qty + " + int.Parse(textBox1.Text) + ") where id = '" + id + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();

                    fpos.txtSearch.Clear();
                    fpos.txtSearch.Focus();
                    fpos.LoadCart();
                    this.Dispose();
                }
                else
                {
                    cn.Open();
                    cm = new SqlCommand("insert into tblCart (transno, pcode, price, qty, sdate, cashier) values (@transno, @pcode, @price, @qty, @sdate, @cashier)", cn);
                    cm.Parameters.AddWithValue("@transno", transno);
                    cm.Parameters.AddWithValue("@pcode", pcode);
                    cm.Parameters.AddWithValue("@price", price);
                    cm.Parameters.AddWithValue("@qty", int.Parse(textBox1.Text));
                    cm.Parameters.AddWithValue("@sdate", DateTime.Now);
                    cm.Parameters.AddWithValue("@cashier", fpos.lblName.Text.Substring(0, fpos.lblName.Text.IndexOf(" |")));
                    cm.ExecuteNonQuery();
                    cn.Close();

                    fpos.txtSearch.Clear();
                    fpos.txtSearch.Focus();
                    fpos.LoadCart();
                    this.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            try
            {
                if ((double.Parse(txtChange.Text) < 0) || (txtChange.Text.ToString() == String.Empty))
                {
                    MessageBox.Show("Insufficient amount. Please enter the correct amount!", "Danger!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    for (int i = 0; i < fpos.dataGridView1.Rows.Count; i++)
                    {
                        //Update Product Table
                        cn.Open();
                        cm = new SqlCommand("update tblProduct set qty = qty - " + int.Parse(fpos.dataGridView1.Rows[i].Cells[5].Value.ToString()) + " where pcode = '" + fpos.dataGridView1.Rows[i].Cells[8].Value.ToString() + "'", cn);
                        cm.ExecuteNonQuery();
                        cn.Close();

                        //Update Cart Table
                        cn.Open();
                        cm = new SqlCommand("update tblCart set status = 'Sold' where id like '" + fpos.dataGridView1.Rows[i].Cells[1].Value.ToString() + "' and status like 'Pending'", cn);
                        cm.ExecuteNonQuery();
                        cn.Close();
                    }
                    formRecieptPOS frm = new formRecieptPOS(fpos);
                    frm.LoadReport(txtCash.Text, txtChange.Text);
                    frm.ShowDialog();
                    MessageBox.Show("Payment Sucessfuly Saved", "Payment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    fpos.getTransNo();
                    fpos.LoadCart();
                    this.Dispose();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Insufficient amount. Please enter the correct amount!", "Danger!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 3
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Add discount? Click Yes To Confirm.", stitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             cn.Open();
             cm = new SqlCommand("update tblcart set disc = @disc where id = @id", cn);
             cm.Parameters.AddWithValue("@disc", Double.Parse(txtDiscAmount.Text));
             cm.Parameters.AddWithValue("@id", int.Parse(lblID.Text));
             cm.ExecuteNonQuery();
             cn.Close();
             fpos.LoadCart();
             this.Dispose();
         }
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }