Ejemplo n.º 1
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            int    Status = 0;
            string UserId = ((ClsUserInfo)Session["UserInfo"]).UserId;
            string IpAdd  = Request.UserHostAddress;

            try
            {
                if (hdUniqueId.Value.ToString().Trim() != "")
                {
                    if (((Button)sender).CommandName == "Printed")
                    {
                        Status = 17;
                    }

                    bool isGenerated = objLtmsService.GenerateLotteryNumberDtlById(Convert.ToInt64(hdUniqueId.Value.ToString().Trim()), Status);
                    if (isGenerated == true)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Information Saved successfully.');", true);
                    }

                    if (((Button)sender).CommandName == "Printed" && isGenerated == true)
                    {
                        UserId = "";
                        string    UserEmailId = "";
                        DataTable dtInfo      = objLtmsService.GetRequisitionDtlById(Convert.ToInt64(hdUniqueId.Value));
                        if (dtInfo.Rows.Count > 0)
                        {
                            UserId = dtInfo.Rows[0]["CreatedBy"].ToString();
                            DataTable dtUser = objLtmsService.GetEmailToDtlByType("CHALLAN");
                            if (dtUser.Rows.Count > 0)
                            {
                                string        emailOtpSendStatus = "";
                                string        MailSubject        = "Ticket Printed For Requisition " + dtInfo.Rows[0]["ReqCode"].ToString();
                                StringBuilder strMessage         = new StringBuilder();
                                strMessage.AppendLine("<table id='tblOTP' cellpadding='0' cellspacing='0' border='0' width='650px'>");
                                strMessage.AppendLine("     <tr style='border:solid 1px;'><td><b>Ticket Printed</b></td></tr>");
                                strMessage.AppendLine("     <tr><td><b>Ticket Printed For Requisition " + dtInfo.Rows[0]["ReqCode"].ToString() + " and  for Qty. " + dtInfo.Rows[0]["Qty"].ToString() + "</b></td></tr>");
                                strMessage.AppendLine("</table>");

                                for (int iCnt = 0; iCnt < dtUser.Rows.Count; iCnt++)
                                {
                                    UserEmailId        = dtUser.Rows[iCnt]["EmailId"].ToString();
                                    emailOtpSendStatus = objValidateData.SendEmail(UserEmailId, MailSubject, strMessage.ToString());
                                }

                                if (emailOtpSendStatus == "SUCCESSFULL")
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Ticket Printed and Email successfully sent to distributor.');", true);
                                }
                                else if (emailOtpSendStatus == "UNSUCCESSFULL")
                                {
                                    ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Ticket Printed successfully and Email not sent to distributor due to some error.');", 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);
            }
        }