Example #1
0
    protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            if (txtDetails.Text != "")
            {
                objdt = new DataTable();
                int    Count        = 0;
                int    messageCount = 0;
                string Student      = "";
                string MobileNO     = "";
                string FinalMessage = "";
                foreach (GridViewRow li in griduser.Rows)
                {
                    Label    lblStudentID = (Label)li.FindControl("lblstudent");
                    Label    lblMobile    = (Label)li.FindControl("lblMobile");
                    CheckBox cb           = (CheckBox)li.FindControl("chkStudent");
                    if (objdt.Rows.Count == 0)
                    {
                        if (cb != null && cb.Checked)
                        {
                            Student  = Student + lblStudentID.Text + ",";
                            MobileNO = MobileNO + lblMobile.Text + ",";
                            Count    = Count + 1;
                        }
                    }
                }

                if (lblCredit.Text != "" || lblCredit.Text != "No Credits Available. Please Buy Credits.")
                {
                    string[] NoofMessage = lblCredit.Text.Split(':');
                    messageCount = Convert.ToInt32(NoofMessage[1].ToString());
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(btnSubmit, btnSubmit.GetType(), "test", "alert('Message Credit is not Available');", true);
                }
                if (messageCount >= Count)
                {
                    //objStd.Std_id = Convert.ToInt32(DropDownListStandard.SelectedValue);
                    //objStd.Action = "I";
                    //objStd.Student_Id = Student.Remove(Student.Length - 1);
                    //objdt = objStd.Insert_Regular_SMS();

                    //Final Deliver// FinalMessage = FinalMessage + "Dear Member," + Environment.NewLine + "This is to inform that" + Environment.NewLine + txtDetails.Text + Environment.NewLine + "On " + Environment.NewLine + txtDate2.Text + " at " + ddlhour.SelectedValue;
                    FinalMessage = FinalMessage + "Dear Member," + Environment.NewLine + "This is to inform that" + Environment.NewLine + txtDetails.Text;

                    /*For Multiple Number */
                    MobileNO = MobileNO.Remove(MobileNO.Length - 1);

                    //string ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<URLsmsSendsms>\r\n  <SMSAuthentication>\r\n    <UserID>[email protected]</UserID>\r\n    <Password>modasa009</Password>\r\n  </SMSAuthentication>\r\n  <StartSMSSend>\r\n    <SenderID Text=\"GECMOD\">\r\n      [Message]\r\n    </SenderID>\r\n  </StartSMSSend>\r\n</URLsmsSendsms>";
                    string ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<URLsmsSendsms>\r\n  <SMSAuthentication>\r\n    <UserID>[email protected]</UserID>\r\n    <Password>epilpa009</Password>\r\n  </SMSAuthentication>\r\n  <StartSMSSend>\r\n    <SenderID Text=\"EPILPA\">\r\n      [Message]\r\n    </SenderID>\r\n  </StartSMSSend>\r\n</URLsmsSendsms>";

                    string str1 = "<SendSMS>\r\n        <SMStext>";
                    string str2 = "</SMStext>\r\n        <Recipients>";
                    string str3 = "</Recipients>\r\n      </SendSMS>";
                    string str4 = "";

                    str4 = str4 + str1 + FinalMessage + str2 + MobileNO + str3 + "\r\n";

                    /**********************/
                    ret = ret.Replace("[Message]", str4);
                    DataSet ds = new DataSet();
                    ds = objStd.SendSMSViaXML(ret);
                    Response.Write("<script>alert('SMS Send SucessFully...!!!!');</script>");
                    clear();
                    /**********************/

                    //DataSet ds = new DataSet();
                    //ds = objStd.SendSMSViaXML(ret);
                    //if (ds.Tables.Count > 0)
                    //{
                    //    DataTable NewTable = objStd.NewSendSMS(System.DateTime.Now.ToString("dd/MM/yyyy").ToString().Replace('-', '/'));
                    //    if (NewTable.Rows.Count > 0)
                    //    {
                    //        //GrdMsgStatus.DataSource = NewTable;
                    //        //   GrdMsgStatus.DataBind();
                    //    }
                    //    else
                    //    {
                    //        //GrdMsgStatus.DataSource = null;
                    //        // GrdMsgStatus.DataBind();
                    //    }
                    //}
                    //else
                    //{
                    //    // GrdMsgStatus.DataSource = null;
                    //    // GrdMsgStatus.DataBind();
                    //}
                }

                else
                {
                    ScriptManager.RegisterClientScriptBlock(btnSubmit, btnSubmit.GetType(), "test", "alert('Message Credit is not Available');", true);
                    //imgbtnCal.Focus();
                }
            }
            else
            {
            }
            // clear();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Example #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (validation() == 1)
            {
                clsreg             = new Registration();
                objdt              = new DataTable();
                objds              = new DataSet();
                clsreg.UserID      = Convert.ToInt32(txtid.Text);
                clsreg.UserType    = ddlMemberType.SelectedValue;
                clsreg.YearOfStart = txtYearOfStart.Text;
                clsreg.UAddress    = txtAddress.Text;
                clsreg.Sex         = ddlSex.SelectedValue;
                clsreg.Residence   = txtResidence.Text;
                //  clsreg.AcYear = txtAcYear.Text;
                //  clsreg.AdFeeRs = txtAdFeeRs.Text;
                clsreg.Company = txtCompany.Text;
                clsreg.Fax     = txtFax.Text;
                //  clsreg.MeFeeRs = txtMeFeeRs.Text;
                clsreg.Mobile           = txtMobile.Text;
                clsreg.NatureOfActivity = txtNatureOfActivity.Text;
                clsreg.OAddress         = txtOAddress.Text;
                clsreg.PhoneOffice      = txtPhoneOffice.Text;
                clsreg.UName            = txtMemberName.Text;
                clsreg.UEmailID         = txtEmailID.Text;
                clsreg.CBankBranch      = txtbankbranch.Text;
                clsreg.CBankName        = txtbank.Text;
                clsreg.CCHqueAmount     = txtcqAmount.Text;
                clsreg.SrNo             = Convert.ToInt32(txtsrno.Text);
                if (txtCqdate.Text != "")
                {
                    clsreg.CChqueDate = Convert.ToDateTime(txtCqdate.Text);
                }
                clsreg.CChqueNo = txtcqnumber.Text;
                if (Upload1.HasFile || (hdnPhotoName.Value != "" && hdnPhotoData.Value != ""))
                {
                    if (Upload1.HasFile)
                    {
                        string filename = Upload1.FileName;
                        string ext      = Path.GetExtension(filename);


                        #region imageconvert
                        Stream       fs    = Upload1.PostedFile.InputStream;
                        BinaryReader br    = new BinaryReader(fs);
                        Byte[]       bytes = br.ReadBytes((Int32)fs.Length);
                        clsreg.PhotoData = bytes;
                        #endregion

                        #region imageconvert
                        Stream       fs1    = Upload2.PostedFile.InputStream;
                        BinaryReader br1    = new BinaryReader(fs1);
                        Byte[]       bytes1 = br1.ReadBytes((Int32)fs1.Length);
                        clsreg.PhotoData1 = bytes1;
                        #endregion
                        //Stream fs = Upload1.PostedFile.InputStream;
                        //BinaryReader br = new BinaryReader(fs);
                        //Byte[] bytes = br.ReadBytes((Int32)fs.Length);
                        //string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                        //string Final = "data:image/png;base64," + base64String;
                        //postFile = this.Upload1.PostedFile;
                        //bt = ReadImageFile(postFile.FileName, new string[] { ".GIF", ".gif", ".jpg", ".bmp" });
                        hdnPhotoName.Value = filename;
                        //clsreg.PhotoData =bytes[0];
                        hdnPhotoType.Value = ext;
                        //Image1.ImageUrl = Final;
                    }
                    else
                    {
                        if (hdnPhotoName.Value != "" && hdnPhotoData.Value != "")
                        {
                            Image1.ImageUrl = hdnPhotoData.Value;
                        }
                    }


                    clsreg.PhotoName = hdnPhotoName.Value;
                    // clsreg.PhotoData = ;
                }

                //if (Upload2.HasFile || (hdnIdname.Value != "" && HdnIdData.Value != ""))
                //{
                //    if (Upload2.HasFile)
                //    {
                //        string filename = Upload2.FileName;
                //        string ext = Path.GetExtension(filename);


                //        Stream fs = Upload2.PostedFile.InputStream;+
                //        BinaryReader br = new BinaryReader(fs);
                //        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
                //        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                //        string Final = "data:image/png;base64,"  base64String;

                //        hdnIdname.Value = filename;
                //        HdnIdData.Value = Final;
                //        hdnIdType.Value = ext;

                //        Image2.ImageUrl = Final;
                //    }
                //    else
                //    {
                //        if (hdnIdname.Value != "" && HdnIdData.Value != "")
                //        {
                //            Image2.ImageUrl = HdnIdData.Value;

                //        }
                //    }
                //}
                clsreg.Action = "InsertReg";
                objdt         = clsreg.Registration1();
                if (objdt.Rows[0][0].ToString() == "1")
                {
                    //===================For Members EMAIL ======================
                    //==============================================================

                    string subject;
                    string body;
                    string to   = txtEmailID.Text;
                    string from = "*****@*****.**";

                    string      ErrMsg;
                    int         RegID = Convert.ToInt32(txtsrno.Text.Trim());
                    MailMessage email = new MailMessage(from, to);
                    //   Image img = http://localhost:1900/Epilpa31Decnew/images/symbol.jpg
                    // string path = Server.MapPath(@"images/symbol.jpg");
                    // LinkedResource logo = new LinkedResource(path);
                    //  logo.ContentId = "Company Logo";
                    //AlternateView Av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/><br></body></html>");
                    //  Av1.LinkedResources.Add(logo);
                    // MailMessage MAIL = new MailMessage(from, to);

                    //email.Attachments.Add(new Attachment(flupld.PostedFile.InputStream, flupld.FileName));

                    email.Subject    = "Registration";
                    email.IsBodyHtml = true;
                    email.Body       = "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Hello Customer,</b><br><br><br>Thank you for registration on our website www.epilpa.org<BR><BR> Your RegistrationID is :" + (RegID) + "<BR><BR> It takes some time to acivate your Account. <BR><BR> You will be updated through E-Mail<BR><br><b>From,<br>www.epilpa.org<BR>(Team)</b><br><img src=\"cid:images/logo.jpg\"></font>";
                    string     FileName   = "";
                    SmtpClient mailclient = new SmtpClient();
                    System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("*****@*****.**", "BYJ^$#@3");
                    mailclient.Host    = "smtp.epilpa.org";
                    mailclient.Port    = 25;
                    mailclient.Timeout = 100000;

                    mailclient.UseDefaultCredentials = false;
                    mailclient.Credentials           = basicAuthenticationInfo;
                    ErrMsg = string.Empty;

                    try
                    {
                        mailclient.Send(email);
                        //return 1;
                    }
                    catch (Exception ex)
                    {
                        ErrMsg = ex.Message;
                        //return 0;
                    }
                    //=====================================================
                    //=====================================================



                    //===========================For Admin EMAIL ======================
                    //==================================================================

                    string      subject1;
                    string      body1;
                    string      to1   = "*****@*****.**";
                    string      from1 = "*****@*****.**";
                    string      image1;
                    string      ErrMsg1;
                    int         RegID1 = Convert.ToInt32(txtsrno.Text.Trim());
                    MailMessage email1 = new MailMessage(from1, to1);


                    //email.Attachments.Add(new Attachment(flupld.PostedFile.InputStream, flupld.FileName));

                    email1.Subject    = "Registration";
                    email1.IsBodyHtml = true;
                    email1.Body       = "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Hello Admin,</b><br><br><br>One new Registration on our website www.epilpa.org<BR><BR>Member RegistrationID is :" + (RegID) + "<BR><BR>  <BR><BR> <BR><br><b>From,<br>www.epilpa.org<BR>(Team)</b></font>";

                    string FileName1 = "";
                    //if (image.ToString() != "")
                    //{
                    //    FileName = Path.GetFileName(image);
                    //    Attachment attach1 = new Attachment(HttpContext.Current.Server.MapPath(image));
                    //    /* Attach the newly created email attachment */

                    //    email.Attachments.Add(attach1);
                    //}
                    //else
                    //{
                    //}
                    SmtpClient mailclient1 = new SmtpClient();
                    System.Net.NetworkCredential basicAuthenticationInfo1 = new System.Net.NetworkCredential("*****@*****.**", "BYJ^$#@3");
                    mailclient.Host    = "smtp.epilpa.org";
                    mailclient.Port    = 25;
                    mailclient.Timeout = 100000;

                    mailclient.UseDefaultCredentials = false;
                    mailclient.Credentials           = basicAuthenticationInfo;
                    ErrMsg1 = string.Empty;

                    try
                    {
                        mailclient.Send(email1);
                        //return 1;
                    }
                    catch (Exception ex)
                    {
                        ErrMsg1 = ex.Message;
                        //return 0;
                    }


                    //===================SMS============================================
                    //===================================================================


                    int Count        = 0;
                    int messageCount = 0;
                    //  string Student = "";
                    string MobileNO     = "";
                    string FinalMessage = "";

                    if (lblCredit.Text != "")
                    {
                        string[] NoofMessage = lblCredit.Text.Split(':');
                        if (NoofMessage[1].ToString() != "")
                        {
                            messageCount = Convert.ToInt32(NoofMessage[1].ToString());
                        }
                    }
                    if (messageCount >= Count)
                    {
                        SMS.Action     = "I";
                        SMS.Student_Id = txtsrno.Text;
                        Objdt          = SMS.Insert_Exam_Fee_SMS();

                        FinalMessage = FinalMessage + "Your details are registered successfully." + Environment.NewLine + "Registration id: " + txtsrno.Text + "" + Environment.NewLine + "Login will be activated after approval" + Environment.NewLine + "from admin." + Environment.NewLine + "Regards" + Environment.NewLine + "EPILPA TEAM";

                        // FinalMessage = FinalMessage + " Your details are registered successfully. Membership id:" +txtid.Text+ "Login will be activated after approval from admin. Regards EPILPA TEAM ";



                        /*For Multiple Number */
                        MobileNO = txtMobile.Text;

                        //string ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<URLsmsSendsms>\r\n  <SMSAuthentication>\r\n    <UserID>[email protected]</UserID>\r\n    <Password>modasa009</Password>\r\n  </SMSAuthentication>\r\n  <StartSMSSend>\r\n    <SenderID Text=\"GECMOD\">\r\n      [Message]\r\n    </SenderID>\r\n  </StartSMSSend>\r\n</URLsmsSendsms>";
                        string ret = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<URLsmsSendsms>\r\n  <SMSAuthentication>\r\n    <UserID>[email protected]</UserID>\r\n    <Password>epilpa009</Password>\r\n  </SMSAuthentication>\r\n  <StartSMSSend>\r\n    <SenderID Text=\"EPILPA\">\r\n      [Message]\r\n    </SenderID>\r\n  </StartSMSSend>\r\n</URLsmsSendsms>";

                        string str1 = "<SendSMS>\r\n        <SMStext>";
                        string str2 = "</SMStext>\r\n        <Recipients>";
                        string str3 = "</Recipients>\r\n      </SendSMS>";
                        string str4 = "";

                        str4 = str4 + str1 + FinalMessage + str2 + MobileNO + str3 + "\r\n";

                        /**********************/
                        ret = ret.Replace("[Message]", str4);
                        DataSet ds = new DataSet();
                        ds = objStd.SendSMSViaXML(ret);
                        /**********************/



                        //    //=====================================================================
                        //    //=====================================================================
                    }

                    //  Response.Redirect("index.aspx");
                }
                else
                {
                    Response.Write("<script>alert('This E-mail or UserId is Already Exists...!!!!');</script>");
                }
                Response.Write("<script>alert('Thanks For Registration...!!!!');</script>");
                Clear();
            }
        }



        //else
        //{
        //    lblMess.Text = "You are already registered with us with this E-Mail ID";
        //}
        catch (Exception ex)
        {
            throw ex;
        }
    }