示例#1
0
        private void SendBillToAttendant(OrderModel o)
        {
            string to      = (GlobalConfig.Connection.GetPersonByFullName(o.Attendant)).EmailAddress;
            string subject = "Bill";

            StringBuilder body = new StringBuilder();

            body.AppendLine($"<h1>{ o.Attendant }, A bill is ready to pay</h1>");
            body.AppendLine($"<h2><strong>Table: { o.TableNumber }</strong></h2>");
            body.AppendLine(".......................................................................");

            foreach (FoodModel f in o.FoodOrdered)
            {
                body.Append($"<br><strong>{ f.FoodType } &emsp { f.FoodName }: &emsp { f.Price } &emsp { f.Quantity }</stong></br>");
            }

            body.AppendLine(".......................................................................");

            body.Append($"<br><strong>Subtotal: &emsp { subTotal }</strong></br>");
            body.Append($"<br><strong>Tax: &emsp { tax }</strong></br>");
            body.Append($"<br><strong>Total: &emsp { total }</strong></br>");

            EmailLogic.SendEmail(to, subject, body.ToString());
        }
示例#2
0
        private void sendEmailsButton_Click(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.emailContent == null)
            {
                LogLabel(logLabel, "Compose email first.", Color.Red);

                return;
            }

            if (employeeList.Count == 0)
            {
                LogLabel(logLabel, "Add employee to list first.", Color.Red);

                return;
            }

            if (passwordBox.TextLength == 0)
            {
                LogLabel(logLabel, "Enter password.", Color.Red);

                return;
            }

            List <PersonModel> selectedEmployees = new List <PersonModel>();

            if (!sendToTeamsCheckbox.Checked)
            {
                if (employeeListbox.SelectedItems.Count == 0)
                {
                    selectedEmployees = employeeList.ToList();
                }
                else
                {
                    foreach (PersonModel item in employeeListbox.SelectedItems)
                    {
                        selectedEmployees.Add(item);
                    }
                }
            }
            else
            {
                List <TeamModel> selectedTeams = new List <TeamModel>();

                if (teamListbox.SelectedItems.Count == 0)
                {
                    selectedTeams = teamList.ToList();
                }
                else
                {
                    foreach (TeamModel t in teamListbox.SelectedItems)
                    {
                        foreach (PersonModel p in t.TeamMembers)
                        {
                            selectedEmployees.Add(p);
                        }
                    }
                }
            }

            try
            {
                using (SmtpClient smtp = EmailLogic.CreateSmtp(Properties.Settings.Default.smtp,
                                                               int.Parse(Properties.Settings.Default.smtpPort), Properties.Settings.Default.email, passwordBox.Text))
                {
                    foreach (PersonModel p in selectedEmployees)
                    {
                        EmailLogic.logs.Add($"Sending Email to {p.FullName}");
                        logListbox.Refresh();
                        logListbox.TopIndex = logListbox.Items.Count - 1;

                        EmailLogic.logs.Add(EmailLogic.SendEmail(Properties.Settings.Default.emailContent, p, smtp, Properties.Settings.Default.email));
                        logListbox.Refresh();
                        logListbox.TopIndex = logListbox.Items.Count - 1;
                    }
                }
            }
            catch (Exception exc)
            {
                EmailLogic.logs.Add("Something went wrong. ");
                EmailLogic.logs.Add(exc.Message);

                logListbox.Refresh();
                logListbox.TopIndex = logListbox.Items.Count - 1;
            }

            passwordBox.Text = "";
        }
