Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                // string AlphabetSeries = "";
                DataTable dtInfo = new DataTable();
                if (IsValidEntry() == false)
                {
                    return;
                }                                       //Check for valid data entry
                objLottery.LotteryName       = txtLotteryName.Text.Trim();
                objLottery.LotteryTypeId     = Convert.ToInt16(ddlLotteryType.SelectedValue.ToString());
                objLottery.NoOfDigit         = Convert.ToInt16(txtNoOfDigit.Text);
                objLottery.SyndicateRate     = Convert.ToDouble(txtSyndicateRate.Text);
                objLottery.RateForSpl        = Convert.ToDouble(txtRateForSpl.Text);
                objLottery.TotTicketRate     = Convert.ToDouble(txtTotTicketRate.Text);
                objLottery.GstRate           = Convert.ToDouble(txtGstRate.Text);
                objLottery.PrizeCategory     = Convert.ToInt16(txtPrizeCategory.Text);
                objLottery.IncludeConsPrize  = chkIncludeConsPrize.Checked;
                objLottery.ClaimDays         = Convert.ToInt16(txtClaimDays.Text.Trim());
                objLottery.ClaimDaysVariable = Convert.ToInt16(txtClaimDaysVariable.Text.Trim());
                objLottery.SizeOfTicket      = txtSizeOfTicket.Text.Trim();
                objLottery.PaperQuality      = txtPaperQuality.Text.Trim();
                objLottery.UserId            = ((ClsUserInfo)Session["UserInfo"]).UserId;
                objLottery.IpAdd             = Request.UserHostAddress;
                if (hdUniqueId.Value.ToString().Trim() == "")
                {
                    dtInfo = objLtmsService.GetLotteryDtlByName(objLottery.LotteryName);
                    if (dtInfo.Rows.Count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery Name Already Exist. Duplicate Lottery name not allowed');", true);
                        return;
                    }
                    bool IsAdded = objLtmsService.InsertInLottery(objLottery);
                    if (IsAdded == true)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery Type information Saved successfully.');", true);
                    }
                }
                else
                {
                    objLottery.DataUniqueId = hdUniqueId.Value.ToString().Trim();
                    if (dtInfo.Rows.Count > 0)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery Name Already Exist. Duplicate Lottery name not allowed');", true);
                        return;
                    }


                    bool IsUpdated = objLtmsService.UpdateInLottery(objLottery);
                    if (IsUpdated == true)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery Type information updated successfully.');", true);
                    }
                }
                BindGvData();
                btnCancel_Click(sender, e);
            }
            catch (Exception Ex)
            {
                objValidateData.SaveSystemErrorLog(Ex, Request.UserHostAddress);
                var message = new JavaScriptSerializer().Serialize("Some Error has occurred while performing your activity. Please contact the System Administrator for further assistance.");
                var script  = string.Format("alert({0});", message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true);
            }
        }