Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            correct = true;

            if (correct == true)
            {
                try
                {
                    var query = db.Company_Information.FirstOrDefault();

                    query.Company_Name        = txtCompName.Text;
                    query.Company_Address     = txtCompAddress.Text;
                    query.VAT_Percentage      = Convert.ToDecimal(txtVatPerc.Text);
                    query.VAT_Number          = txtVatNumb.Text;
                    query.Registration_Number = txtRegNumber.Text;
                    query.Email_Address       = txtEmailAddr.Text;
                    query.Telephone_Number    = txtTelNumber.Text;

                    db.SaveChanges();
                    MessageBox.Show("Company information updated successfully");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured" + ex);
                }
            }


            // MessageBox.Show("Please fill in all required fields");
        }
Esempio n. 3
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");
            }
        }
Esempio n. 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Client                NewCllient = new Client();
            Credit_Approval       NewCA      = new Credit_Approval();
            City                  newCity    = new City();
            Credit_Status         crStatus   = new Credit_Status();
            Client_Account_Status cAS        = new Client_Account_Status();
            Province              NewProv    = new Province();

            try
            {
                NewCllient.Client_Name           = "Thabang";
                NewCllient.Client_VAT_Reg_Number = "123";
                NewCllient.Client_Telephone      = "123";
                NewCllient.Client_Fax_Number     = "123";
                NewCllient.Client_Email_Address  = "Thabang@gmail";
                NewCllient.Physical_Address      = "Feast str";

                int Province = 0;
                var Prov     = db.Provinces.Where(emp => emp.Province_Name == txtProvince.Text).Select(u => u.Province_Id).FirstOrDefault();
                Province            = Prov;
                NewProv.Province_Id = Province;

                int City = 0;
                var Cty  = db.Cities.Where(emp => emp.City_Name == txtCity.Text).Select(u => u.City_Id).FirstOrDefault();
                City            = Cty;
                newCity.City_Id = City;

                NewCA.Credit_Approval_Amount = 1000;


                int Credit  = 0;
                var cstatus = db.Credit_Status.Where(emp => emp.Credit_Status_Description == txtCreditSta.Text).Select(u => u.Credit_Status_ID).FirstOrDefault();
                Credit = cstatus;
                crStatus.Credit_Status_ID = Credit;

                NewCA.Authourised_By       = "Thabang";
                NewCA.Date_Of_Commencement = txtDateTimeDateOfCommencement.Value.Date;

                int AccntStat = 0;
                var atat      = db.Client_Account_Status.Where(emp => emp.Account_Status_Description == comboBox5.Text).Select(u => u.Account_Status_ID).FirstOrDefault();

                AccntStat = atat;

                cAS.Account_Status_ID = AccntStat;

                NewCA.Credit_Approval_Form = FileData;

                //FK relationships
                NewCllient.Province_Id        = NewProv.Province_Id;
                NewCllient.City_Id            = newCity.City_Id;
                NewCllient.Credit_Approval_ID = NewCA.Credit_Approval_ID;
                NewCllient.Account_Status_ID  = cAS.Account_Status_ID;

                //Credit status table--not in client
                NewCA.Credit_Status_ID = crStatus.Credit_Status_ID;



                //Saving to indv tables
                db.Clients.Add(NewCllient);
                int myClient = NewCllient.Client_ID;

                db.Credit_Approval.Add(NewCA);
                int myCrApproval = NewCA.Credit_Approval_ID;

                //  db.Cities.Add(newCity);
                //==int myCty = newCity.City_Id;


                // db.Client_Account_Status.Add(cAS);
                //== int myAccstats = cAS.Account_Status_ID;
                db.SaveChanges();

                MessageBox.Show("Client Has been Added succesfully");

                int    Client_Id       = NewCllient.Client_ID;
                string Marketing_Value = Convert.ToString(NewCllient);

                Audit_Log Current_Audit3 = new Audit_Log();
                Current_Audit3.Table_Name = "Client";
                Current_Audit3.Users_Id   = Globals.Users_Id;
                Current_Audit3.Date_Time  = DateTime.Now;
                db.Audit_Log.Add(Current_Audit3);
                db.SaveChanges();
                int Log_ID3 = Current_Audit3.Audit_Log_Id;


                Audit_Create_Delete Current_Create3 = new Audit_Create_Delete();
                Current_Create3.Audit_Log_Id    = Log_ID3;
                Current_Create3.Created         = true;
                Current_Create3.PK_Row_Effected = Client_Id;
                Current_Create3.Value           = Marketing_Value;
                db.Audit_Create_Delete.Add(Current_Create3);
                db.SaveChanges();

                //MessageBox.Show("Are you sure you want to add this client ?", "confirmation", MessageBoxButtons.YesNo);
                //MessageBox.Show("Client details have been added successfully");
                //MessageBox.Show("Client already exists on the system");
                //MessageBox.Show("Please fill in all required fields");
                //MessageBox.Show("Please select a client");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Whoops, Something went wrong. Please try again" + ex);
            }
        }
