예제 #1
0
        protected void btnAddPrinter_Click(object sender, EventArgs e)
        {
            BussinessObject.Printer printer = new BussinessObject.Printer();

            printer.PrinterName          = txtprintername1.Text;
            printer.FolderToMonitor      = txtfoldertomonitor1.Text;
            printer.OutputType           = txtoutputtype1.Text;
            printer.FileOutput           = txtfileoutput1.Text;
            printer.PrinterMakeID        = Convert.ToInt32(cbprintermake1.SelectedValue);
            printer.Status               = 1;
            printer.CreatedDate          = DateTime.Now;
            printer.LastModificationDate = DateTime.Now;

            if (radactive.Checked)
            {
                printer.Active = 1;
            }
            else
            {
                printer.Active = 0;
            }

            Bussinesslogic.UserBL userBL = new Bussinesslogic.UserBL();

            int result = userBL.SavePrinter(printer);

            if (result > 0)
            {
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Printer has been added successfully')", true);
            }
            Server.TransferRequest(Request.Url.AbsolutePath, false);
        }
예제 #2
0
        protected void RegisterBtnSave_Click(object sender, EventArgs e)
        {
            String   dateofbirth = RadDatePicker.SelectedDate.ToString();
            DateTime date1       = DateTime.Parse(dateofbirth);
            String   date        = date1.ToString("dd/MM/yyyy");

            DateTime datetime = DateTime.ParseExact(date, "dd/MM/yyyy", null);

            datetime = Convert.ToDateTime(datetime, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);


            reg.LastName  = txtlastname.Text;
            reg.FirstName = txtfirstname.Text;
            reg.Email     = txtemail.Text;
            reg.UserName  = (string)Session["User"];
            reg.Password  = txtpassword.Text;
            reg.Address   = txtaddress.Text;
            reg.DOB       = datetime;


            Bussinesslogic.UserBL objUBL = new Bussinesslogic.UserBL();
            int result = objUBL.UserUpdate(reg.UserName, reg);

            if (result > 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Data saved successfully')", true);
            }
        }
예제 #3
0
        protected void CreateUser()
        {
            BussinessObject.CreateUser reg = new BussinessObject.CreateUser();

            reg.LastName             = txtlastname.Text;
            reg.FirstName            = txtfirstname.Text;
            reg.DesignationID        = Convert.ToInt32(txtdesignation.SelectedValue);
            reg.Email                = txtlastname.Text + "@printers.com";
            reg.UserName             = txtfirstname.Text + txtlastname.Text;
            reg.Password             = "******";
            reg.Address              = txtaddress.Text;
            reg.DOB                  = (DateTime)RadDatePicker.SelectedDate;
            reg.CreatedDate          = DateTime.Now;
            reg.LastModificationDate = DateTime.Now;


            Bussinesslogic.UserBL objUBL = new Bussinesslogic.UserBL();
            int result = objUBL.UserRegistration(reg);

            if (result > 0)
            {
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('User has been created successfully')", true);
            }
            //Send Email
            MailMessage Msg = new MailMessage();

            Msg.From    = new MailAddress("*****@*****.**", "Admin"); // Sender details here, replace with valid value
            Msg.Subject = ("New Registration");                                 // subject of email
            Msg.To.Add(reg.Email);                                              //Add Email id, to which we will send email
            Msg.Body       = ("Dear" + reg.FirstName + '\n' + "You have been registered on the Company Printers employee system.Your login details are as follows:" + '\n' + '\n' + "Username" + reg.UserName + '\n' + reg.Password + '\n' + '\n' + "Kind Regards" + '\n' + "Admin");
            Msg.IsBodyHtml = true;
            Msg.Priority   = MailPriority.High;



            SmtpClient smtp = new SmtpClient();

            smtp.UseDefaultCredentials = false; // to get rid of error "SMTP server requires a secure connection"
            smtp.Host        = "smtp.gmail.com";
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "MrFeather123456");// replace with valid value
            smtp.EnableSsl   = true;
            smtp.Timeout     = 20000;



            //smtp.Send(Msg);
        }