protected void TxtBarcode_TextChanged(object sender, EventArgs e) { // Response.Write("Its working"); MySqlConnection con = new MySqlConnection(cs); con.Open(); MySqlCommand cmd = new MySqlCommand(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select * From TblMedicine where Barcode='" + TxtBarcode.Text.ToString() + "'"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow dr in dt.Rows) { TxtItemName.Text = (dr["Medicine"].ToString()); TxtPrice.Text = (dr["Price"].ToString()); } TxtQty.Focus(); }
private void TxtBarCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TxtQty.Focus(); TxtQty.SelectAll(); } }
protected void TxtDisRsChild_TextChanged(object sender, EventArgs e) { TxtPurchaseRate.Text = TxtPurchaseRate.Text == "" ? "0" : TxtPurchaseRate.Text; txtDiscPerChild.Text = txtDiscPerChild.Text == "" ? "0" : txtDiscPerChild.Text; TxtDisRsChild.Text = TxtDisRs.Text == "" ? "0" : TxtDisRs.Text; TxtQty.Text = TxtQty.Text == "" ? "0" : TxtQty.Text; txtDiscPerChild.Text = "0"; //TxtDisRs.Text = (Convert.ToDecimal(TxtMRP.Text) * Convert.ToDecimal(txtDiscPerChild.Text) / 100).ToString("0.00"); TxtMRP.Text = (Convert.ToDecimal(TxtMRP.Text) - Convert.ToDecimal(TxtDisRsChild.Text)).ToString("0.00"); LblTotal.Text = (Convert.ToDecimal(TxtQty.Text) * Convert.ToDecimal(Convert.ToDecimal(TxtPurchaseRate.Text) - Convert.ToDecimal(TxtDisRsChild.Text))).ToString("0.00"); TxtQty.Focus(); }
private void BtnProducts_Click(object sender, EventArgs e) { SearchProduct SearchPro = new SearchProduct(); SearchPro.ShowDialog(); if (SearchPro.DialogResult == DialogResult.OK) { TxtIDPro.Text = SearchPro.dataGridView1.Rows[SearchPro.dataGridView1.CurrentRow.Index].Cells[0].Value.ToString(); LblDescriptionProduct.Text = SearchPro.dataGridView1.Rows[SearchPro.dataGridView1.CurrentRow.Index].Cells[1].Value.ToString(); LblPriceProd.Text = SearchPro.dataGridView1.Rows[SearchPro.dataGridView1.CurrentRow.Index].Cells[2].Value.ToString(); lblStock.Text = SearchPro.dataGridView1.Rows[SearchPro.dataGridView1.CurrentRow.Index].Cells[3].Value.ToString(); Engine.idproduct = int.Parse(TxtIDPro.Text); TxtQty.Focus(); } }
private void button1_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(TxtIDPro.Text.Trim()) == false) { Engine.idproduct = int.Parse(TxtIDPro.Text); Engine.SProduct(); LblDescriptionProduct.Text = Engine.ProductDescription; LblPriceProd.Text = Convert.ToString(Engine.ProductPrice); lblStock.Text = Convert.ToString(Engine.productStock); TxtQty.Focus(); } } catch (Exception error) { Engine.Qupdate = int.Parse(TxtQty.Text); if (int.Parse(TxtQty.Text) <= int.Parse(lblStock.Text)) { bool addedbefore = false; int num_row = 0; if (counter_row == 0) { dataGridView1.Rows.Add(TxtIDPro.Text, LblDescriptionProduct.Text, LblPriceProd.Text, TxtQty.Text); double totalprice = Convert.ToDouble(dataGridView1.Rows[counter_row].Cells[2].Value) * Convert.ToDouble(dataGridView1.Rows[counter_row].Cells[3].Value); dataGridView1.Rows[counter_row].Cells[4].Value = totalprice; counter_row++; Engine.Qtyupdater(); lblStock.Text = Convert.ToString(Engine.Qupdate); } else { foreach (DataGridViewRow r in dataGridView1.Rows) { if (r.Cells[0].Value.ToString() == TxtIDPro.Text) { addedbefore = true; num_row = r.Index; } } if (addedbefore == true) { dataGridView1.Rows[num_row].Cells[3].Value = (Convert.ToDouble(TxtQty.Text) + Convert.ToDouble(dataGridView1.Rows[num_row].Cells[3].Value)).ToString(); double totalprice = Convert.ToDouble(dataGridView1.Rows[num_row].Cells[2].Value) * Convert.ToDouble(dataGridView1.Rows[num_row].Cells[3].Value); dataGridView1.Rows[num_row].Cells[4].Value = totalprice; Engine.Qtyupdater(); lblStock.Text = Convert.ToString(Engine.Qupdate); } else { dataGridView1.Rows.Add(TxtIDPro.Text, LblDescriptionProduct.Text, LblPriceProd.Text, TxtQty.Text); double totalprice = Convert.ToDouble(dataGridView1.Rows[counter_row].Cells[2].Value) * Convert.ToDouble(dataGridView1.Rows[counter_row].Cells[3].Value); dataGridView1.Rows[counter_row].Cells[4].Value = totalprice; counter_row++; Engine.Qtyupdater(); lblStock.Text = Convert.ToString(Engine.Qupdate); } } TotalInvoice = 0; foreach (DataGridViewRow r in dataGridView1.Rows) { TotalInvoice += Convert.ToDouble(r.Cells[4].Value); } LblTotalInv.Text = "CZK " + TotalInvoice.ToString(); } } }
private void Save_Click(object sender, EventArgs e) { if (TxtVNo.Text.Trim().Length <= 0) { MessageBox.Show("Enter Voucher Number", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtVNo.Focus(); return; } if (TxtName.Text.Trim().Length <= 2) { MessageBox.Show("Invalid Subcriber Name", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtName.Focus(); return; } if (TxtAdd.Text.Trim().Length <= 5) { MessageBox.Show("Invalid Subscriber Address", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtAdd.Focus(); return; } if (TxtPIN.Text.Trim().Length > 0) { if (TxtPIN.Text.Trim().Length != 6) { MessageBox.Show("Invalid PIN Code", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtPIN.Focus(); return; } } if (Convert.ToInt32(db.ExtractCode(CmbExecutive.Text)) <= 0) { MessageBox.Show("Invalid Executive Name", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); CmbExecutive.Focus(); return; } if (Convert.ToInt16(TxtQty.Text) <= 0) { MessageBox.Show("Invalid Quantity", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtQty.Focus(); return; } DataSet ds; ds = db.GetTableData("Select * from mas_sub_pay_details where voucher_no='" + TxtOldVNo.Text.Trim() + "' and '01-" + DtpMnthFrm.Value.ToString("MMM-yy") + "' between period_frm and period_to"); if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("Invalid Previous Subscription Voucher Number", "HD Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if (TxtPhone.Text.Trim().Length < 10) //{ // MessageBox.Show("Invalid Mobile Number", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); // TxtAdd.Focus(); // return; //} int issues = 0; ds = db.GetTableData("Select * from MAS_SUB_TYPE where sub_type_id=" + db.ExtractCode(CmbSubType.Text)); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { issues = Convert.ToInt32(dr["issues"].ToString()); } } string[] res; if (LblPK.Text.Trim().Length > 0) { res = db.ExecuteQueries("Update mas_subscriptions set state_id=" + db.ExtractCode(CmbState.Text) + ", district_id=" + db.ExtractCode(CmbDistrict.Text) + ", region_id=" + db.ExtractCode(CmbRegion.Text) + ", sub_name='" + TxtName.Text + "',address='" + TxtAdd.Text + "',city_name='" + TxtCity.Text + "',pin_code='" + TxtPIN.Text + "',email_id='" + TxtEMail.Text + "',contact_no='" + TxtPhone.Text + "',remarks='" + TxtRemarks.Text + "',modified_by='" + GlobalClass.UserName + "', modified_date=sysdate where sub_id=" + LblPK.Text).Split(','); if (res[0].ToString() != "0") { MessageBox.Show("Updation Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } res = db.ExecuteQueries("Update MAS_SUB_PAY_DETAILS set executive_id=" + db.ExtractCode(CmbExecutive.Text) + ", voucher_no='" + TxtVNo.Text.Trim() + "', prev_voucher_no='" + TxtOldVNo.Text.Trim() + "', period_frm='01-" + DtpMnthFrm.Value.ToString("MMM-yyyy") + "', period_to='01-" + DtpMnthTo.Value.ToString("MMM-yyyy") + "', sub_type=" + db.ExtractCode(CmbSubType.Text) + ", Amount=" + TxtAmt.Text + ", sponsor_id=" + db.ExtractCode(CmbSponsor.Text) + ", Quantity=" + TxtQty.Text + ", Modified_by='" + GlobalClass.UserName + "', modified_date=sysdate where sub_id=" + LblPK.Text.Trim() + " and voucher_no='" + TxtVNo.Text.Trim() + "'").Split(','); if (res[0].ToString() != "0") { MessageBox.Show("Updation Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { int sid = db.GetNewID("mas_subscriptions", "sub_id"); res = db.ExecuteQueries("Insert into mas_subscriptions values (" + sid.ToString() + "," + db.ExtractCode(CmbState.Text) + "," + db.ExtractCode(CmbDistrict.Text) + "," + db.ExtractCode(CmbRegion.Text) + ",'" + TxtName.Text + "','" + TxtAdd.Text + "','" + TxtCity.Text + "','" + TxtPIN.Text + "','" + TxtEMail.Text + "','" + TxtPhone.Text + "','" + TxtRemarks.Text + "','" + GlobalClass.UserName + "',sysdate, null, null, 'I')").Split(','); if (res[0].ToString() != "0") { MessageBox.Show("Insertion Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } res = db.ExecuteQueries("Insert into mas_sub_pay_details values (" + db.GetNewID("mas_sub_pay_details", "pay_id") + "," + sid.ToString() + "," + db.ExtractCode(CmbExecutive.Text) + ", '" + TxtVNo.Text.Trim() + "','" + TxtOldVNo.Text.Trim() + "','01-" + DtpMnthFrm.Value.ToString("MMM-yyyy") + "','01-" + DtpMnthTo.Value.ToString("MMM-yyyy") + "'," + db.ExtractCode(CmbSubType.Text) + "," + TxtAmt.Text + "," + db.ExtractCode(CmbSponsor.Text) + "," + TxtQty.Text + ",null,'" + GlobalClass.UserName + "', sysdate, null, null, 'I')").Split(','); if (res[0].ToString() != "0") { MessageBox.Show("Insertion Failure..\n" + res[1].ToString(), "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Error); db.ExecuteQueries("Delete from mas_subscriptions where sub_id=" + sid.ToString()); return; } } MessageBox.Show("Successfully Saved", "Hindudharmam Magazine", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtName.Text = ""; TxtAdd.Text = ""; TxtCity.Text = ""; TxtEMail.Text = ""; TxtPhone.Text = ""; TxtPIN.Text = ""; TxtRemarks.Text = ""; TxtVNo.Text = vouchernumber(); TxtVNo.Focus(); TxtOldVNo.Text = ""; LblPK.Text = ""; DtpMnthFrm.Enabled = true; CmbSponsor.SelectedIndex = 0; DtpMnthFrm.MinDate = Convert.ToDateTime("01-" + DateTime.Now.ToString("MMM-yyyy")); DtpMnthFrm.Value = Convert.ToDateTime("01-" + DateTime.Now.ToString("MMM-yyyy")); TxtQty.Text = "1"; db.TxtAutoFill(TxtCity, "mas_subscriptions", "city_name"); db.TxtAutoFill(TxtPIN, "mas_subscriptions", "PIN_CODE"); db.TxtAutoFill(TxtOldVNo, "mas_sub_pay_details", "voucher_no"); }