示例#3
0
    protected void lnkBtnUpdate_Click(object sender, EventArgs e)
    {
        BusinessLogic objBus  = new BusinessLogic();
        DBManager     manager = new DBManager(DataProvider.SqlServer);

        manager.ConnectionString = objBus.CreateConnectionString(System.Configuration.ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ConnectionString);

        string enabledate = string.Empty;

        enabledate = rdvoudateenable.SelectedValue;

        try
        {
            manager.Open();
            manager.ExecuteNonQuery(CommandType.Text, "Update last_recon Set recon_date='" + Convert.ToDateTime(txtReconDate.Text).ToString("yyyy-MM-dd") + "'");

            manager.ExecuteNonQuery(CommandType.Text, "UPDATE tblSettings SET KEYVALUE = '" + enabledate.ToString() + "' WHERE KEYNAME='ENBLDATE' ");

            string salestype  = string.Empty;
            int    ScreenNo   = 0;
            string ScreenName = string.Empty;

            salestype  = "Lock Transaction";
            ScreenName = "Lock Transaction";


            string usernam = Request.Cookies["LoggedUserName"].Value;

            bool          mobile       = false;
            bool          Email        = false;
            string        emailsubject = string.Empty;
            string        connection   = Request.Cookies["Company"].Value;
            BusinessLogic bl           = new BusinessLogic();

            string emailcontent = string.Empty;
            if (hdEmailRequired.Value == "YES")
            {
                var   toAddress     = "";
                var   toAdd         = "";
                Int32 ModeofContact = 0;
                int   ScreenType    = 0;



                DataSet dsdd = bl.GetDetailsForScreenNo(connection, ScreenName, "");
                if (dsdd != null)
                {
                    if (dsdd.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dsdd.Tables[0].Rows)
                        {
                            ScreenType   = Convert.ToInt32(dr["ScreenType"]);
                            mobile       = Convert.ToBoolean(dr["mobile"]);
                            Email        = Convert.ToBoolean(dr["Email"]);
                            emailsubject = Convert.ToString(dr["emailsubject"]);
                            emailcontent = Convert.ToString(dr["emailcontent"]);

                            if (ScreenType == 1)
                            {
                                toAddress = toAdd;
                            }
                            else
                            {
                                toAddress = dr["EmailId"].ToString();
                            }
                            if (Email == true)
                            {
                                string body = "\n";

                                int index123 = emailcontent.IndexOf("@Branch");
                                body = Request.Cookies["Company"].Value;
                                if (index123 >= 0)
                                {
                                    emailcontent = emailcontent.Remove(index123, 7).Insert(index123, body);
                                }

                                int index312 = emailcontent.IndexOf("@User");
                                body = usernam;
                                if (index312 >= 0)
                                {
                                    emailcontent = emailcontent.Remove(index312, 5).Insert(index312, body);
                                }

                                int index2 = emailcontent.IndexOf("@Date");
                                body = txtReconDate.Text;
                                if (index2 >= 0)
                                {
                                    emailcontent = emailcontent.Remove(index2, 5).Insert(index2, body);
                                }

                                string smtphostname = ConfigurationManager.AppSettings["SmtpHostName"].ToString();
                                int    smtpport     = Convert.ToInt32(ConfigurationManager.AppSettings["SmtpPortNumber"]);
                                var    fromAddress  = ConfigurationManager.AppSettings["FromAddress"].ToString();

                                string fromPassword = ConfigurationManager.AppSettings["FromPassword"].ToString();

                                EmailLogic.SendEmail(smtphostname, smtpport, fromAddress, toAddress, emailsubject, emailcontent, fromPassword);

                                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Email sent successfully')", true);
                            }
                        }
                    }
                }
            }

            string     conn    = bl.CreateConnectionString(Request.Cookies["Company"].Value);
            UtilitySMS utilSMS = new UtilitySMS(conn);
            string     UserID  = Page.User.Identity.Name;

            string smscontent = string.Empty;
            if (hdSMSRequired.Value == "YES")
            {
                var   toAddress     = "";
                var   toAdd         = "";
                Int32 ModeofContact = 0;
                int   ScreenType    = 0;

                DataSet dsdd = bl.GetDetailsForScreenNo(connection, ScreenName, "");
                if (dsdd != null)
                {
                    if (dsdd.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dsdd.Tables[0].Rows)
                        {
                            ScreenType = Convert.ToInt32(dr["ScreenType"]);
                            mobile     = Convert.ToBoolean(dr["mobile"]);
                            smscontent = Convert.ToString(dr["smscontent"]);

                            if (ScreenType == 1)
                            {
                                toAddress = toAdd;
                            }
                            else
                            {
                                toAddress = dr["mobile"].ToString();
                            }
                            if (mobile == true)
                            {
                                string body = "\n";

                                int index123 = smscontent.IndexOf("@Branch");
                                body = Request.Cookies["Company"].Value;
                                if (index123 >= 0)
                                {
                                    smscontent = emailcontent.Remove(index123, 7).Insert(index123, body);
                                }

                                int index312 = smscontent.IndexOf("@User");
                                body = usernam;
                                if (index312 >= 0)
                                {
                                    smscontent = smscontent.Remove(index312, 5).Insert(index312, body);
                                }

                                int index2 = smscontent.IndexOf("@Date");
                                body = txtReconDate.Text;
                                if (index2 >= 0)
                                {
                                    smscontent = smscontent.Remove(index2, 5).Insert(index2, body);
                                }

                                if (Session["Provider"] != null)
                                {
                                    utilSMS.SendSMS(Session["Provider"].ToString(), Session["Priority"].ToString(), Session["SenderID"].ToString(), Session["UserName"].ToString(), Session["Password"].ToString(), toAddress, smscontent, true, UserID);
                                }
                            }
                        }
                    }
                }
            }


            //errorDisplay.AddItem("Recon Date updated successfully." , DisplayIcons.GreenTick,false);
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Recon Date updated successfully.');", true);
            return;
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
示例#4
0
        public ActionResult AddEditUsuario(AddEditUsuarioViewModel ViewModel)
        {
            try
            {
                if (ViewModel.UsuarioId.HasValue)
                {
                    Usuario Usuario = context.Usuario.FirstOrDefault(x => x.UsuarioId == ViewModel.UsuarioId);
                    Usuario.Nombres   = ViewModel.Nombres;
                    Usuario.Apellidos = ViewModel.Apellidos;
                    Usuario.Codigo    = ViewModel.Codigo;
                    Usuario.Password  = ViewModel.Password;
                    Usuario.Estado    = ViewModel.Estado;
                    Usuario.Email     = ViewModel.Email;

                    context.Entry(Usuario).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();
                }
                else
                {
                    Usuario Usuario = context.Usuario.FirstOrDefault(X => X.Codigo == ViewModel.Codigo);

                    if (Usuario == null)
                    {
                        Usuario = new Usuario();
                    }

                    Usuario.Nombres        = ViewModel.Nombres;
                    Usuario.Apellidos      = ViewModel.Apellidos;
                    Usuario.Codigo         = ViewModel.Codigo;
                    Usuario.Password       = ViewModel.Password;
                    Usuario.Rol            = ConstantHelpers.ROL_PROPIETARIO;
                    Usuario.DepartamentoId = ViewModel.DepartamentoId;
                    Usuario.Estado         = "TEM";
                    Usuario.Email          = ViewModel.Email;
                    context.Usuario.Add(Usuario);



                    context.SaveChanges();


                    if (!String.IsNullOrEmpty(Usuario.Email))
                    {
                        EmailLogic logic    = new EmailLogic(this, CargarDatosContext());
                        var        edificio = context.Edificio.Include(X => X.Departamento).FirstOrDefault(X => X.Departamento.Any(Y => Y.DepartamentoId == (Usuario.DepartamentoId ?? -1)));
                        if (edificio != null)
                        {
                            RegisterNewUserViewModel model = new RegisterNewUserViewModel();
                            model.Password = Usuario.Password;
                            model.Nombre   = Usuario.Nombres;
                            model.Usuario  = Usuario.Codigo;
                            var archivos = new List <String>();
                            archivos.Add(Path.Combine(Server.MapPath("~/Content"), "Intranet Afari.pdf"));
                            logic.SendEmail("Usuario Afari", "RegistroUsuario", "*****@*****.**", "Afari", Usuario.Email, model, archivos, String.Empty, String.Empty);
                        }
                    }
                }

                PostMessage(MessageType.Success);
            }
            catch (Exception ex) { PostMessage(MessageType.Error, "Error tecnico: " + ex.Message.ToString()); }
            return(RedirectToAction("LstUsuario", new { DepartamentoId = ViewModel.DepartamentoId, EdificioId = ViewModel.EdificioId }));
        }