Esempio n. 5
0
        private void btnUpdateClient_Click(object sender, EventArgs e)
        {
            correct = true;

            Client                NewCllient = new Client();
            Credit_Approval       NewCA      = new Credit_Approval();
            City                  newCity    = new City();
            Credit_Status         crStatus   = new Credit_Status();
            Client_Account_Status cAS        = new Client_Account_Status();
            Province              NewProv    = new Province();

            if (txtName.Text == "" || txtVatRegNum.Text == "" || txtTelephone.Text == "" || txtFaxNumber.Text == "" || txtEmailAdd.Text == "" || txtPhysicalAdd.Text == "" || txtApprovedBy.Text == "")
            {
                MessageBox.Show("Please enter all fields!");
                correct = false;
            }


            DialogResult dialogResult = MessageBox.Show("Would you like to update the client Information ?", "Update Template", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (correct == true)
                {
                    try
                    {
                        if (correct == true)
                        {
                            NewCllient.Client_Name           = txtName.Text;
                            NewCllient.Client_VAT_Reg_Number = txtVatRegNum.Text;
                            NewCllient.Client_Telephone      = txtTelephone.Text;
                            NewCllient.Client_Fax_Number     = txtFaxNumber.Text;
                            NewCllient.Client_Email_Address  = txtEmailAdd.Text;
                            NewCllient.Physical_Address      = txtPhysicalAdd.Text;

                            int Province = 0;
                            var Prov     = db.Provinces.Where(emp => emp.Province_Name == txtProvince.Text).Select(u => u.Province_Id).FirstOrDefault();
                            Province            = Prov;
                            NewProv.Province_Id = Province;

                            int City = 0;
                            var Cty  = db.Cities.Where(emp => emp.City_Name == txtCity.Text).Select(u => u.City_Id).FirstOrDefault();
                            City            = Cty;
                            newCity.City_Id = City;

                            NewCA.Credit_Approval_Amount = Convert.ToDecimal(txtAmount.Text);


                            int Credit  = 0;
                            var cstatus = db.Credit_Status.Where(emp => emp.Credit_Status_Description == txtCreditSta.Text).Select(u => u.Credit_Status_ID).FirstOrDefault();
                            Credit = cstatus;
                            crStatus.Credit_Status_ID = Credit;

                            NewCA.Authourised_By       = txtApprovedBy.Text;
                            NewCA.Date_Of_Commencement = txtDateTimeDateOfCommencement.Value.Date;

                            int AccntStat = 0;
                            var atat      = db.Client_Account_Status.Where(emp => emp.Account_Status_Description == comboBox5.Text).Select(u => u.Account_Status_ID).FirstOrDefault();

                            AccntStat = atat;

                            cAS.Account_Status_ID = AccntStat;

                            NewCA.Credit_Approval_Form = FileData;

                            //FK relationships
                            NewCllient.Province_Id        = NewProv.Province_Id;
                            NewCllient.City_Id            = newCity.City_Id;
                            NewCllient.Credit_Approval_ID = NewCA.Credit_Approval_ID;
                            NewCllient.Account_Status_ID  = cAS.Account_Status_ID;

                            //Credit status table--not in client
                            NewCA.Credit_Status_ID = crStatus.Credit_Status_ID;



                            //Saving to indv tables
                            db.Clients.Add(NewCllient);
                            int myClient = NewCllient.Client_ID;

                            db.Credit_Approval.Add(NewCA);
                            int myCrApproval = NewCA.Credit_Approval_ID;

                            //  db.Cities.Add(newCity);
                            //==int myCty = newCity.City_Id;


                            // db.Client_Account_Status.Add(cAS);
                            //== int myAccstats = cAS.Account_Status_ID;
                            db.SaveChanges();

                            MessageBox.Show("Client Has been updated succesfully");
                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error has occured, and template was not updated successfully" + ex);
                    }
                }
            }
        }
Esempio n. 6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            correct = true;

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

            DialogResult dialogResult = MessageBox.Show("Would you like to update this Template?", "Update Template", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (correct == true)
                {
                    try
                    {
                        if (correct == true)
                        {
                            var query = db.Email_Notice_Template.Where(co => co.Template_Id == tempID).FirstOrDefault();

                            query.Template_Description = txtDescription.Text;
                            query.Template_Text        = txtText.Text;
                            db.SaveChanges();

                            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;

                            if (txtText.Text != iText)
                            {
                                Audit_Update Update_Name1 = new Audit_Update();
                                Update_Name1.PK_Row_Effected = Convert.ToInt32(query.Template_Id);
                                Update_Name1.Field_Effected  = "Text";
                                Update_Name1.Before_Value    = iText.ToString();
                                Update_Name1.After_Value     = txtText.Text.ToString();
                                Update_Name1.Audit_Log_Id    = Log_ID;
                                db.Audit_Update.Add(Update_Name1);
                                db.SaveChanges();
                            }
                            if (txtDescription.Text != Desc)
                            {
                                Audit_Update Update_Name2 = new Audit_Update();
                                Update_Name2.PK_Row_Effected = Convert.ToInt32(query.Template_Id);
                                Update_Name2.Field_Effected  = "Description";
                                Update_Name2.Before_Value    = Desc.ToString();
                                Update_Name2.After_Value     = txtDescription.Text.ToString();
                                Update_Name2.Audit_Log_Id    = Log_ID;
                                db.Audit_Update.Add(Update_Name2);
                                db.SaveChanges();
                            }

                            MessageBox.Show("Marketing Template Successfully Updated");
                            this.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error has occured, and template was not updated successfully" + ex);
                    }
                }
            }
        }