public string ValidatePartialTicketNo(ClsTicketInventory objGeneratedNo, string Ticketno)
        {
            string ErrorMsg = "", AlphabetSeries = "";
            int    TicketLength, FnEndLength = 0, AlphabetSeriesLength = 0, TnEndLength = 0;
            string Alphabet = "";

            // Check for Ticket Length
            AlphabetSeries = objGeneratedNo.AlphabetSeries;
            string[] values = AlphabetSeries.Split(',');

            FnEndLength          = (objGeneratedNo.FnEnd == 0 ? 0 : FnEndLength);//objGeneratedNo.FnEnd.ToString().Length;
            AlphabetSeriesLength = values[values.Length - 1].ToString().Trim().Length;
            TnEndLength          = objGeneratedNo.TnEnd.ToString().Length;

            if (Ticketno.Trim().Length <= TnEndLength && IsIntegerWithZero(Ticketno))
            {
                if (Convert.ToInt32(Ticketno) > objGeneratedNo.TnEnd)
                {
                    ErrorMsg = "Invalid Ticket No. Ticket no should less than or equal to " + objGeneratedNo.TnEnd;
                    return(ErrorMsg);
                }
            }
            bool IsFound = false;

            if (Ticketno.Trim().Length == (AlphabetSeriesLength + TnEndLength) && IsIntegerWithZero(Ticketno))
            {
                for (int aCnt = 0; aCnt < values.Length; aCnt++)
                {
                    Alphabet = Ticketno.Substring(FnEndLength, TnEndLength);
                    if (Alphabet == values[aCnt].ToString().Trim() == true)
                    {
                        IsFound = true;
                        break;
                    }
                }
                if (IsFound == false)
                {
                    ErrorMsg = "Invalid Ticket No. Alphabet charcter sholud be among " + AlphabetSeries + " for ticket no " + Ticketno;
                    return(ErrorMsg);
                }
            }

            TicketLength = FnEndLength + AlphabetSeriesLength + TnEndLength;
            if (Ticketno.Trim().Length == TicketLength)
            {
                ErrorMsg = ValidateTicketNo(objGeneratedNo, Ticketno);
                return(ErrorMsg);
            }


            return(ErrorMsg);
        }
Пример #2
0
        public string GenQRNo(ClsTicketInventory objGeneratedNo, string LotteryNo)
        {
            string QRCode = "", RQId = "", RQDate = "", GenLotteryNo = "", GenCheckDigit = "";
            CheckDigitCalculation objCheckDigitCalculation = new CheckDigitCalculation();

            RQId          = "R_" + objGeneratedNo.DataUniqueId.ToString() + "~";
            RQDate        = "M_" + objGeneratedNo.StrReqDate + ":";
            GenLotteryNo  = "X_" + LotteryNo + "-";
            GenCheckDigit = "S_" + objCheckDigitCalculation.GenCheckDigit(objGeneratedNo.DataUniqueId.ToString() + objGeneratedNo.StrReqDate + LotteryNo) + "!";


            Random rnd        = new Random();
            int    IdPosition = rnd.Next(1, 3);

            if (IdPosition == 1)
            {
                QRCode = GenLotteryNo + RQDate + GenCheckDigit + RQId + "X";
            }
            else if (IdPosition == 2)
            {
                QRCode = RQId + GenCheckDigit + GenLotteryNo + "X" + RQDate;
            }
            else if (IdPosition == 3)
            {
                QRCode = GenCheckDigit + RQDate + "X" + RQId + GenLotteryNo;
            }

            if (objGeneratedNo.ID > default(long))
            {
                return(string.Format("{0}_{1}", QRCode, objGeneratedNo.ID.ToString()));
            }
            else
            {
                return(QRCode);
            }
        }
