/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { btnUpdate.Visible = true; btnCancel.Visible = true; btnAdd.Visible = false; btnModify.Visible = false; DateTime donorDate; string performDate = string.Empty; donorDate = Convert.ToDateTime(dtpDate.Text); if (dtpEnglishDateType.Enabled == true) performDate = dtpEnglishDateType.Value.ToString("dd-MM"); else performDate = ""; int selectedServiceTypeId; int selectedServiceNameId; int selectedMonthId; int selectedStarId; int selectedSpecialDayId; int selectedThithiId; int selectedDayId; int selectedDonorThithi; var selectedDateTypeId = SelectedDateTypeId(out selectedServiceTypeId, out selectedServiceNameId, out selectedMonthId, out selectedStarId, out selectedSpecialDayId, out selectedThithiId, out selectedDayId, out selectedDonorThithi); if (cmbServiceName.Enabled == false) selectedServiceNameId = 0; if (cmbMonth.Enabled == false) selectedMonthId = 0; if (cmbSpecialDay.Enabled == false) selectedSpecialDayId = 0; if (cmbThithi.Enabled == false) selectedThithiId = 0; if (cmbMonthlyAnna.Enabled == false) selectedDayId = 0; if (cmbMonthyAnnaThithi.Enabled == false) selectedDonorThithi = 0; Donors donorUpdateInfo = new Donors { Id = txtDonorId.Text, Donordate = donorDate, Address = txtAddress.Text, Surname = txtSurname.Text, DonorName = txtName.Text, DistrictName = txtDistrict.Text, City = txtCity.Text, Pin = txtPin.Text, State = txtState.Text, Country = txtCountry.Text, NameOn = txtNameOn.Text, Star = selectedStarId, Occassion = txtOccassion.Text, Gothram = txtGothram.Text, Amount = Convert.ToDecimal(txtAmount.Text), MR_No = txtMRNo.Text, Remarks = txtRemarks.Text, Landline = txtLandline.Text, SpecialDayId = selectedSpecialDayId, ServiceTypeId = selectedServiceTypeId, ServiceNameId = selectedServiceNameId, DateTypeId = selectedDateTypeId, PerformDate = performDate, EmailId = txtEmailId.Text, DonorMonth = selectedMonthId, Thidhi = selectedThithiId, DonorDay = selectedDayId, Mobile = txtMobile.Text, DonorThithi = selectedDonorThithi }; string updateStatus = donorRepo.updateDonorInformation(donorUpdateInfo); if (updateStatus == "Success") { MessageBox.Show("Data updated successfully."); CleareAllcontrolsRecursive(); btnAdd.Visible = true; btnModify.Visible = true; } else MessageBox.Show("There was a problem in updating your data, kindly try again."); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { bool checkvalidate = validation(); if (checkvalidate == false) return; string performDate = string.Empty; DateTime donorDate; try { donorDate = Convert.ToDateTime(dtpDate.Text); if (dtpEnglishDateType.Enabled == true) performDate = dtpEnglishDateType.Value.ToString("dd-MM"); else performDate = ""; if ((txtPin.Text == "") || (txtPin.Text == string.Empty)) txtPin.Text = null; if ((txtLandline.Text == "") || (txtLandline.Text == string.Empty)) txtLandline.Text = null; if ((txtMobile.Text == "") || (txtMobile.Text == string.Empty)) txtMobile.Text = null; int selectedServiceTypeId; int selectedServiceNameId; int selectedMonthId; int selectedStarId; int selectedSpecialDayId; int selectedThithiId; int selectedDayId; int selectedDonorThithi; var selectedDateTypeId = SelectedDateTypeId(out selectedServiceTypeId, out selectedServiceNameId, out selectedMonthId, out selectedStarId, out selectedSpecialDayId, out selectedThithiId, out selectedDayId, out selectedDonorThithi); string maxIDFormat = DateForId(donorDate); #region AutoGenerate Id var maxDonorId = donorRepo.getMaxIdFromDonor(maxIDFormat); int maxId = 0; //date = date.ToString("yyyy/mm/dd"); if (maxDonorId.Tables[0].Rows.Count > 0) { string Id = maxDonorId.Tables[0].Rows[0]["donroId"].ToString(); maxId = Convert.ToInt32(Id) + 1; } else maxId = 1; string uniqueDonorId = DateForId(donorDate) + " " + maxId; #endregion if (cmbServiceName.Enabled == false) selectedServiceNameId = 0; if (cmbMonth.Enabled == false) selectedMonthId = 0; if (cmbSpecialDay.Enabled == false) selectedSpecialDayId = 0; if (cmbThithi.Enabled == false) selectedThithiId = 0; if (cmbMonthlyAnna.Enabled == false) selectedDayId = 0; if (cmbMonthyAnnaThithi.Enabled == false) selectedDonorThithi = 0; Donors donorInfo = new Donors { Id = uniqueDonorId, Donordate = donorDate, Address = txtAddress.Text, Surname = txtSurname.Text, DonorName = txtName.Text, DistrictName = txtDistrict.Text, City = txtCity.Text, Pin = txtPin.Text, State = txtState.Text, Country = txtCountry.Text, NameOn = txtNameOn.Text, Star = selectedStarId, Occassion = txtOccassion.Text, Gothram = txtGothram.Text, Amount = Convert.ToDecimal(txtAmount.Text), MR_No = txtMRNo.Text, Remarks = txtRemarks.Text, Landline = txtLandline.Text, SpecialDayId = selectedSpecialDayId, ServiceTypeId = selectedServiceTypeId, ServiceNameId = selectedServiceNameId, DateTypeId = selectedDateTypeId, PerformDate = performDate, EmailId = txtEmailId.Text, DonorMonth = selectedMonthId, Thidhi = selectedThithiId, DonorDay = selectedDayId, Mobile = txtMobile.Text, DonorThithi = selectedDonorThithi }; string performDate_ForPrint = string.Empty; var selectedServiceType = cmbServiceType.SelectedItem as ServiceTypes; TokenPrint oTokenPrint = new TokenPrint { Id = txtMRNo.Text, Name = txtNameOn.Text, PhoneNumber = txtMobile.Text, Gothram = txtGothram.Text, VillageName = txtCity.Text, ServiceType = selectedServiceType.Name, Cost = Convert.ToDouble(txtAmount.Text) }; //check if gothra exists var checkIfExists = gothramRepo.checkIfGothramExists(txtGothram.Text); //If Gothra doesn't exist and if user has entered a Gothram if (checkIfExists == null && txtGothram.Text != string.Empty) { string insrtGothra = gothramRepo.insertNewGothraName(txtGothram.Text); } //Insert the Donor Information string strInsertStatus = donorRepo.insertDonorInformation(donorInfo); //var selectedServiceType = cmbServiceType.SelectedItem as ServiceTypes; string smsMessage = "Thanks " + donorInfo.NameOn + " we have recieved an amount of Rs." + donorInfo.Amount + "/- towards " + selectedServiceType.Name; if (strInsertStatus == "Success") { MessageBox.Show("Data inserted successfully."); CleareAllcontrolsRecursive(); loadGothramAutoComplete(); SMSHelper smshelper = new SMSHelper(); smshelper.sendSMS("91" + donorInfo.Mobile, smsMessage); PrintHelper oPrintHelper = new PrintHelper(); lstTokenPrint.Add(oTokenPrint); oPrintHelper.PrintTokens(lstTokenPrint, this, ConfigurationManager.AppSettings["PrinterName"].ToString(), Convert.ToBoolean(ConfigurationManager.AppSettings["ShowPrintPreview"])); } else MessageBox.Show("There was a problem inserting data, kindly try again to save the record"); } catch (Exception ex) { MessageBox.Show("There was a problem inserting data, kindly try again to save the record"); } }
/// <summary> /// /// </summary> public void getDataFromChildWindow(Donors donor) { if (donor != null) { DateTime dt; txtDonorId.Text = donor.Id.ToString(); if (!DateTime.TryParse(donor.Donordate.ToString(), out dt)) { dtpDate.Value = dt; } txtAddress.Text = donor.Address; txtSurname.Text = donor.Surname; txtName.Text = donor.DonorName; txtDistrict.Text = donor.DistrictName; txtCity.Text = donor.City; txtPin.Text = donor.Pin; txtState.Text = donor.State; txtCountry.Text = donor.Country; txtNameOn.Text = donor.NameOn; txtNameOn.Enabled = false; //Get Star Info var bindStarName = starRepo.GetAllAsQuerable(donor.Star); string[] starNameValue = bindStarName.Select(p => p.Name).ToArray(); cmbStar.SelectedIndex = cmbStar.FindString(starNameValue[0]); txtOccassion.Text = donor.Occassion; txtGothram.Text = donor.Gothram; txtAmount.Text = donor.Amount.ToString(); txtAmount.Enabled = false; txtMRNo.Text = donor.MR_No.ToString(); txtMRNo.Enabled = false; txtRemarks.Text = donor.Remarks; txtLandline.Text = donor.Landline; txtMobile.Text = donor.Mobile; txtEmailId.Text = donor.EmailId; //Get ServiceType var bindServiceType = serviceTypeRepo.GetAllAsQuerable(donor.ServiceTypeId); string[] starTypeValue = bindServiceType.Select(p => p.Name).ToArray(); cmbServiceType.SelectedIndex = cmbServiceType.FindString(starTypeValue[0]); //Get ServiceName if (cmbServiceName.Enabled == true) { var bindServiceName = serviceNameRepo.GetAllAsQuerable(donor.ServiceNameId); string[] serviceNameValue = bindServiceName.Select(p => p.Name).ToArray(); cmbServiceName.SelectedIndex = cmbServiceName.FindString(serviceNameValue[0]); } //Get DateType if (cmbDateType.Enabled == true) { var bindDatetype = datetypeRepo.GetAllAsQuerable(donor.DateTypeId); string[] dateTypeValue = bindDatetype.Select(p => p.Name).ToArray(); cmbDateType.SelectedIndex = cmbDateType.FindString(dateTypeValue[0]); } //Get SpecialDay if (cmbSpecialDay.Enabled == true) { var bindSpecialDay = specialDayRepo.GetAllAsQuerable(donor.SpecialDayId); string[] specialDayValue = bindSpecialDay.Select(p => p.Name).ToArray(); cmbSpecialDay.SelectedIndex = cmbSpecialDay.FindString(specialDayValue[0]); } //Get Month if (cmbMonth.Enabled == true) { var bindMonth = monthsRepo.GetAllAsQuerable(donor.DonorMonth); string[] monthValue = bindMonth.Select(p => p.Name).ToArray(); cmbMonth.SelectedIndex = cmbMonth.FindString(monthValue[0]); } //Get Thithi if (cmbThithi.Enabled == true) { var bindThithi = thithiRepo.GetAllAsQuerable(donor.Thidhi); string[] thithiValue = bindThithi.Select(p => p.Name).ToArray(); cmbThithi.SelectedIndex = cmbThithi.FindString(thithiValue[0]); } //Perform Date if (donor.PerformDate != null) { var performDate = donor.PerformDate.ToString(); var perforDateArr = performDate.Split('-'); DateTime dt1 = new DateTime(); int date; int month; int year; if (perforDateArr.Length > 0) { var performDateWithoutMonthAndYear = int.TryParse(perforDateArr[0], out date); var performDayWithoutYearAbdDate = int.TryParse(perforDateArr[1], out month); year = DateTime.Now.Year; dt1 = new DateTime(year, month, date); } dtpEnglishDateType.Value = dt1; } else { dtpEnglishDateType.Visible = false; dtpEnglishDateType.Enabled = false; } //Monthly AnnaDanam if (donor.DonorDay != 0) { rbdEnglish.Visible = true; rbdTelugu.Visible = true; rbdEnglish.Checked = true; var bindDonorDay = monthlyAnnaRepo.GetAllAsQuerable(donor.DonorDay); string[] donorDayValue = bindDonorDay.Select(p => p.Day).ToArray(); cmbMonthlyAnna.SelectedIndex = cmbMonthlyAnna.FindString(donorDayValue[0]); } else if (donor.DonorThithi != 0) { rbdEnglish.Visible = true; rbdTelugu.Visible = true; rbdTelugu.Checked = true; var bindDonorThithi = thithiRepo.GetAllAsQuerable(donor.DonorThithi); string[] donorthithiValue = bindDonorThithi.Select(p => p.Name).ToArray(); cmbMonthyAnnaThithi.SelectedIndex = cmbMonthyAnnaThithi.FindString(donorthithiValue[0]); } } }
public void getDataFromChildWindow(Donors donor) { oDonationInfo.getDataFromChildWindow(donor); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { bool checkvalidate = validation(); if (checkvalidate == false) return; string performDate = string.Empty; DateTime donorDate; string transactionDate = string.Empty; try { donorDate = Convert.ToDateTime(dtpDate.Text); if (dtpEnglishDateType.Enabled == true) performDate = dtpEnglishDateType.Value.ToString("dd-MM"); else performDate = ""; if (cmbTransactionDate.Enabled == true) transactionDate = cmbTransactionDate.Value.ToString("dd-MM-yyyy"); else transactionDate = ""; if ((txtTransaction.Text == "") || (txtTransaction.Text == string.Empty)) txtTransaction.Text = null; if ((txtPin.Text == "") || (txtPin.Text == string.Empty)) txtPin.Text = null; if ((txtLandline.Text == "") || (txtLandline.Text == string.Empty)) txtLandline.Text = null; if ((txtMobile.Text == "") || (txtMobile.Text == string.Empty)) txtMobile.Text = null; if ((txtTransaction.Text == "") || (txtTransaction.Text == string.Empty)) txtTransaction.Text = null; if ((txtMandal.Text == "") || (txtMandal.Text == string.Empty)) txtMandal.Text = null; int selectedServiceTypeId; int selectedServiceNameId; int selectedMonthId; int selectedStarId; int selectedSpecialDayId; int selectedThithiId; int selectedDayId; int selectedDonorThithi; int selectedTransactionTypeId; var selectedDateTypeId = SelectedDateTypeId(out selectedServiceTypeId, out selectedServiceNameId, out selectedMonthId, out selectedStarId, out selectedSpecialDayId, out selectedThithiId, out selectedDayId, out selectedDonorThithi, out selectedTransactionTypeId); string maxIDFormat = DateForId(donorDate); #region AutoGenerate Id var maxDonorId = donorRepo.getMaxIdFromDonor(maxIDFormat); int maxId = 0; //date = date.ToString("yyyy/mm/dd"); if (maxDonorId.Tables[0].Rows.Count > 0) { string Id = maxDonorId.Tables[0].Rows[0]["donroId"].ToString(); maxId = Convert.ToInt32(Id) + 1; } else maxId = 1; string uniqueDonorId = DateForId(donorDate) + " " + maxId; #endregion #region AutoGenerate MRNo var fetchMRNO = donorRepo.getMaxMRNoFromDonor(); int maxMRNO = 0; //date = date.ToString("yyyy/mm/dd"); if (fetchMRNO.Tables[0].Rows.Count > 0) { int Id = Convert.ToInt32(fetchMRNO.Tables[0].Rows[0]["donroMRNo"]); if (Id == 0) maxMRNO = 15001; else maxMRNO = Id + 1; } //} //else // maxId = 15000; string uniqueMRNo = Convert.ToString(maxMRNO); #endregion if (cmbServiceName.Enabled == false) selectedServiceNameId = 0; if (cmbMonth.Enabled == false) selectedMonthId = 0; if (cmbSpecialDay.Enabled == false) selectedSpecialDayId = 0; if (cmbThithi.Enabled == false) selectedThithiId = 0; if (cmbMonthlyAnna.Enabled == false) selectedDayId = 0; if (cmbMonthyAnnaThithi.Enabled == false) selectedDonorThithi = 0; var nameonPrefix = cmbNameOnPrefix.SelectedItem as Prefixes; var namePrefix = cmbNamePrefix.SelectedItem as Prefixes; Donors donorInfo = new Donors { Id = uniqueDonorId, Donordate = donorDate, Prefix_Name = namePrefix.Id, DonorName = txtName.Text, DistrictName = txtDistrict.Text, City = txtCity.Text, Pin = txtPin.Text, State = txtState.Text, Prefix_NameOn = nameonPrefix.Id, NameOn = txtNameOn.Text, Star = selectedStarId, TransactionTypeId = selectedTransactionTypeId, TransactionId = txtTransaction.Text, TransactionDate = transactionDate, Occasion = txtPurpose.Text, Gothram = txtGothram.Text, MR_No = uniqueMRNo, Amount = Convert.ToDecimal(txtAmount.Text), Landline = txtLandline.Text, SpecialDayId = selectedSpecialDayId, ServiceTypeId = selectedServiceTypeId, ServiceNameId = selectedServiceNameId, DateTypeId = selectedDateTypeId, DoorNo = txtDoorNo.Text, Mandal = txtMandal.Text, PerformDate = performDate, EmailId = txtEmailId.Text, DonorMonth = selectedMonthId, Thidhi = selectedThithiId, DonorDay = selectedDayId, Mobile = txtMobile.Text, DonorThithi = selectedDonorThithi, CreatedBy = ApplicationElements.loggedInEmployee.Id }; string performDate_ForPrint = string.Empty; var selecteddtType = cmbDateType.SelectedItem as DateType; var selectedMonth = cmbMonth.SelectedItem as Months; var selectdThidhi = cmbThithi.SelectedItem as Thidhi; var selectdspDay = cmbSpecialDay.SelectedItem as SpecialDay; var selectedStar = cmbStar.SelectedItem as Stars; if (cmbDateType.Enabled == true) { switch (selecteddtType.Id) { case 1: performDate_ForPrint = selectedMonth.Name + " " + selectdThidhi.Name; break; case 2: performDate_ForPrint = dtpEnglishDateType.Value.ToString("dd-MMM"); break; case 3: performDate_ForPrint = selectdspDay.Name; break; } } var selectedServiceType = cmbServiceType.SelectedItem as ServiceTypes; TokenPrint oTokenPrint = new TokenPrint { Id = uniqueMRNo, Name = txtName.Text, NameOn = txtNameOn.Text, PerformDate = performDate_ForPrint, Star = (selectedStar.Id == 0) ? "" : selectedStar.Name, PhoneNumber = txtMobile.Text, Gothram = txtGothram.Text, VillageName = txtCity.Text, ServiceType = selectedServiceType.Name, Cost = Convert.ToDouble(txtAmount.Text), LoginName = ApplicationElements.loggedInEmployee.LoginId }; //check if gothra exists var checkIfExists = gothramRepo.checkIfGothramExists(txtGothram.Text); //If Gothra doesn't exist and if user has entered a Gothram if (checkIfExists == null && txtGothram.Text != string.Empty) { string insrtGothra = gothramRepo.insertNewGothraName(txtGothram.Text); } //Insert the Donor Information string strInsertStatus = donorRepo.insertDonorInformation(donorInfo); string performDatePrintMsg = string.Empty; if (performDate_ForPrint != "" && performDate_ForPrint != string.Empty) performDatePrintMsg = " to be performed on " + performDate_ForPrint; //var selectedServiceType = cmbServiceType.SelectedItem as ServiceTypes; string smsMessage = "We have received an amount of Rs." + donorInfo.Amount + "/- towards " + selectedServiceType.Name + performDatePrintMsg + " Visit: www.svstemple.com , Call:08856225812 "; if (strInsertStatus == "Success") { MessageBox.Show("Data inserted successfully."); CleareAllcontrolsRecursive(); loadGothramAutoComplete(); loadGothramAutoComplete(); loadStateAutoComplete(); loadCityVillageAutoComplete(); loadMandalAutoComplete(); loadDistrictAutoComplete(); try { SMSHelper smshelper = new SMSHelper(); smshelper.sendSMS("91" + donorInfo.Mobile, smsMessage); } catch (Exception ex) { MessageBox.Show("There was a problem sending SMS to the recipients."); } PrintHelper oPrintHelper = new PrintHelper(); lstTokenPrint.Clear(); lstTokenPrint.Add(oTokenPrint); if (printerName == string.Empty || printerName == "") { MessageBox.Show("Token cannot be printed.... Please install a printer and select.."); } else oPrintHelper.PrintTokens(lstTokenPrint, this, printerName, Convert.ToBoolean(ConfigurationManager.AppSettings["ShowPrintPreview"])); } else MessageBox.Show("There was a problem inserting data, kindly try again to save the record"); } catch (Exception ex) { MessageBox.Show("There was a problem inserting data, kindly try again to save the record " + ex.Message); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { bool checkvalidate = validation(); if (checkvalidate == false) return; btnUpdate.Visible = true; btnCancel.Visible = true; btnAdd.Visible = false; btnModify.Visible = false; DateTime donorDate; string performDate = string.Empty; string transactionDate = string.Empty; donorDate = Convert.ToDateTime(dtpDate.Text); if (dtpEnglishDateType.Enabled == true) performDate = dtpEnglishDateType.Value.ToString("dd-MM"); else performDate = ""; int selectedServiceTypeId; int selectedServiceNameId; int selectedMonthId; int selectedStarId; int selectedSpecialDayId; int selectedThithiId; int selectedDayId; int selectedDonorThithi; int selectedTransactionTypeId; var selectedDateTypeId = SelectedDateTypeId(out selectedServiceTypeId, out selectedServiceNameId, out selectedMonthId, out selectedStarId, out selectedSpecialDayId, out selectedThithiId, out selectedDayId, out selectedDonorThithi, out selectedTransactionTypeId); if (cmbServiceName.Enabled == false) selectedServiceNameId = 0; if (cmbMonth.Enabled == false) selectedMonthId = 0; if (cmbSpecialDay.Enabled == false) selectedSpecialDayId = 0; if (cmbThithi.Enabled == false) selectedThithiId = 0; if (cmbMonthlyAnna.Enabled == false) selectedDayId = 0; if (cmbMonthyAnnaThithi.Enabled == false) selectedDonorThithi = 0; if (cmbTransaction.Enabled == false) selectedTransactionTypeId = 0; var nameonprefix = cmbNameOnPrefix.SelectedItem as Prefixes; var nameprefix = cmbNamePrefix.SelectedItem as Prefixes; Donors donorUpdateInfo = new Donors { Id = txtDonorId.Text, Donordate = donorDate, Prefix_Name = nameprefix.Id, Prefix_NameOn=nameonprefix.Id, DonorName = txtName.Text, DistrictName = txtDistrict.Text, City = txtCity.Text, Pin = txtPin.Text, State = txtState.Text, NameOn = txtNameOn.Text, Star = selectedStarId, MR_No = txtMRNo.Text, TransactionTypeId = selectedTransactionTypeId, TransactionId = txtTransaction.Text, TransactionDate = transactionDate, Occasion = txtPurpose.Text, Gothram = txtGothram.Text, Amount = Convert.ToDecimal(txtAmount.Text), Landline = txtLandline.Text, SpecialDayId = selectedSpecialDayId, ServiceTypeId = selectedServiceTypeId, ServiceNameId = selectedServiceNameId, DateTypeId = selectedDateTypeId, DoorNo = txtDoorNo.Text, Mandal = txtMandal.Text, PerformDate = performDate, EmailId = txtEmailId.Text, DonorMonth = selectedMonthId, Thidhi = selectedThithiId, DonorDay = selectedDayId, Mobile = txtMobile.Text, DonorThithi = selectedDonorThithi, ModifiedBy = ApplicationElements.loggedInEmployee.Id, ModifiedDate = donorDate }; string updateStatus = donorRepo.updateDonorInformation(donorUpdateInfo); if (updateStatus == "Success") { MessageBox.Show("Data updated successfully."); CleareAllcontrolsRecursive(); btnAdd.Visible = true; btnModify.Visible = true; } else MessageBox.Show("There was a problem in updating your data, kindly try again."); }