private void btnSubmit_Click(object sender, EventArgs e) { int tId = 0; int.TryParse(txtId.Text, out tId); double amt = 0; amt = Convert.ToDouble(txtTotalCost.Text); var tokenDAO = new TokenDao(); if (tId == 0) { sdailyNumber = tokenDAO.getHighestDailyNumber(serviceId) + 1; dailyNumber = tokenDAO.getMaxDailyNumber(DateTime.Now) + 1; } var tokenObj = new Token { Id = tId, ServiceId = serviceId, Quantity = 1, TotalCost = amt, ServicePerformDate = Convert.ToDateTime(dtpPerformDate.Value), Status = 1, ServiceDailyNumber = sdailyNumber, DailyNumber = dailyNumber, CreatedOn = DateTime.Now, CreatedBy = App.LoggedInEmployee.Id }; tokenDAO.SaveToken(tokenObj); ShowHundials(); }
private void btnSubmit_Click(object sender, EventArgs e) { int devoteeRows = Convert.ToInt32(cmbQty.Text); //MessageBox.Show(devoteeRows.ToString()); if (sType == 2 || sType == 11 || sType == 15) { //get Devotees and store. Store Single Token. var savedTokens = new List<Token>(); long tokenId = 0; //get Devotees and store. Store Multiple Tokens and print MUltiple Tokens. int serviceId = 0; if (sId == 0) { serviceId = sId; } var tokenDAO = new TokenDao(); int devoteeId = 0; int prefixID = 1; String devoteeName = ""; String devoteeGothram = ""; String devoteeAdditionalNames = ""; String devoteeAdditionalGothrams = ""; if (cmbTransactionType.Text != "Cash" && txtTransactionID.Text == "") { MessageBox.Show("Please enter Transaction ID of your Transaction"); goto Exitlabel; } for (int i = 0; i < 1; i++) { if (i == 0) { prefixID = Convert.ToInt32(dgvDevotees.Rows[i].Cells[1].Value.ToString()); devoteeId = Convert.ToInt32(dgvDevotees.Rows[i].Cells[0].Value.ToString()); devoteeName = dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeGothram = dgvDevotees.Rows[i].Cells[3].Value.ToString(); } else { devoteeAdditionalNames = devoteeAdditionalNames + "," + dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeAdditionalGothrams = devoteeAdditionalGothrams + "," + dgvDevotees.Rows[i].Cells[3].Value.ToString(); } } if (devoteeId == 0) { var devoteeObj = new Devotee { DevoteeName = devoteeName, Prefix = prefixID, Gothram = devoteeGothram, DoorNumber = txtDoorNumber.Text, AreaName = txtAreaName.Text, City = txtCity.Text, MandalName = txtMandalName.Text, DistrictName = txtDistrictName.Text, StateName = txtStateName.Text, PhoneNumber = txtPhoneNumber.Text, AdditionalNames = devoteeAdditionalNames, AdditionalGothrams = devoteeAdditionalGothrams, OtherDetails = txtOtherDetails.Text }; var devoteeDao = new DevoteesDao(); devoteeId = devoteeDao.Save(devoteeObj); // MessageBox.Show(devoteeId.ToString()); } long sdailyNumber = tokenDAO.getHighestDailyNumber(sId) + 1; long dailyNumber = tokenDAO.getMaxDailyNumber(DateTime.Now) + 1; var tokenObj = new Token { ServiceId = sId, DevoteeId = devoteeId, Quantity = Convert.ToInt32(cmbQty.Text), TotalCost = Convert.ToDouble(txtTotalAmount.Text), ServicePerformDate = Convert.ToDateTime(dtpPerformDate.Value), Status = 1, ServiceDailyNumber = sdailyNumber, DailyNumber = dailyNumber, CreatedOn = DateTime.Now, CreatedBy = App.LoggedInEmployee.Id, TransactionType = cmbTransactionType.Text, TransactionID = txtTransactionID.Text, TransactionDate = Convert.ToDateTime(dtpDDChecqueDate.Value) }; tokenId = tokenDAO.SaveToken(tokenObj); // MessageBox.Show(tokenId.ToString()); tokenObj = tokenDAO.getTokenById(tokenId); savedTokens.Add(tokenObj); if (sType == 2) { var sdDao = new StockDetailsDao(); int stockVal = Convert.ToInt32(cmbQty.Text); // int CurrStock = sdDao.getStockByServiceId(sId); // stockVal = stockVal - CurrStock; sdDao.UpdateStockDetail(stockVal, sId); } PrintTokens(savedTokens); Exitlabel: { } } else if (sType == 9) { //get Devotees and store. Store Single Token. var savedTokens = new List<Token>(); long tokenId = 0; //get Devotees and store. Store Multiple Tokens and print MUltiple Tokens. int serviceId = 0; if (sId == 0) { serviceId = sId; } /* if (cmbTimeId.Text == "" || cmbTimeId.Text == null) { MessageBox.Show("Free Annadanam Timings completed for Today. Sorry for the Inconvenience."); goto Exitlabel; } if (cmbTransactionType.Text != "Cash" && txtTransactionID.Text == "") { MessageBox.Show("Please enter Transaction ID of your Transaction"); goto Exitlabel; } int timeIdValue = (cmbTimeId.SelectedItem as Timing).Id; */ int timeIdValue = 1; //int TimeValId = 0; //String TimeValName = ""; int TimeValCount = 0; //int dgvTimingsRows = App.DayMaxSlots; //for (int i = 0; i < dgvTimingsRows; i++) { int i = timeIdValue - 1; String i2Val; if (dgvTimings.Rows[i].Cells[2].Value.ToString() != null) { i2Val = Convert.ToString(dgvTimings.Rows[i].Cells[2].Value.ToString()); } else { i2Val = "0"; } TimeValCount = Convert.ToInt32(i2Val); /* if ((Convert.ToInt32(cmbQty.Text) + TimeValCount) > App.SlotMaxVal) { MessageBox.Show("Slot is not Available for the specified Quantity. Please select another Slot."); goto Exitlabel; } */ } var tokenDAO = new TokenDao(); int devoteeId = 0; int prefixID = 1; String devoteeName = ""; String devoteeGothram = ""; String devoteeAdditionalNames = ""; String devoteeAdditionalGothrams = ""; for (int i = 0; i < devoteeRows; i++) { if (i == 0) { prefixID = Convert.ToInt32(dgvDevotees.Rows[i].Cells[1].Value.ToString()); devoteeId = Convert.ToInt32(dgvDevotees.Rows[i].Cells[0].Value.ToString()); devoteeName = Convert.ToString(dgvDevotees.Rows[i].Cells[2].Value.ToString()); devoteeGothram = Convert.ToString(dgvDevotees.Rows[i].Cells[3].Value.ToString()); } else { devoteeAdditionalNames = Convert.ToString(devoteeAdditionalNames) + "," + Convert.ToString(dgvDevotees.Rows[i].Cells[2].Value.ToString()); devoteeAdditionalGothrams = Convert.ToString(devoteeAdditionalGothrams) + "," + Convert.ToString(dgvDevotees.Rows[i].Cells[3].Value.ToString()); } } if (prefixID <= 0) { MessageBox.Show("Please Select Prefix", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (devoteeName == "") { MessageBox.Show("Please Enter Devotee Name", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (devoteeId == 0) { var devoteeObj = new Devotee { DevoteeName = devoteeName, Prefix = prefixID, Gothram = devoteeGothram, DoorNumber = txtDoorNumber.Text, AreaName = txtAreaName.Text, City = txtCity.Text, MandalName = txtMandalName.Text, DistrictName = txtDistrictName.Text, StateName = txtStateName.Text, PhoneNumber = txtPhoneNumber.Text, AdditionalNames = devoteeAdditionalNames, AdditionalGothrams = devoteeAdditionalGothrams, OtherDetails = txtOtherDetails.Text }; var devoteeDao = new DevoteesDao(); devoteeId = devoteeDao.Save(devoteeObj); // MessageBox.Show(devoteeId.ToString()); } long sdailyNumber = tokenDAO.getHighestDailyNumber(sId) + 1; long dailyNumber = tokenDAO.getMaxDailyNumber(DateTime.Now) + 1; var tokenObj = new Token { ServiceId = sId, DevoteeId = devoteeId, Quantity = Convert.ToInt32(cmbQty.Text), TotalCost = 0, ServicePerformDate = Convert.ToDateTime(dtpPerformDate.Value), Status = 1, ServiceDailyNumber = sdailyNumber, DailyNumber = dailyNumber, CreatedOn = DateTime.Now, CreatedBy = App.LoggedInEmployee.Id, TimeId = timeIdValue, TransactionType = cmbTransactionType.Text }; tokenId = tokenDAO.SaveToken(tokenObj); // MessageBox.Show(tokenId.ToString()); tokenObj = tokenDAO.getTokenById(tokenId); savedTokens.Add(tokenObj); PrintTokens(savedTokens); } Exitlabel: { } //get Devotees and store. Store Multiple Tokens and print First Person name only. } else if (sType == 10) { //get Devotees and store in Additional Persons and Additional Gothrams. Store Single Token. var savedTokens = new List<Token>(); long tokenId = 0; //get Devotees and store. Store Multiple Tokens and print MUltiple Tokens. int serviceId = 0; if (sId == 0) { serviceId = sId; } var tokenDAO = new TokenDao(); int devoteeId = 0; int prefixID = 1; String devoteeName = ""; String devoteeGothram = ""; String devoteeAdditionalNames = ""; String devoteeAdditionalGothrams = ""; for (int i = 0; i < devoteeRows; i++) { if (i == 0) { prefixID = Convert.ToInt32(dgvDevotees.Rows[i].Cells[1].Value.ToString()); devoteeId = Convert.ToInt32(dgvDevotees.Rows[i].Cells[0].Value.ToString()); devoteeName = dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeGothram = dgvDevotees.Rows[i].Cells[3].Value.ToString(); } else { devoteeAdditionalNames = devoteeAdditionalNames + "," + dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeAdditionalGothrams = devoteeAdditionalGothrams + "," + dgvDevotees.Rows[i].Cells[3].Value.ToString(); } } if (cmbTransactionType.Text != "Cash" && txtTransactionID.Text == "") { MessageBox.Show("Please enter Transaction ID of your Transaction"); goto Exitlabel; } if (prefixID <= 0) { MessageBox.Show("Please Select Prefix", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (devoteeName == "") { MessageBox.Show("Please Enter Devotee Name", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (devoteeId == 0) { var devoteeObj = new Devotee { DevoteeName = devoteeName, Prefix = prefixID, Gothram = devoteeGothram, DoorNumber = txtDoorNumber.Text, AreaName = txtAreaName.Text, City = txtCity.Text, MandalName = txtMandalName.Text, DistrictName = txtDistrictName.Text, StateName = txtStateName.Text, PhoneNumber = txtPhoneNumber.Text, AdditionalNames = devoteeAdditionalNames, AdditionalGothrams = devoteeAdditionalGothrams, OtherDetails = txtOtherDetails.Text }; var devoteeDao = new DevoteesDao(); devoteeId = devoteeDao.Save(devoteeObj); // MessageBox.Show(devoteeId.ToString()); } double scCost = 0; if (sCost == 0) { scCost = Convert.ToDouble(txtTotalAmount.Text); } else { scCost = sCost; } long sdailyNumber = tokenDAO.getHighestDailyNumber(sId) + 1; long dailyNumber = tokenDAO.getMaxDailyNumber(DateTime.Now) + 1; var tokenObj = new Token { ServiceId = sId, DevoteeId = devoteeId, Quantity = Convert.ToInt32(cmbQty.Text), TotalCost = scCost, //Convert.ToDouble(txtTotalAmount.Text) sCost ServicePerformDate = Convert.ToDateTime(dtpPerformDate.Value), Status = 1, ServiceDailyNumber = sdailyNumber, DailyNumber = dailyNumber, CreatedOn = DateTime.Now, CreatedBy = App.LoggedInEmployee.Id, TransactionType = cmbTransactionType.Text }; tokenId = tokenDAO.SaveToken(tokenObj); // MessageBox.Show(tokenId.ToString()); tokenObj = tokenDAO.getTokenById(tokenId); savedTokens.Add(tokenObj); PrintTokens(savedTokens); } Exitlabel: { } } else if (sType == 1 || sType == 3 || sType == 4 || sType == 5 || sType == 6 || sType == 7 || sType == 8 || sType == 12) { { var savedTokens = new List<Token>(); long tokenId = 0; //get Devotees and store. Store Multiple Tokens and print MUltiple Tokens. int serviceId = 0; if (sId == 0) { serviceId = sId; } var tokenDAO = new TokenDao(); int devoteeId = 0; int prefixID = 1; String devoteeName = ""; String devoteeGothram = ""; if (cmbTransactionType.Text != "Cash" && txtTransactionID.Text == "") { MessageBox.Show("Please enter Transaction ID or DD/Cheque Number of your Transaction"); goto Exitlabel; } int dVal = 1; if (sId != 1) { for (int i = 0; i < devoteeRows; i++) { devoteeId = 0; devoteeId = Convert.ToInt32(dgvDevotees.Rows[i].Cells[0].Value.ToString()); devoteeName = dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeGothram = dgvDevotees.Rows[i].Cells[3].Value.ToString(); prefixID = Convert.ToInt32(dgvDevotees.Rows[i].Cells[1].Value.ToString()); if (prefixID <= 0) { MessageBox.Show("Please Select Prefix", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); dVal = 0; dgvDevotees.Rows[i].Cells[1].Selected = true; break; } else if (devoteeName == "") { MessageBox.Show("Please Enter Devotee Name", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); dVal = 0; dgvDevotees.Rows[i].Cells[2].Selected = true; break; } else if (devoteeGothram == "") { MessageBox.Show("Please Enter Devotee Gothram", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); dVal = 0; dgvDevotees.Rows[i].Cells[3].Selected = true; break; } } if (sType == 4) { if (txtPhoneNumber.Text == "") { MessageBox.Show("Please Enter Phone Number", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); dVal = 0; } else if (txtCity.Text == "") { MessageBox.Show("Please Enter City or Village", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); dVal = 0; } } } else { dVal = 1; } if (dVal == 1) { for (int i = 0; i < devoteeRows; i++) { devoteeId = 0; devoteeId = Convert.ToInt32(dgvDevotees.Rows[i].Cells[0].Value.ToString()); devoteeName = dgvDevotees.Rows[i].Cells[2].Value.ToString(); devoteeGothram = dgvDevotees.Rows[i].Cells[3].Value.ToString(); prefixID = Convert.ToInt32(dgvDevotees.Rows[i].Cells[1].Value.ToString()); if (devoteeId == 0) { //prefixID = int.TryParse(dgvDevotees.Rows[i].Cells[1].Value.ToString(), out prefixId); var devoteeObj = new Devotee { DevoteeName = dgvDevotees.Rows[i].Cells[2].Value.ToString(), Prefix = prefixID, Gothram = dgvDevotees.Rows[i].Cells[3].Value.ToString(), DoorNumber = txtDoorNumber.Text, AreaName = txtAreaName.Text, City = txtCity.Text, MandalName = txtMandalName.Text, DistrictName = txtDistrictName.Text, StateName = txtStateName.Text, PhoneNumber = txtPhoneNumber.Text, OtherDetails = txtOtherDetails.Text }; var devoteeDao = new DevoteesDao(); devoteeId = devoteeDao.Save(devoteeObj); // MessageBox.Show(devoteeId.ToString()); } double scCost = 0; if (sCost == 0) { scCost = Convert.ToDouble(txtTotalAmount.Text); } else { scCost = sCost; } long sdailyNumber = tokenDAO.getHighestDailyNumber(sId) + 1; long dailyNumber = tokenDAO.getMaxDailyNumber(DateTime.Now) + 1; var tokenObj = new Token { ServiceId = sId, DevoteeId = devoteeId, Quantity = 1, TotalCost = scCost, //Convert.ToDouble(txtTotalAmount.Text) sCost ServicePerformDate = Convert.ToDateTime(dtpPerformDate.Value), Status = 1, ServiceDailyNumber = sdailyNumber, DailyNumber = dailyNumber, CreatedOn = DateTime.Now, CreatedBy = App.LoggedInEmployee.Id, TransactionType = cmbTransactionType.Text }; tokenId = tokenDAO.SaveToken(tokenObj); // MessageBox.Show(tokenId.ToString()); tokenObj = tokenDAO.getTokenById(tokenId); savedTokens.Add(tokenObj); } PrintTokens(savedTokens); } else { MessageBox.Show("Please Enter Devotee Details", "Error Occured !", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Exitlabel: { } } //(btnPooja + sId).Focus(); FocusOnBtn(clickedButtonName, 1); }