Пример #3
0
        //Checking for valid data entry
        private bool IsValidEntry()
        {
            if (ddlLotteryType.SelectedIndex == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Select Lottery Type.');", true);
                ddlLotteryType.Focus();
                return(false);
            }
            if (ddlLotteryName.SelectedIndex == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Select Lottery Name.');", true);
                ddlLotteryName.Focus();
                return(false);
            }

            if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false && txtDrawNo.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date or Draw no.');", true);
                txtDrawNo.Focus();
                return(false);
            }
            if (txtDrawDate.Text.Trim() != "")
            {
                if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date.');", true);
                    txtDrawDate.Focus();
                    return(false);
                }
            }
            if (txtDrawNo.Text.Trim() != "")
            {
                if (objValidateData.IsIntegerWithZero(txtDrawNo.Text.Trim()) == false)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw No.');", true);
                    txtDrawNo.Focus();
                    return(false);
                }
            }

            if (txtLotteryNo.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter Lottery No.');", true);
                txtLotteryNo.Focus();
                return(false);
            }

            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtLotteryInfo  = new DataTable();

            Int64    InLotteryId = Convert.ToInt64(ddlLotteryName.SelectedValue);
            int?     InDrawNo    = string.IsNullOrEmpty(txtDrawNo.Text.Trim()) ? (int?)null : int.Parse(txtDrawNo.Text.Trim());
            DateTime?InDrawDate  = string.IsNullOrEmpty(txtDrawDate.Text.Trim()) ? (DateTime?)null : DateTime.Parse(txtDrawDate.Text.Trim());

            dtLotteryInfo = objLtmsService.GetLotteryDtlFromRequisitionDtl(InLotteryId, InDrawNo, InDrawDate);
            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());

                string ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, txtLotteryNo.Text);
                if (ErrorMsg.Trim().Length > 0)
                {
                    lblValidTicket.Text = "<font color='red'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is Not valid ticket</b></font>";
                    var message = new JavaScriptSerializer().Serialize(ErrorMsg);
                    var script  = string.Format("alert({0});", message);
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                    txtLotteryNo.Focus();
                    return(false);
                }

                int    FnNo     = 0;
                string Alphabet = "";
                Int64  TnNo     = 0;


                string   AlphabetSeries = objGeneratedNo.AlphabetSeries;
                string[] values         = AlphabetSeries.Split(',');
                int      AlphabetLen    = Convert.ToInt16(values[values.Length - 1].ToString().Length);

                FnNo     = Convert.ToInt16(((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : txtLotteryNo.Text.Trim().Substring(0, objGeneratedNo.FnEnd.ToString().Length)));
                Alphabet = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? txtLotteryNo.Text.Trim().Substring(0, AlphabetLen) : txtLotteryNo.Text.Trim().Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                TnNo     = Convert.ToInt64(txtLotteryNo.Text.Trim().Substring(txtLotteryNo.Text.Trim().Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length));

                DataSet dtLotteryDtl = objLtmsService.GetLotteryDtlInClaimAndUnSold(objGeneratedNo.DataUniqueId, txtLotteryNo.Text.Trim().ToUpper(), FnNo, Alphabet, TnNo);
                if (dtLotteryDtl != null)
                {
                    if (dtLotteryDtl.Tables[1].Rows.Count > 0)
                    {
                        lblValidTicket.Text = "<font color='red'><b>The Lottery Ticket No " + txtLotteryNo.Text.Trim() + " is not available for Prize.</b></font>";
                        return(false);
                    }
                }
                DataSet dtLotteryWiningSerialNoDtl = objLtmsService.GetLotteryWiningSerialNoDtlByLotteryNo(objGeneratedNo.DataUniqueId, txtLotteryNo.Text.Trim());
                if (dtLotteryWiningSerialNoDtl.Tables[0].Rows.Count > 0)
                {
                    lblValidTicket.Text = "<font color='Green'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is available for " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["NameOfPrize"].ToString() + " and Prize Amount is " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["PrizeAmount"].ToString() + "</b></font>";
                    return(false);
                }
                bool isFound = false;
                dtLotteryWiningSerialNoDtl = objLtmsService.GetLotteryWiningSerialNoDtlByLotteryNo(objGeneratedNo.DataUniqueId, "");
                if (dtLotteryWiningSerialNoDtl.Tables[1].Rows.Count > 0)
                {
                    for (int rwCnt = 0; rwCnt < dtLotteryWiningSerialNoDtl.Tables[1].Rows.Count; rwCnt++)
                    {
                        if (txtLotteryNo.Text.Trim().EndsWith(dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WiningSerialNo"].ToString()) == true)
                        {
                            isFound             = true;
                            lblValidTicket.Text = "<font color='Green'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is available for " + dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["NameOfPrize"].ToString() + " and Prize Amount is " + dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["PrizeAmount"].ToString() + "</b></font>";
                            return(false);
                        }
                    }
                }
                if (isFound == false)
                {
                    lblValidTicket.Text = "<font color='red'><b>The Lottery Ticket No " + txtLotteryNo.Text.Trim() + " is not a Prize Winning Ticket.</b></font>";
                    // ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Enter valid ticket no. The ticket no you entered is not available in any Wining Serial No.');", true);
                    return(false);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Enter valid ticket no. The ticket no you entered is not correct for the date and draw no you specified');", true);
                return(false);
            }
            // GetLotteryDtlFromRequisitionDtl(Int64 InLotteryId, int InDrawNo, DateTime InDrawDate)

            return(true);
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["JB"]))
                {
                    string QueryString = Request.QueryString["JB"];
                    string LotteryNo = "", ReqId = "", ErrorMsg = "", RQDate = "", GenCheckDigit = "";
                    string UID  = string.Empty;
                    long   uidl = default(long);

                    int startIndex = QueryString.IndexOf("X_") + "X_".Length;
                    int endIndex   = QueryString.IndexOf("-");
                    LotteryNo = QueryString.Substring(startIndex, endIndex - startIndex);

                    UID = !string.IsNullOrWhiteSpace(QueryString) ? (QueryString.Split('_').LastOrDefault() != null ? QueryString.Split('_').LastOrDefault() : default(long).ToString()) : default(long).ToString();

                    startIndex = QueryString.IndexOf("R_") + "R_".Length;
                    endIndex   = QueryString.IndexOf("~");
                    ReqId      = QueryString.Substring(startIndex, endIndex - startIndex);

                    startIndex = QueryString.IndexOf("M_") + "M_".Length;
                    endIndex   = QueryString.IndexOf(":");
                    RQDate     = QueryString.Substring(startIndex, endIndex - startIndex);

                    startIndex    = QueryString.IndexOf("S_") + "S_".Length;
                    endIndex      = QueryString.IndexOf("!");
                    GenCheckDigit = QueryString.Substring(startIndex, endIndex - startIndex);

                    CheckDigitCalculation objCheckDigitCalculation = new CheckDigitCalculation();
                    string CheckDigit = string.Empty;
                    try
                    {
                        CheckDigit = objCheckDigitCalculation.GenCheckDigit(ReqId + RQDate + LotteryNo);
                    }
                    catch (Exception)
                    {
                        lblMessage.Text = " <font color='red'>Incorrect QR code</font>";;
                        return;
                    }

                    if (CheckDigit != GenCheckDigit)
                    {
                        lblMessage.Text = " <font color='red'>" + LotteryNo + " Is Not Valid Ticket No</font>";;
                        return;
                    }

                    objValidateData.ClearAllInputField(pnlDataEntry);
                    ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
                    DataTable          dtLotteryInfo  = new DataTable();
                    dtLotteryInfo = objLtmsService.GetRequisitionDtlById(Convert.ToInt32(ReqId));
                    long sr1End = default(long);
                    try
                    {
                        long.TryParse(dtLotteryInfo.Rows[0]["FnEnd"].ToString(), out sr1End);
                    }
                    catch (Exception) { }
                    DataTable newMultiTableData = objLtmsService.GetSeriesGenerationByReqIdAndSr1End(Convert.ToInt32(ReqId), sr1End);

                    long.TryParse(UID, out uidl);
                    DataTable newTableData = new DataTable();
                    if (uidl > default(long))
                    {
                        newTableData = objLtmsService.GetSeriesGenerationByReqIdSpecific(Convert.ToInt32(ReqId), uidl);
                    }
                    else
                    {
                        newTableData = objLtmsService.GetSeriesGenerationByReqId(Convert.ToInt32(ReqId));
                    }

                    if (dtLotteryInfo.Rows.Count > 0)
                    {
                        objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                        objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                        objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                        objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();

                        if (newTableData.Rows.Count > default(int))
                        {
                            objGeneratedNo.FnStart = Convert.ToInt16(newTableData.Rows[0]["Series1Start"].ToString());
                            objGeneratedNo.FnEnd   = Convert.ToInt16(newTableData.Rows[0]["Series1End"].ToString());
                            objGeneratedNo.TnStart = Convert.ToInt64(newTableData.Rows[0]["NumStart"].ToString());
                            objGeneratedNo.TnEnd   = Convert.ToInt64(newTableData.Rows[0]["NumEnd"].ToString());
                        }
                        else
                        {
                            objGeneratedNo.FnStart = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                            objGeneratedNo.FnEnd   = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                            objGeneratedNo.TnStart = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                            objGeneratedNo.TnEnd   = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());
                        }


                        ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, LotteryNo, newMultiTableData);
                        if (ErrorMsg.Trim().Length > 0)
                        {
                            lblMessage.Text = " <font color='red'>" + LotteryNo + " Is Not Valid Ticket No</font>";;
                        }
                        else
                        {
                            txtLotteryType.Text = dtLotteryInfo.Rows[0]["LotteryType"].ToString();
                            txtLotteryName.Text = !string.IsNullOrWhiteSpace(dtLotteryInfo.Rows[0]["ModifiedLotteryName"].ToString()) ? dtLotteryInfo.Rows[0]["ModifiedLotteryName"].ToString() : dtLotteryInfo.Rows[0]["LotteryName"].ToString();
                            txtDrawNo.Text      = dtLotteryInfo.Rows[0]["DrawNo"].ToString();
                            txtDrawDate.Text    = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"]).ToString("dd-MMM-yyyy");
                            txtLotteryNo.Text   = LotteryNo;
                            lblMessage.Text     = " <font color='green'>" + LotteryNo + " Is Valid Ticket No</font>";;
                        }
                    }
                }
            }
            catch (Exception ex) {
                lblMessage.Text = "Some Error occured. Please contact system administrator.";;
            }
        }
        //Checking for valid data entry
        private bool IsValidEntry(DataTable dtExcelData, Int64 DatauNiqueId)
        {
            string             ErrorMsg       = "";
            Int32              TotError       = 0;
            StringBuilder      strMsg         = new StringBuilder();
            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtLotteryInfo  = new DataTable();

            dtLotteryInfo = objLtmsService.GetRequisitionDtlById(DatauNiqueId);
            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());
                for (Int16 colCnt = 0; colCnt < dtExcelData.Columns.Count; colCnt++)
                {
                    ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Columns[colCnt].ToString());
                    if (ErrorMsg.Trim().Length > 0)
                    {
                        TotError++;
                        strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1:" + ErrorMsg);
                    }

                    for (Int32 iCnt = 0; iCnt < dtExcelData.Rows.Count; iCnt++)
                    {
                        ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Rows[iCnt][colCnt].ToString());
                        if (ErrorMsg.Trim().Length > 0)
                        {
                            TotError++;
                            if (TotError <= 10)
                            {
                                strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No " + (iCnt + 1) + ": " + ErrorMsg);
                            }
                            if (TotError > 10)
                            {
                                break;
                            }
                            ;
                        }
                    }
                }
            }
            if (strMsg.ToString().Trim().Length > 0)
            {
                if (TotError > 10)
                {
                    ErrorMsg = "There are more than 10 Error in the file  first 10 error are as below " + strMsg.ToString();
                }
                else
                {
                    ErrorMsg = "There are " + TotError + " Error in the file as below " + strMsg.ToString();
                }
                var message = new JavaScriptSerializer().Serialize(ErrorMsg);
                var script  = string.Format("alert({0});", message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                return(false);
            }
            if (objValidateData.IsIntegerWithZero(txtDrawNo.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Draw No number should be numeric.');", true);
                txtDrawNo.Focus();
                return(false);
            }
            if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date');", true);
                txtDrawDate.Focus();
                return(false);
            }
            return(true);
        }
Пример #6
0
 public bool UpdateInTicketInventory(ClsTicketInventory objTicketInventory)
 {
     return(objBusinessLogicDbTrx.UpdateInTicketInventory(objTicketInventory));
 }
