예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            correct = true;

            Email_Notice_Template newTemplate = new Email_Notice_Template();

            if (txtDescription.Text == "")
            {
                MessageBox.Show("Please enter a Template Description");
                correct = false;
            }

            if (txtText.Text == "")
            {
                MessageBox.Show("Please enter Template Text");
                correct = false;
            }
            if (correct == true)
            {
                newTemplate.Template_Description = txtDescription.Text;
                newTemplate.Template_Text        = txtText.Text;


                db.Email_Notice_Template.Add(newTemplate);

                db.SaveChanges();

                int    Template_ID    = newTemplate.Template_Id;
                string Template_Value = Convert.ToString(newTemplate);

                //Audit_Log Current_Audit = new Audit_Log();
                //Current_Audit.Table_Name = "Marketing_Template";
                //Current_Audit.User_ID = Globals.User_ID;
                //Current_Audit.Date_Time = DateTime.Now;
                //db.Audit_Log.Add(Current_Audit);
                //db.SaveChanges();
                //int Log_ID = Current_Audit.Audit_Log_ID;

                //Audit_Create_Delete Current_Create = new Audit_Create_Delete();
                //Current_Create.Audit_Log_ID = Log_ID;
                //Current_Create.Created = true;
                //Current_Create.PK_Row_Effected = Marketing_Template_ID;
                //Current_Create.Value = Marketing_Template_Value;
                //db.Audit_Create_Delete.Add(Current_Create);
                //db.SaveChanges();


                MessageBox.Show("Template Successfully Created");



                //MessageBox.Show("Please enter all required fields");
                //MessageBox.Show("Are you sure you want to create this notification template ?", "confirmation", MessageBoxButtons.YesNo);
                //MessageBox.Show("Email notification template has been created successfully");
            }
        }
예제 #2
0
        private void Add_Click(object sender, EventArgs e)
        {
            correct = true;

            Email_Notice_Template newTemplate = new Email_Notice_Template();

            if (txtDescription.Text == "")
            {
                MessageBox.Show("Please enter a Template Description");
                correct = false;
            }

            if (txtText.Text == "")
            {
                MessageBox.Show("Please enter Template Text");
                correct = false;
            }
            if (correct == true)
            {
                newTemplate.Template_Description = txtDescription.Text;
                newTemplate.Template_Text        = txtText.Text;


                db.Email_Notice_Template.Add(newTemplate);

                db.SaveChanges();

                int    Template_ID    = newTemplate.Template_Id;
                string Template_Value = Convert.ToString(newTemplate);



                Audit_Log Current_Audit = new Audit_Log();
                Current_Audit.Table_Name = "Notification Template";
                Current_Audit.Users_Id   = Globals.Users_Id;
                Current_Audit.Date_Time  = DateTime.Now;
                db.Audit_Log.Add(Current_Audit);
                db.SaveChanges();
                int Log_ID = Current_Audit.Audit_Log_Id;

                Audit_Create_Delete Current_Create = new Audit_Create_Delete();
                Current_Create.Audit_Log_Id    = Log_ID;
                Current_Create.Created         = true;
                Current_Create.PK_Row_Effected = Template_ID;
                Current_Create.Value           = Template_Value;
                db.Audit_Create_Delete.Add(Current_Create);
                db.SaveChanges();
                MessageBox.Show("Notification template created successfully");
                this.Close();
            }
        }
예제 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Would you like to delete this Template?", "Delete Template", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    Email_Notice_Template template = new Email_Notice_Template();
                    template = db.Email_Notice_Template.Find(tempID);

                    db.Email_Notice_Template.Remove(template);
                    db.SaveChanges();

                    int    Marketing_Template_ID    = template.Template_Id;
                    string Marketing_Template_Value = Convert.ToString(template);

                    Audit_Log Current_Audit = new Audit_Log();
                    Current_Audit.Table_Name = "Marketing_Template";
                    Current_Audit.Users_Id   = Globals.Users_Id;
                    Current_Audit.Date_Time  = DateTime.Now;
                    db.Audit_Log.Add(Current_Audit);
                    db.SaveChanges();
                    int Log_ID = Current_Audit.Audit_Log_Id;

                    Audit_Create_Delete Current_Create = new Audit_Create_Delete();
                    Current_Create.Audit_Log_Id    = Log_ID;
                    Current_Create.Created         = false;
                    Current_Create.PK_Row_Effected = Marketing_Template_ID;
                    Current_Create.Value           = Marketing_Template_Value;
                    db.Audit_Create_Delete.Add(Current_Create);
                    db.SaveChanges();


                    MessageBox.Show("Notification Template Successfully Deleted");
                    this.Close();
                }

                catch (Exception)
                {
                    MessageBox.Show("Error has occured, and template was not deleted successfully");
                }
            }
        }