Esempio n. 1
0
 public DailyAnnadanam(string PrinterName,bool ShowPrintPreview)
 {
     this.MaximizeBox = false;
     dailyAnnaRepo = new DailyAnnaDanamRepository();
     gothramRepo = new GothramsRepository();
     serviceTypeRepo = new ServiceTypeRepository();
     oPrintHelper = new PrintHelper();
     lstTokenPrint = new List<TokenPrint>();
     _PrinterName = PrinterName;
     _ShowPrintPreview = ShowPrintPreview;
     InitializeComponent();
 }
Esempio n. 2
0
        /// <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);
            }
        }
        private void btnReprint_Click(object sender, EventArgs e)
        {
            Donors oDonorLastRec = donorRepo.GetLastRecordbyOperator(ApplicationElements.loggedInEmployee.Id);
            if (oDonorLastRec != null)
            {
                string performDate_ForPrint = string.Empty;
                //Get Star Info
                var bindStarName = starRepo.GetAllAsQuerable(oDonorLastRec.Star);
                string[] starNameValue = bindStarName.Select(p => p.Name).ToArray();

                //Get serviceName Info
                var bindServiceType = serviceTypeRepo.GetAllAsQuerable(oDonorLastRec.ServiceTypeId);
                string[] ServceType = bindServiceType.Select(p => p.Name).ToArray();

                switch (oDonorLastRec.DateTypeId)
                {
                    case 1:
                        var bindMonth = monthsRepo.GetAllAsQuerable(oDonorLastRec.DonorMonth);
                        string[] months = bindMonth.Select(p => p.Name).ToArray();

                        var bindThidhi = thithiRepo.GetAllAsQuerable(oDonorLastRec.Thidhi);
                        string[] thidhi = bindThidhi.Select(p => p.Name).ToArray();
                        performDate_ForPrint = months[0] + " " + thidhi[0];
                        break;
                    case 2:
                        performDate_ForPrint = oDonorLastRec.PerformDate;
                        break;
                    case 3:
                        var bindSpecialDay = specialDayRepo.GetAllAsQuerable(oDonorLastRec.SpecialDayId);
                        string[] specialDay = bindSpecialDay.Select(p => p.Name).ToArray();
                        performDate_ForPrint = specialDay[0];
                        break;
                }

                TokenPrint oTokenPrint = new TokenPrint
                {
                    Id = oDonorLastRec.MR_No,
                    Name = oDonorLastRec.DonorName,
                    NameOn = oDonorLastRec.NameOn,
                    PerformDate = performDate_ForPrint,
                    Star = (starNameValue[0] == "Select") ? "" : starNameValue[0],
                    PhoneNumber = oDonorLastRec.Mobile,
                    Gothram = oDonorLastRec.Gothram,
                    VillageName = oDonorLastRec.City,
                    ServiceType = ServceType[0],
                    Cost = Convert.ToDouble(oDonorLastRec.Amount),
                    LoginName = ApplicationElements.loggedInEmployee.LoginId
                };

                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("No Data found for this user");
        }