Пример #7
0
 public bool InsertInTicketInventory(ClsTicketInventory objTicketInventory)
 {
     return(objBusinessLogicDbTrx.InsertInTicketInventory(objTicketInventory));
 }
        //Checking for valid data entry
        private bool IsValidEntry(out string DataUniqueId)
        {
            DataUniqueId = "";
            if (ddlClaimType.SelectedIndex == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Select Claim Type.');", true);
                ddlClaimType.Focus();
                return(false);
            }
            if (ddlLotteryType.SelectedIndex == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Select Lottery Type.');", true);
                ddlLotteryType.Focus();
                return(false);
            }
            if (ddlLotteryName.SelectedIndex == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Select Lottery Name.');", true);
                ddlLotteryName.Focus();
                return(false);
            }

            if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false && txtDrawNo.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date or Draw no.');", true);
                txtDrawNo.Focus();
                return(false);
            }
            if (txtDrawDate.Text.Trim() != "")
            {
                if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date.');", true);
                    txtDrawDate.Focus();
                    return(false);
                }
            }
            if (txtDrawNo.Text.Trim() != "")
            {
                if (objValidateData.IsIntegerWithZero(txtDrawNo.Text.Trim()) == false)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw No.');", true);
                    txtDrawNo.Focus();
                    return(false);
                }
            }

            if (txtLotteryNo.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter Lottery No.');", true);
                txtLotteryNo.Focus();
                return(false);
            }
            if (txtCaptcha.Text.Trim() != Session["captcha"].ToString())
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Enter valid captcha');", true);
                FillCapctha();
                txtCaptcha.Text = "";
                txtCaptcha.Focus();
                return(false);
            }
            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtLotteryInfo  = new DataTable();

            Int64    InLotteryId = Convert.ToInt64(ddlLotteryName.SelectedValue);
            int?     InDrawNo    = string.IsNullOrEmpty(txtDrawNo.Text.Trim()) ? (int?)null : int.Parse(txtDrawNo.Text.Trim());
            DateTime?InDrawDate  = string.IsNullOrEmpty(txtDrawDate.Text.Trim()) ? (DateTime?)null : DateTime.Parse(txtDrawDate.Text.Trim());

            dtLotteryInfo = objLtmsService.GetLotteryDtlFromRequisitionDtl(InLotteryId, InDrawNo, InDrawDate);
            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                DataUniqueId                  = objGeneratedNo.DataUniqueId.ToString();
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());
                if (txtDrawNo.Text.Trim() == "")
                {
                    txtDrawNo.Text = Convert.ToDateTime(objGeneratedNo.DrawDate).ToString("dd-MMM-yyyy");
                }
                if (txtDrawNo.Text.Trim() != "")
                {
                    txtDrawNo.Text = objGeneratedNo.DrawNo.ToString();
                }
                string ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, txtLotteryNo.Text);
                if (ErrorMsg.Trim().Length > 0)
                {
                    var message = new JavaScriptSerializer().Serialize(ErrorMsg);
                    var script  = string.Format("alert({0});", message);
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                    txtLotteryNo.Focus();
                    return(false);
                }
                DataSet dtLotteryWiningSerialNoDtl = objLtmsService.GetLotteryWiningSerialNoDtlByLotteryNo(objGeneratedNo.DataUniqueId, txtLotteryNo.Text.Trim());
                if (dtLotteryWiningSerialNoDtl.Tables[0].Rows.Count > 0)
                {
                    if (ddlClaimType.SelectedIndex == 1)
                    {
                        lblPrize.Text = "<font color='Yellow'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is available for " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["NameOfPrize"].ToString() + " and The Prize Amount is " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["PrizeAmount"].ToString() + "</b></font>";
                    }
                    else if (ddlClaimType.SelectedIndex == 2)
                    {
                        lblPrize.Text = "<font color='Yellow'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is available for Super " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["NameOfPrize"].ToString() + " and The Prize Amount is " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["SuperTicketAmount"].ToString() + "</b></font>";
                    }
                    else if (ddlClaimType.SelectedIndex == 3)
                    {
                        lblPrize.Text = "<font color='Yellow'><b>The Lottery Ticket " + txtLotteryNo.Text.Trim() + " is available for Special " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["NameOfPrize"].ToString() + " and The Prize Amount is " + dtLotteryWiningSerialNoDtl.Tables[0].Rows[0]["SpecialTicketAmount"].ToString() + "</b></font>";
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Enter valid ticket no. The ticket no you entered is not in prize list for the date and draw no you specified');", true);
                    return(false);
                }

                dtLotteryWiningSerialNoDtl.Dispose();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please Enter valid ticket no. The ticket no you entered is not correct for the date and draw no you specified');", true);
                return(false);
            }
            // GetLotteryDtlFromRequisitionDtl(Int64 InLotteryId, int InDrawNo, DateTime InDrawDate)

            return(true);
        }
        public string ValidateTicketNo(ClsTicketInventory objGeneratedNo, string Ticketno, DataTable dt = null)
        {
            string ErrorMsg = "", AlphabetSeries = "";
            int    TicketLength = 0, FnEndLength = 0, AlphabetSeriesLength = 0, TnEndLength = 0;
            string StartNo = "", Alphabet = "", EndNo = "";

            // Check for Ticket Length
            AlphabetSeries = objGeneratedNo.AlphabetSeries;
            string[] values = AlphabetSeries.Split(',');

            string finTktAlphabet            = string.Empty;
            long   finTktLastSeries          = default(long);
            List <ClsSeriesGeneration> lst   = new List <ClsSeriesGeneration>();
            List <ClsSeriesGeneration> fltr1 = new List <ClsSeriesGeneration>();

            FnEndLength          = (objGeneratedNo.FnEnd == 0 ? 0 : objGeneratedNo.FnEnd.ToString().Length);//objGeneratedNo.FnEnd.ToString().Length;
            TnEndLength          = objGeneratedNo.TnEnd.ToString().Length;
            AlphabetSeriesLength = values[values.Length - 1].ToString().Trim().Length;
            if (Ticketno.Trim().Length > 0)
            {
                try
                {
                    finTktAlphabet = Ticketno.Substring(FnEndLength, AlphabetSeriesLength);
                    long.TryParse(Ticketno.Substring((FnEndLength + AlphabetSeriesLength), (Ticketno.Trim().Length - (FnEndLength + AlphabetSeriesLength))), out finTktLastSeries);

                    /*var res = from row in dt.AsEnumerable()
                     *        where row.Field<long>("NumStart") <= finTktLastSeries && row.Field<long>("NumEnd") > finTktLastSeries
                     *        select row;*/

                    if (dt != null)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            var obj = new ClsSeriesGeneration();
                            obj.ID           = Convert.ToInt64(dt.Rows[i]["ID"]);
                            obj.ReqId        = Convert.ToInt32(dt.Rows[i]["ReqId"]);
                            obj.Series1Start = Convert.ToInt64(dt.Rows[i]["Series1Start"]);
                            obj.Series1End   = Convert.ToInt64(dt.Rows[i]["Series1End"]);
                            obj.Series2Start = Convert.ToString(dt.Rows[i]["Series2Start"]);
                            obj.Series2End   = Convert.ToString(dt.Rows[i]["Series2End"]);
                            obj.NumStart     = Convert.ToInt64(dt.Rows[i]["NumStart"]);
                            obj.NumEnd       = Convert.ToInt64(dt.Rows[i]["NumEnd"]);
                            lst.Add(obj);
                        }
                        fltr1 = lst.Where(l => l.NumStart <= finTktLastSeries && l.NumEnd >= finTktLastSeries).ToList();
                        if (fltr1.Count() > default(int))
                        {
                            foreach (var item in fltr1)
                            {
                                var alpSries = values.Slice(Array.FindIndex(values, m => m == item.Series2Start), (Array.FindIndex(values, m => m == item.Series2End) + 1));
                                var results  = Array.FindAll(alpSries, s => s.Equals(finTktAlphabet));
                                if (results != null && results.Length > default(int))
                                {
                                    objGeneratedNo.FnStart = Convert.ToInt32(item.Series1Start);
                                    objGeneratedNo.FnEnd   = Convert.ToInt32(item.Series1End);
                                    objGeneratedNo.TnStart = item.NumStart;
                                    objGeneratedNo.TnEnd   = item.NumEnd;
                                    FnEndLength            = (objGeneratedNo.FnEnd == 0 ? 0 : objGeneratedNo.FnEnd.ToString().Length);
                                    TnEndLength            = objGeneratedNo.TnEnd.ToString().Length;
                                    break;
                                }
                            }
                        }
                    }
                }
                catch { }


                TicketLength = (objGeneratedNo.FnEnd == 0 ? 0 : FnEndLength) + AlphabetSeriesLength + TnEndLength;
                if (Ticketno.Trim().Length != TicketLength)
                {
                    ErrorMsg = "Invalid Ticket No. No of characters in Ticket should be " + TicketLength + " for ticket no " + Ticketno;
                    return(ErrorMsg);
                }
                if (objGeneratedNo.FnEnd > 0)
                {
                    StartNo = Ticketno.Substring(0, FnEndLength);

                    if (IsIntegerWithZero(StartNo) == false)
                    {
                        ErrorMsg = "Invalid Ticket No. First " + FnEndLength + " No  sholud be should numeric and less thar or equal to " + objGeneratedNo.FnEnd + " for ticket no " + Ticketno;
                        return(ErrorMsg);
                    }

                    if ((Convert.ToInt16(StartNo) <= objGeneratedNo.FnEnd) == false)
                    {
                        ErrorMsg = "Invalid Ticket No. First " + FnEndLength + " No  sholud be should be less than or equal to " + objGeneratedNo.FnEnd + " for ticket no " + Ticketno;
                        return(ErrorMsg);
                    }
                }

                bool IsFound = false;
                for (int aCnt = 0; aCnt < values.Length; aCnt++)
                {
                    Alphabet = Ticketno.Substring(FnEndLength, (TicketLength - (FnEndLength + TnEndLength)));
                    if (Alphabet == values[aCnt].ToString().Trim() == true)
                    {
                        IsFound = true;
                        break;
                    }
                }
                if (IsFound == false)
                {
                    ErrorMsg = "Invalid Ticket No. Alphabet charcter sholud be among " + AlphabetSeries + " for ticket no " + Ticketno;
                    return(ErrorMsg);
                }

                EndNo = Ticketno.Substring(Ticketno.Length - TnEndLength, TnEndLength);

                if (IsLongIntegerWithZero(EndNo) == false)
                {
                    ErrorMsg = "Invalid Ticket No. Last " + TnEndLength + " No  sholud be should numeric and less thar or equal to " + objGeneratedNo.TnEnd + " for ticket no " + Ticketno;
                    return(ErrorMsg);
                }

                if ((Convert.ToInt64(EndNo) <= objGeneratedNo.TnEnd) == false)
                {
                    ErrorMsg = "Invalid Ticket No. Last " + TnEndLength + " No  sholud be should be less than or equal to " + objGeneratedNo.TnEnd + " for ticket no " + Ticketno;
                    return(ErrorMsg);
                }
            }
            return(ErrorMsg);
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string        QRUrl          = System.Web.Configuration.WebConfigurationManager.AppSettings["QRUrl"].ToString() + "?JB=";
            StringBuilder strReport      = new StringBuilder();
            StringBuilder strTableReport = new StringBuilder();

            ClsTicketGenRequest objClsTicketGenRequest = new ClsTicketGenRequest();

            objClsTicketGenRequest = (ClsTicketGenRequest)Session["TicketGenRequest"];

            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtInfo         = objLtmsService.GetRequisitionDtlById(objClsTicketGenRequest.DataUniqueId);

            if (dtInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId = Convert.ToInt64(dtInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.ReqDate      = Convert.ToDateTime(dtInfo.Rows[0]["ReqDate"].ToString());
                objGeneratedNo.DrawNo       = Convert.ToInt16(dtInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate     = Convert.ToDateTime(dtInfo.Rows[0]["DrawDate"].ToString());

                /*objGeneratedNo.FnStart = Convert.ToInt16(dtInfo.Rows[0]["FnStart"].ToString());
                 * objGeneratedNo.FnEnd = Convert.ToInt16(dtInfo.Rows[0]["FnEnd"].ToString());
                 * objGeneratedNo.AlphabetSeries = dtInfo.Rows[0]["AlphabetSeries"].ToString();
                 * objGeneratedNo.TnStart = Convert.ToInt64(dtInfo.Rows[0]["TnStart"].ToString());
                 * objGeneratedNo.TnEnd = Convert.ToInt64(dtInfo.Rows[0]["TnEnd"].ToString());*/
                objGeneratedNo.ID             = objClsTicketGenRequest.ID;
                objGeneratedNo.FnStart        = objClsTicketGenRequest.FnStart;
                objGeneratedNo.FnEnd          = objClsTicketGenRequest.FnEnd;
                objGeneratedNo.AlphabetSeries = objClsTicketGenRequest.AlphabetSeries;
                objGeneratedNo.TnStart        = objClsTicketGenRequest.TnStart;
                objGeneratedNo.TnEnd          = objClsTicketGenRequest.TnEnd;

                objGeneratedNo.ReqCode    = dtInfo.Rows[0]["ReqCode"].ToString();
                objGeneratedNo.StrReqDate = objGeneratedNo.ReqDate.Minute.ToString();

                Int64 FnStartRange = objClsTicketGenRequest.TnStart;
                Int64 FnEndRange   = objClsTicketGenRequest.TnEnd;
                //string FileName = objClsTicketGenRequest.RowNo.ToString()+ "_DR" + objGeneratedNo.DrawNo + "_" + Convert.ToDateTime(objGeneratedNo.DrawDate).ToString("ddMMMyyyy").ToUpper() + "_" + objGeneratedNo.ReqCode.Replace("/", "") + "_" + FnStartRange.ToString() + "_" + FnEndRange.ToString() + ".xls";
                //string FileName = objClsTicketGenRequest.RowNo.ToString() + "_DR" + objGeneratedNo.DrawNo + "_" + Convert.ToDateTime(objGeneratedNo.DrawDate).ToString("ddMMMyyyy").ToUpper() + "_" + objGeneratedNo.ReqCode.Replace("/", "") + "_" + FnStartRange.ToString() + "_" + FnEndRange.ToString() + ".csv";
                string   FileName         = objClsTicketGenRequest.RowNo.ToString() + "_DR" + objGeneratedNo.DrawNo + "_" + Convert.ToDateTime(objGeneratedNo.DrawDate).ToString("ddMMMyyyy").ToUpper() + "_" + objGeneratedNo.ReqCode.Replace("/", "") + "_" + FnStartRange.ToString() + "_" + FnEndRange.ToString() + ".xlsx";
                int      FnStart          = objGeneratedNo.FnStart;
                int      FnEnd            = objGeneratedNo.FnEnd;
                string   AlphabetSeries   = objGeneratedNo.AlphabetSeries;
                string[] values           = AlphabetSeries.Split(',');
                Int64    TnStart          = objGeneratedNo.TnStart;
                bool     IsStartNoRequire = false;
                Int64    TnEnd            = objGeneratedNo.TnEnd;
                FnEnd            = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? 1 : objGeneratedNo.FnEnd);
                FnStart          = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? 1 : objGeneratedNo.FnStart);
                IsStartNoRequire = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? false : true);

                string AlphabetChar = "", LotteryNumber = "";

                /*for (int sCnt = FnStart; sCnt <= FnEnd; sCnt++)
                 * {
                 *  for (Int64 eCnt = FnEndRange; eCnt >= FnStartRange; eCnt--)
                 *  {
                 *      for (int aCnt =values.Length-1; aCnt >= 0; aCnt--)
                 *      {
                 *          AlphabetChar = values[aCnt].ToString().Trim();
                 *
                 *          strReport.AppendLine("<tr>");
                 *          //LotteryNumber =(IsStartNoRequire==true? sCnt.ToString().PadLeft(FnEnd.ToString().Length,'0') :"") + AlphabetChar + eCnt.ToString().PadLeft(TnEnd.ToString().Length,'0');
                 *          LotteryNumber = (IsStartNoRequire == true ? sCnt.ToString().PadLeft(FnEnd.ToString().Length, '0') : "") + AlphabetChar + eCnt.ToString().PadLeft(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PadLeftCharCount"]), '0');
                 *          strReport.AppendLine("      <td>" + LotteryNumber + "</td>");
                 *          strReport.AppendLine("      <td>" + QRUrl + GenQRNo(objGeneratedNo, LotteryNumber) +"</td>");
                 *          strReport.AppendLine("</tr>");
                 *      }
                 *  }
                 * }*/

                DataTable dt = new DataTable();
                dt.TableName = "dt";
                dt.Columns.Add(new DataColumn("LotteryNumber", typeof(string)));
                dt.Columns.Add(new DataColumn("QRUrl", typeof(string)));
                DataRow dtRw = null;

                //StringBuilder builder = new StringBuilder();
                //List<string> columnNames = new List<string>();
                //List<string> rows = new List<string>();
                //columnNames.Add("\"LotteryNumber\"");
                //columnNames.Add("\"QRUrl\"");
                //builder.Append(string.Join(",", columnNames.ToArray())).Append("\n");

                for (Int64 eCnt = FnEndRange; eCnt >= FnStartRange; eCnt--)
                {
                    //for (int sCnt = FnStart; sCnt <= FnEnd; sCnt++)
                    for (int sCnt = FnEnd; sCnt >= FnStart; sCnt--)
                    {
                        for (int aCnt = values.Length - 1; aCnt >= 0; aCnt--)
                        {
                            AlphabetChar = values[aCnt].ToString().Trim();

                            /*strReport.AppendLine("<tr>");
                             * //LotteryNumber =(IsStartNoRequire==true? sCnt.ToString().PadLeft(FnEnd.ToString().Length,'0') :"") + AlphabetChar + eCnt.ToString().PadLeft(TnEnd.ToString().Length,'0');
                             * LotteryNumber = (IsStartNoRequire == true ? sCnt.ToString().PadLeft(FnEnd.ToString().Length, '0') : "") + AlphabetChar + eCnt.ToString().PadLeft(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PadLeftCharCount"]), '0');
                             * //strReport.AppendLine("      <td>&#39;" + LotteryNumber + "</td>");
                             * strReport.AppendLine("      <td>" + LotteryNumber + "</td>");
                             * strReport.AppendLine("      <td>" + QRUrl + GenQRNo(objGeneratedNo, LotteryNumber) + "</td>");
                             * strReport.AppendLine("</tr>");*/

                            dtRw                  = dt.NewRow();
                            LotteryNumber         = (IsStartNoRequire == true ? sCnt.ToString().PadLeft(FnEnd.ToString().Length, '0') : "") + AlphabetChar + eCnt.ToString().PadLeft(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PadLeftCharCount"]), '0');
                            dtRw["LotteryNumber"] = LotteryNumber;
                            dtRw["QRUrl"]         = QRUrl + GenQRNo(objGeneratedNo, LotteryNumber);
                            dt.Rows.Add(dtRw);

                            //List<string> currentRow = new List<string>();
                            //LotteryNumber = (IsStartNoRequire == true ? sCnt.ToString().PadLeft(FnEnd.ToString().Length, '0') : "") + AlphabetChar + eCnt.ToString().PadLeft(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PadLeftCharCount"]), '0');
                            //currentRow.Add("\"" + LotteryNumber + "\"");
                            //currentRow.Add("\"" + QRUrl + GenQRNo(objGeneratedNo, LotteryNumber) + "\"");
                            //rows.Add(string.Join(",", currentRow.ToArray()));
                        }
                    }
                }
                dt.AcceptChanges();

                //builder.Append(string.Join("\n", rows.ToArray()));

                /*strTableReport.AppendLine("<table border='1' >");
                 * strTableReport.AppendLine("          " + strReport.ToString());
                 * strTableReport.AppendLine("</table>");*/

                Response.Clear();
                Response.Buffer = true;
                //Response.ContentType = "application/vnd.ms-excel";
                Response.ContentType = "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("Content-Disposition", "inline;filename=" + FileName);
                //Response.ContentType = "text/csv";
                //Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
                //Response.Write(builder.ToString());
                //String HTMLDataToExport = strTableReport.ToString();


                /*Response.Write("<html><head><head>" +
                 * HTMLDataToExport.Replace("<BR>", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<br>", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<BR >", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<BR />", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<br />", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<Br />", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<Br>", "<br style='mso-data-placement:same-cell;'>")
                 *                             .Replace("<br >", "<br style='mso-data-placement:same-cell;'>") + "</html>");*/
                Response.BinaryWrite(GenerateExcel2007(dt));
                Response.End();
            }
        }
