//Clear all the fiels private void clearfields() { TxtName.Clear(); TxtPhone.Clear(); TxtAdd.Clear(); TxtCity.Clear(); TxtSuburb.Clear(); }
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"); }