private void uploadButton_Click(object sender, EventArgs e)
 {
     if (urlTexBox.Text != String.Empty)
     {
         OthersGateway othersGateway = new OthersGateway();
         try
         {
             string     image  = urlTexBox.Text;
             FileStream fs     = new FileStream(image, FileMode.Open, FileAccess.Read);
             byte[]     bimage = new byte[fs.Length];
             fs.Read(bimage, 0, Convert.ToInt32(fs.Length));
             fs.Close();
             int rowAffect = othersGateway.uploadLogo(bimage);
             if (rowAffect > 0)
             {
                 cMessageBox.Success("Logo Uploaded Successfully");
             }
             else
             {
                 cMessageBox.Failed("Faild To upload");
             }
         }
         catch (Exception)
         {
             cMessageBox.Failed("Select a Vaild Image and Try again");
         }
     }
 }
Esempio n. 2
0
        private void getCodeButton_Click(object sender, EventArgs e)
        {
            if (!Email.IsMatch(emailTextBox.Text.Trim()))
            {
                cMessageBox.Information("Your Email is not Correct");
            }
            else
            {
                string ma    = emailTextBox.Text;
                string mas   = ma.Substring(0, 5);
                string scode = "SA-" + DateTime.Now.ToString("MM-dd") + "-";
                for (int i = 0; i <= mas.Length; i++)
                {
                    scode += scode + mas.Substring(0, 3) + i;
                }
                char[] charArray = scode.ToCharArray();
                Array.Reverse(charArray);
                string codes      = new string(charArray);
                string newCode    = codes.Substring(28, 62);
                bool   connection = NetworkInterface.GetIsNetworkAvailable();
                if (connection == true)
                {
                    try
                    {
                        string         doc           = "No Data is Set";
                        OthersGateway  othersGateway = new OthersGateway();
                        IntroduceModel introduction  = othersGateway.GetInformation();
                        if (introduction != null)
                        {
                            string ins   = introduction.InstituteName;
                            string email = introduction.Email;
                            string add   = introduction.Address;

                            string mob   = introduction.Mobile;
                            string owner = introduction.OwnerName;
                            doc = "Document for : " + ins + ", \nEmail:" + email + ",\n Address :" + add + ",\n Mobile :" + mob + ",\nOwner :" + owner;
                        }
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add("*****@*****.**");
                        mail.Subject           = "Activation For : " + emailTextBox.Text;
                        mail.Body              = doc + "\nCode: " + newCode;
                        SmtpServer.Port        = 587;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "@gmail.doeasily.coart");
                        SmtpServer.EnableSsl   = true;
                        int rowAffect = userGateway.InsertCode(newCode);
                        if (rowAffect > 0)
                        {
                            SmtpServer.Send(mail);
                            cMessageBox.Success("Your Code has been Generated, You will get an Email in short Time.");
                        }
                        else
                        {
                            cMessageBox.Failed("Faild, Try Again or Contact with Developer");
                        }
                    }
                    catch (Exception)
                    {
                        cMessageBox.Failed("Failed to Generate Code");
                    }
                }
                else
                {
                    cMessageBox.Warning("No Internet Connection");
                }
            }
        }