Пример #11
0
        //Checking for valid data entry
        private bool IsValidEntry(DataTable dtExcelData, Int64 DatauNiqueId, ref DataTable dtTicketNumber)
        {
            string ErrorMsg = "";
            Int32  TotError = 0;
            Int64  WinnerId = 0;
            //Int32 NoOfRecordSToBeUpload = 60;
            bool               ValidationForUnsold = false;
            int                errorCntForTkt      = 0;
            StringBuilder      strMsg         = new StringBuilder();
            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtLotteryInfo  = new DataTable();
            DataTable          distinctTable  = dtExcelData.DefaultView.ToTable(true);

            if (dtExcelData.Rows.Count != distinctTable.Rows.Count)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Upload can not be complited.Duplicate Ticket No exist in file.');", true);
                return(false);
            }


            distinctTable.Clear();
            distinctTable = null;
            DataRow dr = null;

            dtLotteryInfo = objLtmsService.GetRequisitionDtlById(DatauNiqueId);
            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());

                DataSet dtLotteryWiningSerialNoDtl = objLtmsService.GetLotteryWiningSerialNoDtlByLotteryNo(objGeneratedNo.DataUniqueId, "");
                for (Int16 colCnt = 0; colCnt < dtExcelData.Columns.Count; colCnt++)
                {
                    if (dtExcelData.Columns[colCnt].ToString().Trim().Length > 0)
                    {
                        errorCntForTkt = 0;
                        WinnerId       = 0;
                        bool isValidTicketNo = true, IsCommonToAllSeries = false, isPartialTicket = false;
                        ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Columns[colCnt].ToString());
                        if (ErrorMsg.Trim().Length > 0)
                        {
                            errorCntForTkt++;
                            TotError++;
                            strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1:" + ErrorMsg);
                            isValidTicketNo = false;
                        }
                        if (isValidTicketNo == true)
                        {
                            for (int rwCnt = 0; rwCnt < dtLotteryWiningSerialNoDtl.Tables[1].Rows.Count; rwCnt++)
                            {
                                if (dtExcelData.Columns[colCnt].ToString().ToUpper() == dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WiningSerialNo"].ToString().ToUpper())
                                {
                                    IsCommonToAllSeries = true;
                                }
                                if (dtExcelData.Columns[colCnt].ToString().ToUpper().EndsWith(dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WiningSerialNo"].ToString()) == true)
                                {
                                    isPartialTicket = true;
                                    WinnerId        = Convert.ToInt64(dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WinnerId"].ToString());

                                    ValidationForUnsold = (dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["ValidationForUnsold"].ToString().ToUpper() == "Y"?true:false);
                                    if (ValidationForUnsold == true)
                                    {
                                        int      FnNo           = 0;
                                        string   Alphabet       = "";
                                        Int64    TnNo           = 0;
                                        string   AlphabetSeries = objGeneratedNo.AlphabetSeries;
                                        string[] values         = AlphabetSeries.Split(',');
                                        int      AlphabetLen    = Convert.ToInt16(values[values.Length - 1].ToString().Length);
                                        FnNo     = Convert.ToInt16(((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().Substring(0, objGeneratedNo.FnEnd.ToString().Length)));
                                        Alphabet = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().Substring(0, AlphabetLen) : dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                                        TnNo     = Convert.ToInt64(dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().Substring(dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length));
                                        DataSet dtLotteryDtl = objLtmsService.GetLotteryDtlInClaimAndUnSold(objGeneratedNo.DataUniqueId, dtExcelData.Columns[colCnt].ToString().ToUpper().Trim().ToUpper(), FnNo, Alphabet, TnNo);
                                        if (dtLotteryDtl != null)
                                        {
                                            if (dtLotteryDtl.Tables[1].Rows.Count > 0)
                                            {
                                                errorCntForTkt++;
                                                TotError++;
                                                strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1: The Lottery Ticket " + dtExcelData.Columns[colCnt].ToString().ToUpper() + " is available in unsold ticket");
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (IsCommonToAllSeries == true)
                        {
                            errorCntForTkt++;
                            TotError++;
                            strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1: The Lottery Ticket " + dtExcelData.Columns[colCnt].ToString().ToUpper() + " is type PWT So it will not uploded with this portal");
                        }
                        if (isPartialTicket == false)
                        {
                            errorCntForTkt++;
                            TotError++;
                            strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1: The Lottery Ticket " + dtExcelData.Columns[colCnt].ToString().ToUpper() + " is Not a Winning prize.");
                        }
                        if (errorCntForTkt == 0 && isPartialTicket == true)
                        {
                            dr = dtTicketNumber.NewRow();
                            dr["TicketNumber"] = dtExcelData.Columns[colCnt].ToString();
                            dr["WinnerId"]     = WinnerId.ToString();
                            dtTicketNumber.Rows.Add(dr);
                        }
                        for (Int32 iCnt = 0; iCnt < dtExcelData.Rows.Count; iCnt++)
                        {
                            if (dtExcelData.Rows[iCnt][colCnt].ToString().Trim().Length > 0)
                            {
                                isValidTicketNo     = true;
                                IsCommonToAllSeries = false;
                                isPartialTicket     = false;
                                errorCntForTkt      = 0;
                                WinnerId            = 0;
                                ErrorMsg            = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Rows[iCnt][colCnt].ToString());
                                if (ErrorMsg.Trim().Length > 0)
                                {
                                    errorCntForTkt++;
                                    TotError++;
                                    if (TotError <= 10)
                                    {
                                        isValidTicketNo = false;
                                        strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No " + (iCnt + 1) + ": " + ErrorMsg);
                                    }
                                    if (TotError > 10)
                                    {
                                        break;
                                    }
                                    ;
                                }
                                if (isValidTicketNo == true)
                                {
                                    for (int rwCnt = 0; rwCnt < dtLotteryWiningSerialNoDtl.Tables[1].Rows.Count; rwCnt++)
                                    {
                                        if (dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper() == dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WiningSerialNo"].ToString().ToUpper())
                                        {
                                            IsCommonToAllSeries = true;
                                        }
                                        if (dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().EndsWith(dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WiningSerialNo"].ToString()) == true)
                                        {
                                            WinnerId            = Convert.ToInt64(dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["WinnerId"].ToString());
                                            isPartialTicket     = true;
                                            ValidationForUnsold = (dtLotteryWiningSerialNoDtl.Tables[1].Rows[rwCnt]["ValidationForUnsold"].ToString().ToUpper() == "Y"?true:false);
                                            if (ValidationForUnsold == true)
                                            {
                                                int    FnNo     = 0;
                                                string Alphabet = "";
                                                Int64  TnNo     = 0;


                                                string   AlphabetSeries = objGeneratedNo.AlphabetSeries;
                                                string[] values         = AlphabetSeries.Split(',');
                                                int      AlphabetLen    = Convert.ToInt16(values[values.Length - 1].ToString().Length);

                                                FnNo     = Convert.ToInt16(((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim().Substring(0, objGeneratedNo.FnEnd.ToString().Length)));
                                                Alphabet = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim().Substring(0, AlphabetLen) : dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim().Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                                                TnNo     = Convert.ToInt64(dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim().Substring(dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim().Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length));

                                                DataSet dtLotteryDtl = objLtmsService.GetLotteryDtlInClaimAndUnSold(objGeneratedNo.DataUniqueId, dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper().Trim(), FnNo, Alphabet, TnNo);
                                                if (dtLotteryDtl != null)
                                                {
                                                    if (dtLotteryDtl.Tables[1].Rows.Count > 0)
                                                    {
                                                        errorCntForTkt++;
                                                        TotError++;
                                                        strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1: The Lottery Ticket " + dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper() + " is available in unsold ticket");
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (IsCommonToAllSeries == true)
                                {
                                    errorCntForTkt++;
                                    TotError++;
                                    strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No  " + (iCnt + 1) + ":  The Lottery Ticket " + dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper() + " is type PWT So it will not uploded with this portal");
                                }
                                if (isPartialTicket == false)
                                {
                                    errorCntForTkt++;
                                    TotError++;
                                    strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No  " + (iCnt + 1) + ": The Lottery Ticket " + dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper() + " is Not a Winning prize.");
                                }

                                if (errorCntForTkt == 0 && isPartialTicket == true)
                                {
                                    dr = dtTicketNumber.NewRow();
                                    dr["TicketNumber"] = dtExcelData.Rows[iCnt][colCnt].ToString().ToUpper();
                                    dr["WinnerId"]     = WinnerId.ToString();
                                    dtTicketNumber.Rows.Add(dr);
                                }
                            }
                            if (TotError > 10)
                            {
                                break;
                            }
                            ;
                        }
                    }
                }
            }
            if (strMsg.ToString().Trim().Length > 0)
            {
                if (TotError > 10)
                {
                    ErrorMsg = "There are more than 10 Error in the file  first 10 error are as below " + strMsg.ToString();
                }
                else
                {
                    ErrorMsg = "There are " + TotError + " Error in the file as below " + strMsg.ToString();
                }
                var message = new JavaScriptSerializer().Serialize(ErrorMsg);
                var script  = string.Format("alert({0});", message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                return(false);
            }

            dtLotteryInfo = objLtmsService.GetVariableClaimPrizeById(DatauNiqueId);
            bool IsFound = false;
            int  DuplicateTicketCount = 0;

            for (int iRwCnt = 0; iRwCnt < dtLotteryInfo.Rows.Count; iRwCnt++)
            {
                for (int jRwCnt = 0; jRwCnt < dtTicketNumber.Rows.Count; jRwCnt++)
                {
                    if (dtTicketNumber.Rows[jRwCnt]["TicketNumber"].ToString().Trim() == dtLotteryInfo.Rows[iRwCnt]["TicketNumber"].ToString().Trim())
                    {
                        DuplicateTicketCount += 1;
                        IsFound = true;
                    }
                }
            }
            if (IsFound == true)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Upload can not be completed. Total " + DuplicateTicketCount + " duplicate ticket no exist in database.');", true);
                return(false);
            }
            if (objValidateData.IsIntegerWithZero(txtDrawNo.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Draw No number should be numeric.');", true);
                txtDrawNo.Focus();
                return(false);
            }
            if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date');", true);
                txtDrawDate.Focus();
                return(false);
            }
            return(true);
        }
Пример #12
0
        //Checking for valid data entry
        private bool IsValidEntry()
        {
            bool   IsError = false;
            string ErrorMsg = "", Msg = "";

            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();
            DataTable          dtLotteryInfo = new DataTable();

            dtLotteryInfo = objLtmsService.GetRequisitionDtlById(Convert.ToInt64(hdUniqueId.Value));
            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery information not generated in inventory.');", true);
                return(false);
            }

            for (int iCtr = 0; iCtr < gvPrizeWinnerDetails.Rows.Count; iCtr++)
            {
                Label    lblNoOfDigitInStatic   = (Label)gvPrizeWinnerDetails.Rows[iCtr].Cells[0].FindControl("lblNoOfDigitInStatic");
                CheckBox chkValidationForUnsold = (CheckBox)gvPrizeWinnerDetails.Rows[iCtr].Cells[0].FindControl("chkValidationForUnsold");

                GridView gvWiningSerialNo = ((GridView)gvPrizeWinnerDetails.Rows[iCtr].Cells[0].FindControl("gvWiningSerialNo"));
                for (int jCnt = 0; jCnt < gvWiningSerialNo.Rows.Count; jCnt++)
                {
                    TextBox txtWiningSerialNo = (TextBox)gvWiningSerialNo.Rows[jCnt].Cells[0].FindControl("txtWiningSerialNo");
                    if (txtWiningSerialNo.Text.Trim() == "")
                    {
                        IsError  = true;
                        ErrorMsg = (ErrorMsg != "" ? ErrorMsg + "\n" : "") + "Wining SerialNo name can not be balnk in row no. " + (iCtr + 1) + " for box" + (jCnt + 1);
                    }
                    else if (txtWiningSerialNo.Text.Trim() != "" && txtWiningSerialNo.Text.Trim().Length != Convert.ToInt16(lblNoOfDigitInStatic.Text))
                    {
                        IsError  = true;
                        ErrorMsg = (ErrorMsg != "" ? ErrorMsg + "\n" : "") + "No of character in Wining Serial No. should be " + Convert.ToInt16(lblNoOfDigitInStatic.Text) + "  in row no. " + (iCtr + 1) + " for box" + (jCnt + 1);
                    }
                    else if (txtWiningSerialNo.Text.Trim() != "" && txtWiningSerialNo.Text.Trim().Length == Convert.ToInt16(lblNoOfDigitInStatic.Text))
                    {
                        if (dtLotteryInfo.Rows.Count > 0)
                        {
                            Msg = objValidateData.ValidatePartialTicketNo(objGeneratedNo, txtWiningSerialNo.Text);
                            if (Msg.Length > 0)
                            {
                                IsError  = true;
                                ErrorMsg = (ErrorMsg != "" ? ErrorMsg + "\n" : "") + Msg + "  in row no. " + (iCtr + 1) + " for box" + (jCnt + 1);
                            }
                            if (Msg.Length == 0 && chkValidationForUnsold.Checked == true)
                            {
                                int    FnNo = 0, TicketLength = 0, FnEndLength = 0, AlphabetSeriesLength, TnEndLength = 0;
                                string Alphabet = "";
                                Int64  TnNo     = 0;

                                string   AlphabetSeries = objGeneratedNo.AlphabetSeries;
                                string[] values         = AlphabetSeries.Split(',');
                                int      AlphabetLen    = Convert.ToInt16(values[values.Length - 1].ToString().Length);

                                FnEndLength          = (objGeneratedNo.FnEnd == 0 ? 0 : objGeneratedNo.FnEnd.ToString().Length);
                                AlphabetSeriesLength = values[values.Length - 1].ToString().Trim().Length;
                                TnEndLength          = objGeneratedNo.TnEnd.ToString().Length;

                                TicketLength = (objGeneratedNo.FnEnd == 0 ? 0 : FnEndLength) + AlphabetSeriesLength + TnEndLength;
                                if (txtWiningSerialNo.Text.Trim().ToUpper().Length == TicketLength)
                                {
                                    FnNo     = Convert.ToInt16(((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : txtWiningSerialNo.Text.Trim().Substring(0, objGeneratedNo.FnEnd.ToString().Length)));
                                    Alphabet = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? txtWiningSerialNo.Text.Trim().Substring(0, AlphabetLen) : txtWiningSerialNo.Text.Trim().Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                                    TnNo     = Convert.ToInt64(txtWiningSerialNo.Text.Trim().Substring(txtWiningSerialNo.Text.Trim().Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length));

                                    DataSet dtLotteryDtl = objLtmsService.GetLotteryDtlInClaimAndUnSold(objGeneratedNo.DataUniqueId, txtWiningSerialNo.Text.Trim().ToUpper(), FnNo, Alphabet, TnNo);
                                    if (dtLotteryDtl != null)
                                    {
                                        if (dtLotteryDtl.Tables[1].Rows.Count > 0)
                                        {
                                            IsError  = true;
                                            ErrorMsg = (ErrorMsg != "" ? ErrorMsg + "\n" : "") + "The Wining Serial No. " + txtWiningSerialNo.Text.Trim().ToUpper() + " is available in unsold ticket in row no. " + (iCtr + 1) + " for box" + (jCnt + 1);
                                        }
                                    }
                                }
                                else if (txtWiningSerialNo.Text.Trim().ToUpper().Length <= TnEndLength && objValidateData.IsIntegerWithZero(txtWiningSerialNo.Text.Trim().ToUpper()))
                                {
                                    if (Convert.ToInt32(txtWiningSerialNo.Text.Trim()) <= objGeneratedNo.TnEnd)
                                    {
                                        FnNo     = 0;
                                        Alphabet = "";
                                        TnNo     = Convert.ToInt64(txtWiningSerialNo.Text.Trim());

                                        DataSet dtLotteryDtl = objLtmsService.GetLotteryDtlInClaimAndUnSold(objGeneratedNo.DataUniqueId, txtWiningSerialNo.Text.Trim().ToUpper(), FnNo, Alphabet, TnNo);
                                        if (dtLotteryDtl != null)
                                        {
                                            if (dtLotteryDtl.Tables[2].Rows.Count > 0)
                                            {
                                                IsError  = true;
                                                ErrorMsg = (ErrorMsg != "" ? ErrorMsg + "\n" : "") + "The Wining Serial No. " + txtWiningSerialNo.Text.Trim().ToUpper() + " is available in unsold ticket in row no. " + (iCtr + 1) + " for box" + (jCnt + 1);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //
                    }
                }
            }

            if (IsError == true)
            {
                var message = new JavaScriptSerializer().Serialize("Some errors in PrizeWinner details table as below.\n'" + ErrorMsg);
                var script  = string.Format("alert({0});", message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                // ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Some error in PrizeWinner details table as below.\n'"+ ErrorMsg +");", true);
                return(false);
            }

            if (txtJudgesName1.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Judges Name 1 can not be left blank.');", true);
                txtJudgesName1.Focus();
                return(false);
            }

            if (txtPlayingAddress.Text.Trim() == "")
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Playing Address can not be left blank.');", true);
                txtPlayingAddress.Focus();
                return(false);
            }

            return(true);
        }
Пример #13
0
        //Checking for valid data entry
        private bool IsValidEntry(DataTable dtExcelData, Int64 DatauNiqueId, out DataTable dtTicketRange)
        {
            string             ErrorMsg       = "";
            Int32              TotError       = 0;
            StringBuilder      strMsg         = new StringBuilder();
            ClsTicketInventory objGeneratedNo = new ClsTicketInventory();

            dtTicketRange = null;

            if (objValidateData.IsIntegerWithZero(txtDrawNo.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Draw No number should be numeric.');", true);
                txtDrawNo.Focus();
                return(false);
            }
            if (objValidateData.isValidDate(txtDrawDate.Text.Trim()) == false)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Please enter valid draw date');", true);
                txtDrawDate.Focus();
                return(false);
            }

            Int32 ColCnt = 0;

            for (Int32 colCnt = 0; colCnt < dtExcelData.Columns.Count; colCnt++)
            {
                if (dtExcelData.Columns[colCnt].ToString().Trim() != "")
                {
                    ColCnt++;
                }
            }

            if (ColCnt != 4)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('No of column in excel should be 4 in a sequence of Initial No, Alphabates, Start no , end no.');", true);
                return(false);
            }

            DataTable dtTicketRow = new DataTable();

            dtTicketRow.TableName = "dtTicket";
            DataRow dataRw = null;

            dtTicketRow.Columns.Add(new DataColumn("FnNo", typeof(int)));
            dtTicketRow.Columns.Add(new DataColumn("Alphabet", typeof(string)));
            dtTicketRow.Columns.Add(new DataColumn("StartNo", typeof(Int64)));
            dtTicketRow.Columns.Add(new DataColumn("EndNo", typeof(Int64)));


            DataTable dtLotteryInfo = objLtmsService.GetRequisitionDtlById(DatauNiqueId);

            if (dtLotteryInfo.Rows.Count > 0)
            {
                objGeneratedNo.DataUniqueId   = Convert.ToInt64(dtLotteryInfo.Rows[0]["DataUniqueId"].ToString());
                objGeneratedNo.DrawNo         = Convert.ToInt16(dtLotteryInfo.Rows[0]["DrawNo"].ToString());
                objGeneratedNo.DrawDate       = Convert.ToDateTime(dtLotteryInfo.Rows[0]["DrawDate"].ToString());
                objGeneratedNo.FnStart        = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnStart"].ToString());
                objGeneratedNo.FnEnd          = Convert.ToInt16(dtLotteryInfo.Rows[0]["FnEnd"].ToString());
                objGeneratedNo.AlphabetSeries = dtLotteryInfo.Rows[0]["AlphabetSeries"].ToString();
                objGeneratedNo.TnStart        = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnStart"].ToString());
                objGeneratedNo.TnEnd          = Convert.ToInt64(dtLotteryInfo.Rows[0]["TnEnd"].ToString());

                bool IsError = false;
                for (Int32 iCnt = 0; iCnt < dtExcelData.Rows.Count; iCnt++)
                {
                    string FirstInitialNo     = dtExcelData.Rows[iCnt][0].ToString();
                    string exclAlphabetSeries = dtExcelData.Rows[iCnt][1].ToString();
                    string TnStart            = dtExcelData.Rows[iCnt][2].ToString();
                    string TnEnd = dtExcelData.Rows[iCnt][3].ToString();
                    IsError = false;
                    if (isValidStartNo(objGeneratedNo.FnStart, objGeneratedNo.FnEnd, FirstInitialNo) == false)
                    {
                        TotError++;
                        IsError = true;
                        strMsg.AppendLine("Column " + 1 + " and Row No " + (iCnt + 2) + ": Invalid First Initial No");
                    }
                    if (isValidAlphabetSeries(objGeneratedNo.AlphabetSeries, exclAlphabetSeries) == false)
                    {
                        TotError++;
                        IsError = true;
                        strMsg.AppendLine("Column " + 2 + " and Row No " + (iCnt + 2) + ": Invalid Alphabets series");
                    }
                    if (isValidEndSeries(objGeneratedNo.TnStart, objGeneratedNo.TnEnd, TnStart, TnEnd) == false)
                    {
                        TotError++;
                        IsError = true;
                        strMsg.AppendLine("Column " + 3 + " and Row No " + (iCnt + 2) + ": Invalid End Range");
                    }
                    if (TotError > 10)
                    {
                        break;
                    }
                    ;
                    if (IsError == false)
                    {
                        string[] excelValues = exclAlphabetSeries.TrimEnd(',').Split(',');
                        for (int jCnt = 0; jCnt < excelValues.Length; jCnt++)
                        {
                            dataRw             = dtTicketRow.NewRow();
                            dataRw["FnNo"]     = FirstInitialNo;
                            dataRw["Alphabet"] = excelValues[jCnt].ToString().Trim();
                            dataRw["StartNo"]  = TnStart;
                            dataRw["EndNo"]    = TnEnd;
                            dtTicketRow.Rows.Add(dataRw);
                        }
                    }
                }

                if (strMsg.ToString().Trim().Length > 0)
                {
                    if (TotError > 10)
                    {
                        ErrorMsg = "There are more than 10 Error in the file  first 10 error are as below " + strMsg.ToString();
                    }
                    else
                    {
                        ErrorMsg = "There are " + TotError + " Error in the file as below " + strMsg.ToString();
                    }
                    var message = new JavaScriptSerializer().Serialize(ErrorMsg);
                    var script  = string.Format("alert({0});", message);
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
                    return(false);
                }

                #region Duplicate Ticket Check
                dtTicketRow.DefaultView.Sort = "FnNo ASC,Alphabet ASC,StartNo ASC,EndNo ASC";
                dtTicketRow = dtTicketRow.DefaultView.ToTable();

                DataTable distinctTable = dtTicketRow.DefaultView.ToTable(true);
                if (dtTicketRow.Rows.Count != distinctTable.Rows.Count)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Upload can not be completed.Duplicate Ticket No exist in file.');", true);
                    return(false);
                }
                Int32 StratRowCnt = 0;
                Int32 EndRowCnt   = 0;
                Int32 TicketCnt   = 0;
                for (int iCnt = 0; iCnt < dtTicketRow.Rows.Count; iCnt++)
                {
                    TicketCnt = TicketCnt + (Convert.ToInt32(dtTicketRow.Rows[iCnt][3].ToString()) - Convert.ToInt32(dtTicketRow.Rows[iCnt][2].ToString())) + 1;
                    for (int jCnt = iCnt + 1; jCnt < dtTicketRow.Rows.Count; jCnt++)
                    {
                        if ((dtTicketRow.Rows[iCnt][0].ToString() == dtTicketRow.Rows[jCnt][0].ToString()) &&
                            (dtTicketRow.Rows[iCnt][1].ToString() == dtTicketRow.Rows[jCnt][1].ToString()) &&
                            (
                                (
                                    (Convert.ToInt32(dtTicketRow.Rows[iCnt][2].ToString()) >= Convert.ToInt32(dtTicketRow.Rows[jCnt][2].ToString()) &&
                                     Convert.ToInt32(dtTicketRow.Rows[iCnt][2].ToString()) <= Convert.ToInt32(dtTicketRow.Rows[jCnt][3].ToString())
                                    )
                                    ||
                                    (Convert.ToInt32(dtTicketRow.Rows[iCnt][3].ToString()) >= Convert.ToInt32(dtTicketRow.Rows[jCnt][2].ToString()) &&
                                     Convert.ToInt32(dtTicketRow.Rows[iCnt][3].ToString()) <= Convert.ToInt32(dtTicketRow.Rows[jCnt][3].ToString())
                                    )
                                ) ||
                                (
                                    (Convert.ToInt32(dtTicketRow.Rows[jCnt][2].ToString()) >= Convert.ToInt32(dtTicketRow.Rows[iCnt][2].ToString()) &&
                                     Convert.ToInt32(dtTicketRow.Rows[jCnt][2].ToString()) <= Convert.ToInt32(dtTicketRow.Rows[iCnt][3].ToString())
                                    )
                                    ||
                                    (Convert.ToInt32(dtTicketRow.Rows[jCnt][3].ToString()) >= Convert.ToInt32(dtTicketRow.Rows[iCnt][2].ToString()) &&
                                     Convert.ToInt32(dtTicketRow.Rows[jCnt][3].ToString()) <= Convert.ToInt32(dtTicketRow.Rows[iCnt][3].ToString())
                                    )
                                )
                            )
                            )
                        {
                            StratRowCnt = iCnt;
                            EndRowCnt   = jCnt;
                            break;
                        }
                    }
                    if (StratRowCnt > 0 && EndRowCnt > 0)
                    {
                        break;
                    }
                }
                if (StratRowCnt > 0 && EndRowCnt > 0)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Upload can not be completed.Duplicate Ticket No exist within the range in file.');", true);
                    return(false);
                }

                #endregion

                #region Unsold Percentage count
                Int64  Qty        = Convert.ToInt64(txtQty.Text.Trim());
                Int64  SoldCount  = Convert.ToInt64(TicketCnt);
                double Percentage = 0;
                if (SoldCount > 0)
                {
                    try
                    {
                        Percentage = Convert.ToDouble((Convert.ToDouble(SoldCount) / Convert.ToDouble(Qty)) * 100);
                        if (Convert.ToDouble(txtUnSoldPercentage.Text.Trim()) > 0 && Percentage > Convert.ToDouble(txtUnSoldPercentage.Text.Trim()))
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('No of ticket percentage cannot be more than the " + txtUnSoldPercentage.Text.Trim() + "%.');", true);
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        objValidateData.SaveSystemErrorLog(ex, Request.UserHostAddress);
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Some Error occured while calculating un-Sold persantage. Please contact system administrator');", true);
                        return(false);
                    }
                }
                #endregion

                dtTicketRange = dtTicketRow.Copy();
                #region Validate ticker
                //for (Int16 colCnt = 0; colCnt < dtExcelData.Columns.Count; colCnt++)
                //{
                //    if (dtExcelData.Columns[colCnt].ToString().Trim() != "")
                //    {
                //        ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Columns[colCnt].ToString());
                //        if (ErrorMsg.Trim().Length > 0)
                //        {
                //            TotError++;
                //            strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No 1:" + ErrorMsg);
                //        }
                //        else {
                //            TicketNo = dtExcelData.Columns[colCnt].ToString().Trim();
                //            dr = dtTicketNumber.NewRow();
                //            dr["FnNo"] = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : TicketNo.Substring(0, objGeneratedNo.FnEnd.ToString().Length));
                //            dr["Alphabet"] = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? TicketNo.Substring(0, AlphabetLen) : TicketNo.Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                //            dr["TnNo"] = TicketNo.Substring(TicketNo.Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length);
                //            dtTicketNumber.Rows.Add(dr);
                //        }
                //        for (Int32 iCnt = 0; iCnt < dtExcelData.Rows.Count; iCnt++)
                //        {
                //            if (dtExcelData.Rows[iCnt][colCnt].ToString() != "")
                //            {
                //                ErrorMsg = objValidateData.ValidateTicketNo(objGeneratedNo, dtExcelData.Rows[iCnt][colCnt].ToString());
                //                if (ErrorMsg.Trim().Length > 0)
                //                {
                //                    TotError++;
                //                    if (TotError <= 10)
                //                    {
                //                        strMsg.AppendLine("Column " + (colCnt + 1) + " and Row No " + (iCnt + 1) + ": " + ErrorMsg);
                //                    }
                //                    if (TotError > 10) { break; };
                //                }
                //                else
                //                {
                //                    TicketNo = dtExcelData.Rows[iCnt][colCnt].ToString();
                //                    dr = dtTicketNumber.NewRow();
                //                    dr["FnNo"] = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? "0" : TicketNo.Substring(0, objGeneratedNo.FnEnd.ToString().Length));
                //                    dr["Alphabet"] = ((objGeneratedNo.FnStart == 0 && objGeneratedNo.FnEnd == 0) ? TicketNo.Substring(0, AlphabetLen) : TicketNo.Substring(objGeneratedNo.FnEnd.ToString().Length, AlphabetLen));
                //                    dr["TnNo"] = TicketNo.Substring(TicketNo.Length - objGeneratedNo.TnEnd.ToString().Length, objGeneratedNo.TnEnd.ToString().Length);
                //                    dtTicketNumber.Rows.Add(dr);
                //                }
                //            }
                //        }
                //    }
                //}


                #endregion
                #region Bind ticket in range
                // dtTicketNumber.DefaultView.Sort = "FnNo ASC,Alphabet ASC,TnNo ASC";
                // dtTicketNumber = dtTicketNumber.DefaultView.ToTable();
                // DataTable dtTicket = new DataTable();
                // dtTicket.TableName = "dtTicket";
                // DataRow dtRw = null;
                // dtTicket.Columns.Add(new DataColumn("FnNo", typeof(int)));
                // dtTicket.Columns.Add(new DataColumn("Alphabet", typeof(string)));
                //// dtTicket.Columns.Add(new DataColumn("TnNo", typeof(string)));
                // dtTicket.Columns.Add(new DataColumn("StartNo", typeof(Int64)));
                // dtTicket.Columns.Add(new DataColumn("EndNo", typeof(Int64)));
                // Int32 tempEndNo=0,rowCounter=0;
                // int FnNo = 0;
                // string Alphabet = "";
                // Int32 TnNo = 0;

                // bool isRowExist = true;
                // for (Int32 iCnt = 0; iCnt < dtTicketNumber.Rows.Count; iCnt++)
                // {
                //     FnNo = Convert.ToInt16(dtTicketNumber.Rows[iCnt]["FnNo"].ToString());
                //     Alphabet = dtTicketNumber.Rows[iCnt]["Alphabet"].ToString();
                //     TnNo = Convert.ToInt32(dtTicketNumber.Rows[iCnt]["TnNo"].ToString());
                //     isRowExist = false;
                //     if (dtTicket.Rows.Count > 0)
                //     {
                //         if ((FnNo == Convert.ToInt16(dtTicket.Rows[rowCounter]["FnNo"].ToString())) &&
                //             (Alphabet == dtTicket.Rows[rowCounter]["Alphabet"].ToString())
                //            )
                //         {
                //             isRowExist = true;
                //         }
                //     }
                //     if (isRowExist == false)
                //     {
                //         dtRw = dtTicket.NewRow();
                //         dtRw["FnNo"] = FnNo;
                //         dtRw["Alphabet"] = Alphabet;
                //        // dtRw["TnNo"] = TnNo;
                //         dtRw["StartNo"] = TnNo;
                //         dtRw["EndNo"] = TnNo;
                //         dtTicket.Rows.Add(dtRw);
                //         tempEndNo = TnNo + 1;
                //         rowCounter = dtTicket.Rows.Count-1;
                //     }

                //     if (isRowExist == true && TnNo == tempEndNo)
                //     {
                //         dtTicket.Rows[rowCounter]["EndNo"] = tempEndNo;
                //         tempEndNo = TnNo+1;
                //     }
                //     else if (isRowExist == true && TnNo > tempEndNo)
                //     {
                //         FnNo = Convert.ToInt16(dtTicketNumber.Rows[iCnt]["FnNo"].ToString());
                //         Alphabet = dtTicketNumber.Rows[iCnt]["Alphabet"].ToString();
                //         TnNo = Convert.ToInt32(dtTicketNumber.Rows[iCnt]["TnNo"].ToString());

                //         dtRw = dtTicket.NewRow();
                //         dtRw["FnNo"] = FnNo;
                //         dtRw["Alphabet"] = Alphabet;
                //        // dtRw["TnNo"] = TnNo;
                //         dtRw["StartNo"] = TnNo;
                //         dtRw["EndNo"] = TnNo;
                //         dtTicket.Rows.Add(dtRw);
                //         tempEndNo = TnNo + 1;
                //         rowCounter = dtTicket.Rows.Count-1;
                //     }
                // }
                // dtTicketRange = dtTicket.Copy();
                //// dtTicketRange = dtTicket;

                // dtExcelData.Clear();
                // dtExcelData = null;

                // dtTicket.Clear();
                // dtTicket = null;
                #endregion
            }
            return(true);
        }