private void btnAddData_Click(object sender, EventArgs e) { bool checkvalidate = validation(); string performDate = DateTime.Now.ToString("yyyy-MM-dd"); if (checkvalidate == false) return; DailyAnnaDanamModel dailyAnna = new DailyAnnaDanamModel { Name = txtName.Text, PhoneNumber = txtPhoneNumber.Text, Gothram = txtGothram.Text, VillageName = txtVillageName.Text, DonatedDate = performDate }; TokenPrint oTokenPrint = new TokenPrint { Name = txtName.Text, PhoneNumber = txtPhoneNumber.Text, Gothram = txtGothram.Text, VillageName = txtVillageName.Text, DonatedDate = performDate, ServiceType="Nithya Annadanam" }; lstTokenPrint.Add(oTokenPrint); 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); } string strInsertStatus = dailyAnnaRepo.insertDonorInformation(dailyAnna); var bindServiceType = serviceTypeRepo.GetAllAsQuerable(10); List<int> serviceTypeValue = bindServiceType.Select(p => p.Cost).ToList(); string smsMessage = "Thanks " + dailyAnna.Name + " we have recieved an amount of Rs." + serviceTypeValue[0] + "/- towards Daily Annadanam"; if (strInsertStatus == "Success") { MessageBox.Show("Data inserted successfully."); oPrintHelper.PrintTokens(lstTokenPrint, this, _PrinterName, _ShowPrintPreview); CleareAllcontrolsRecursive(); loadGothramAutoComplete(); SMSHelper smsHelp = new SMSHelper(); smsHelp.sendSMS("91" + dailyAnna.PhoneNumber, smsMessage); //this.Close(); } }
/// <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> /// <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); } }