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(); } }
private string RenderToken(TokenPrint token) { var sb = new StringBuilder(); string line = string.Empty; string purpose = string.Empty; string PerformDate = string.Empty; string DailyNum = string.Empty; string CDate = string.Empty; sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); DailyNum = string.Format("{0}", token.Id).PadRight(_lineWidth / 2); CDate = string.Format("Date : {0:dd/MM/yyyy h:mm tt} ", System.DateTime.Now).PadRight(_lineWidth / 2); line = DailyNum; if (token.Id != string.Empty && token.Id != "") { sb.AppendLine(line); } line = string.Empty; line = CDate; sb.AppendLine(line); line = string.Empty; purpose = string.Format(token.ServiceType).PadLeft(20); // PerformDate = string.Format("Perform Date : {0:dd/MM/yyyy}", token.DonatedDate).PadLeft(_lineWidth / 2); //line = string.Format("{0}", token.Name).PadRight(60); if (purpose != "") { line = line + purpose; } sb.AppendLine(line); if (token.VillageName != "") { line = string.Format("City : {0}", token.VillageName).PadRight(_lineWidth / 2); } line = string.Format("Gotram : {0}", token.Gothram).PadRight(_lineWidth / 2); if (PerformDate != "") { line = line + PerformDate; } sb.AppendLine(line); line = ""; // int totalCost = 116; line = line + string.Format("Amt : {0:F} ", token.Cost).PadLeft(_lineWidth); sb.AppendLine(line); sb.AppendLine(); sb.AppendLine(); return(sb.ToString()); }