Example #1
0
    //public Datatable AJAX_GetTable_CustomerAddress(int iDisplayLength, int iDisplayStart, int sEcho, int iSortingCols, int iSortCol, string sSortDir, string search)
    //{
    //    try
    //    {
    //        IEnumerable<dynamic> data = Dynamic_GetAll_ByEmail();
    //        int count = data.Count();
    //        if (!string.IsNullOrEmpty(search))
    //            data = data.Where(x =>
    //                x.FirstName.ToLower().Contains(search.ToLower()) ||
    //        x.LastName.ToLower().Contains(search.ToLower()) ||
    //                x.Email.ToLower().Contains(search.ToLower())
    //                ).ToArray();
    //        List<Dictionary<string, dynamic>> resultList = new List<Dictionary<string, dynamic>>();
    //        foreach (dynamic currData in data)
    //        {
    //            Dictionary<string, dynamic> newData = new Dictionary<string, dynamic>();
    //            newData.Add("IDCustomer", currData.IDCustomer);
    //            newData.Add("Name", currData.FirstName + ' ' + currData.LastName);
    //            newData.Add("Email", currData.Email);
    //            newData.Add("Active", currData.Active);
    //            newData.Add("PhoneNumber", currData.PhoneNumber);
    //            resultList.Add(newData);
    //        }
    //        return OurClass.ParseTable(resultList, count, iDisplayLength, iDisplayStart, sEcho, iSortingCols, iSortCol, sSortDir);
    //    }
    //    catch (Exception ex)
    //    {
    //        throw;
    //    }
    //}

    public ReturnData AJAX_Insert(int idCustomer, int idCountry, int idProvince, int idCity, int idDistrict, string peoplename, string name, string address, string phone, string postalCode, string additionalInformation)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            TBAddress _newAddress     = new TBAddress
            {
                IDCustomer            = idCustomer,
                IDCountry             = idCountry,
                IDProvince            = idProvince,
                IDCity                = idCity,
                IDDistrict            = idDistrict,
                PeopleName            = peoplename,
                Name                  = name,
                Address               = address,
                Phone                 = phone,
                PostalCode            = postalCode,
                AdditionalInformation = additionalInformation,
                Active                = true,
                Deflag                = false,
                DateInsert            = DateTime.Now,
                DateLastUpdate        = DateTime.Now
            };
            db.TBAddresses.InsertOnSubmit(_newAddress);
            db.SubmitChanges();
            return(ReturnData.MessageSuccess("Address submit successfully", _newAddress.IDAddress));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Example #2
0
    public ReturnData AJAX_Update(int idAddress, int idCustomer, int idCountry, int idProvince, int idCity, int idDistrict, string peopleName, string name, string address, string phone, string postalCode, string additionalInformation, bool active)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            TBAddress data            = db.TBAddresses.Where(x => !x.Deflag && x.IDCustomer == idCustomer && x.IDAddress == idAddress).FirstOrDefault();
            if (data == null)
            {
                return(ReturnData.MessageFailed("Data not found", null));
            }
            data.IDCountry             = idCountry;
            data.IDProvince            = idProvince;
            data.IDCity                = idCity;
            data.IDDistrict            = idDistrict;
            data.Name                  = name;
            data.Address               = address;
            data.Phone                 = phone;
            data.PeopleName            = peopleName;
            data.PostalCode            = postalCode;
            data.AdditionalInformation = additionalInformation;
            data.Active                = active;
            data.DateLastUpdate        = DateTime.Now;

            db.SubmitChanges();
            return(ReturnData.MessageSuccess("Address has been updated successfully", null));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Example #3
0
        private void BAddToPayroll_Click(object sender, EventArgs e)    //Fires upon clicking the "Add" button
        {
            try
            {
                float    test = 0.0f;
                Employee temp = new Employee();                 //making employee to add to payroll
                temp.FirstName               = TBEmployeeNameFirst.Text;
                temp.LastName                = TBEmployeeNameLast.Text;
                temp.PhoneNumber             = TBPhoneNumber.Text;
                temp.Address.StreetAddress   = TBAddress.Text;
                temp.Address.ApartmentNumber = TBApartmentNumber.Text;
                temp.Address.City            = TBCity.Text;
                temp.Address.State           = TBState.Text;
                temp.Address.ZipCode         = TBZipCode.Text;
                temp.Title = TBJobTitle.Text;
                if (float.TryParse(TBWage.Text, out test))      //sanity check for wage
                {
                    temp.Wage = float.Parse(TBWage.Text);
                }
                temp.IsOnPayroll = CBIsOnPayroll.Checked;
                if (float.TryParse(TBHoursWorked.Text, out test))       //sanity check for hours worked
                {
                    temp.HoursWorked = float.Parse(TBHoursWorked.Text);
                }
                payroll[employeeIndex] = temp;                 //adds employee to payroll

                PayrollList.Items.Add(payroll[employeeIndex]); //adds employee to visible payroll
                employeeIndex++;                               //increment index
            }
            catch (PhoneNumberException)                       //Exception handling!
            {
                MessageBox.Show("Phone numbers must be ten digits!");
            }
            catch (WageException)
            {
                MessageBox.Show("Can't have negative wages!");
            }
            catch (TimeWorkedException)
            {
                MessageBox.Show("Can't have negative hours worked!");
            }
            catch (Exception)
            {
                MessageBox.Show("Something is wrong.\nThat's all we know.");
            }
            TBEmployeeNameFirst.Clear();        //returning fields to their default state
            TBEmployeeNameLast.Clear();
            TBPhoneNumber.Clear();
            TBAddress.Clear();
            TBApartmentNumber.Clear();
            TBCity.Clear();
            TBState.Clear();
            TBZipCode.Clear();
            TBJobTitle.Clear();
            TBWage.Clear();
            CBIsOnPayroll.Checked = false;
            TBHoursWorked.Clear();
        }
Example #4
0
        public CETableItemEditor()
        {
            InitializeComponent();
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += Timer_Tick;
            timer.Start();
            TBAddress.Focus();
        }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TBFName.Text == "")
         {
             lbDisplay.Content = "First name box is eympty please enter correct info";
         }
         else if (TBLName.Text == "")
         {
             lbDisplay.Content = "Last name box is eympty please enter correct info";
         }
         else if (TBMID.Text == "")
         {
             lbDisplay.Content = "Major ID box is eympty please enter correct info";
         }
         else if (TBEmail.Text == "")
         {
             lbDisplay.Content = "E-mail box is eympty please enter correct info";
         }
         else if (TBAddress.Text == "")
         {
             lbDisplay.Content = "Address box is eympty please enter correct info";
         }
         else if (TBPhone.Text == "")
         {
             lbDisplay.Content = "Phone number box is eympty please enter correct info";
         }
         else
         {
             lbDisplay.Content = "";
             MessageBox.Show("E-Mail has been sent to the board to be checked over.");
             TBFName.Clear();
             TBLName.Clear();
             TBMID.Clear();
             TBEmail.Clear();
             TBAddress.Clear();
             TBPhone.Clear();
         }
     }
     catch
     {
     }
 }
Example #6
0
    public ReturnData AJAX_GetDetail(int idAddress, int idCustomer)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            TBAddress selected        = db.TBAddresses.Where(x => !x.Deflag && x.IDAddress == idAddress && x.IDCustomer == idCustomer).FirstOrDefault();
            if (selected == null)
            {
                return(ReturnData.MessageFailed("Data not found", null));
            }
            return(ReturnData.MessageSuccess("OK", Dynamic_GetDetail_ByIDAddress(idAddress)));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Example #7
0
    public ReturnData AJAX_Delete(int idAddress, int idCustomer)
    {
        try
        {
            DataClassesDataContext db = new DataClassesDataContext();
            TBAddress selectedData    = db.TBAddresses.Where(x => !x.Deflag && x.IDCustomer == idCustomer && x.IDAddress == idAddress).FirstOrDefault();
            if (selectedData == null)
            {
                return(ReturnData.MessageFailed("Data not found", null));
            }

            selectedData.Deflag = true;
            db.SubmitChanges();
            return(ReturnData.MessageSuccess("Address has been deleted successfully", null));
        }
        catch (Exception ex)
        {
            Class_Log_Error log = new Class_Log_Error();
            log.Insert(ex.Message, ex.StackTrace);

            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }
Example #8
0
        private void BModifyDone_Click(object sender, EventArgs e)           //fires on clicking the "Done" button
        {
            int index = PayrollList.Items.IndexOf(PayrollList.SelectedItem); //gets the index of the selected employee in the visible payroll

            Employee emp = (Employee)PayrollList.SelectedItem;               //copies the selected employee from the visible payroll to the backend

            PayrollList.Items.Remove(PayrollList.SelectedItem);              //removes the selected visible employee

            try
            {                                                   //alters the employee's data in the backend payroll using same methods as creating
                float test = 0.0f;
                emp.FirstName               = TBEmployeeNameFirst.Text;
                emp.LastName                = TBEmployeeNameLast.Text;
                emp.PhoneNumber             = TBPhoneNumber.Text;
                emp.Address.StreetAddress   = TBAddress.Text;
                emp.Address.ApartmentNumber = TBApartmentNumber.Text;
                emp.Address.City            = TBCity.Text;
                emp.Address.State           = TBState.Text;
                emp.Address.ZipCode         = TBZipCode.Text;
                emp.Title = TBJobTitle.Text;
                if (float.TryParse(TBWage.Text, out test))
                {
                    emp.Wage = float.Parse(TBWage.Text);
                }
                emp.IsOnPayroll = CBIsOnPayroll.Checked;
                if (float.TryParse(TBHoursWorked.Text, out test))
                {
                    emp.HoursWorked = float.Parse(TBHoursWorked.Text);
                }

                BModifyDone.Visible = false;    //hides the "Done" button

                BAddToPayroll.Visible = true;   //shows the "Add" button

                BModifyEmployee.Visible = true; //shows the "Edit" button

                BPayEmployee.Visible = true;    //shows the "Pay" button
            }
            catch (PhoneNumberException)        //Exception handling!
            {
                MessageBox.Show("Phone numbers must be ten digits!");
            }
            catch (WageException)
            {
                MessageBox.Show("Can't have negative wages!");
            }
            catch (TimeWorkedException)
            {
                MessageBox.Show("Can't have negative hours worked!");
            }
            catch (Exception)
            {
                MessageBox.Show("Something is wrong.\nThat's all we know.");
            }

            PayrollList.Items.Insert(index, emp); //"refreshes" the visible employee with the correct info

            TBEmployeeNameFirst.Clear();          //returns fields to the default state
            TBEmployeeNameLast.Clear();
            TBPhoneNumber.Clear();
            TBAddress.Clear();
            TBApartmentNumber.Clear();
            TBCity.Clear();
            TBState.Clear();
            TBZipCode.Clear();
            TBJobTitle.Clear();
            TBWage.Clear();
            CBIsOnPayroll.Checked = false;
            TBHoursWorked.Clear();
        }
Example #9
0
    public ReturnData AJAX_FE_RegisterCustomGroup(string firstName, string lastName, string gender, string email, string password, string phoneNumber, DateTime birthday, bool isSubscribe, string addressname, string address, string postalCode, int idCountry, int idProvince, int idCity, int idDistrict, int idCustomerGroup, string DeliveryAddressName)
    {
        try
        {
            using (DataClassesDataContext db = new DataClassesDataContext())
            {
                if (idCustomerGroup == 3)
                {
                    if (IsExistsEmail(email))
                    {
                        return(ReturnData.MessageFailed("Email is already registered, Please update following customer data", null));
                    }

                    var        customerGroup = db.TBCustomer_Groups.Where(x => x.IDCustomer_Group == idCustomerGroup).FirstOrDefault();
                    TBCustomer _newCust      = new TBCustomer();
                    _newCust.FirstName        = firstName;
                    _newCust.LastName         = lastName;
                    _newCust.Gender           = gender;
                    _newCust.Email            = email;
                    _newCust.Password         = EncryptPassword(password);
                    _newCust.PhoneNumber      = phoneNumber;
                    _newCust.Birthday         = birthday;
                    _newCust.IsSubscribe      = isSubscribe;
                    _newCust.Active           = true;
                    _newCust.DateInsert       = DateTime.Now;
                    _newCust.DateLastUpdate   = DateTime.Now;
                    _newCust.IDCustomer_Group = idCustomerGroup;
                    db.TBCustomers.InsertOnSubmit(_newCust);
                    //db.SubmitChanges();

                    TBAddress _newAddress = new TBAddress();
                    _newAddress.TBCustomer     = _newCust;
                    _newAddress.IDCountry      = idCountry;
                    _newAddress.IDProvince     = idProvince;
                    _newAddress.IDCity         = idCity;
                    _newAddress.IDDistrict     = idDistrict;
                    _newAddress.Name           = addressname;
                    _newAddress.Address        = address;
                    _newAddress.Phone          = _newCust.PhoneNumber;
                    _newAddress.PostalCode     = postalCode;
                    _newAddress.PeopleName     = DeliveryAddressName;
                    _newAddress.Active         = true;
                    _newAddress.DateInsert     = DateTime.Now;
                    _newAddress.DateLastUpdate = DateTime.Now;
                    db.TBAddresses.InsertOnSubmit(_newAddress);
                    db.SubmitChanges();

                    Dictionary <string, dynamic> result = new Dictionary <string, dynamic>();
                    result.Add("IDCustomer", _newCust.IDCustomer);
                    result.Add("IDAddress", _newAddress.IDAddress);

                    //SEND EMAIL
                    using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/assets/email-template/template-email-register.html")))
                    {
                        Class_Configuration _config = new Class_Configuration();
                        var    emailLogo            = _config.Dynamic_Get_EmailLogo();
                        string body = "";
                        body = reader.ReadToEnd();
                        body = body.Replace("{name}", _newCust.FirstName);
                        body = body.Replace("{email}", _newCust.Email);
                        body = body.Replace("{password}", password);
                        body = body.Replace("{title}", System.Configuration.ConfigurationManager.AppSettings["Title"]);
                        body = body.Replace("{email_logo}", System.Configuration.ConfigurationManager.AppSettings["url"] + "/assets/images/email_logo/" + emailLogo);
                        body = body.Replace("{shop_url}", System.Configuration.ConfigurationManager.AppSettings["url"]);
                        OurClass.SendEmail(_newCust.Email, WebConfigurationManager.AppSettings["Title"] + " Account Registration", body, "");
                    }

                    return(ReturnData.MessageSuccess("Register success", result));
                }
                else
                {
                    var adminOrder = db.TBCustomers.Where(x => x.IDCustomer_Group == 4 && x.Email.ToLower() == email).FirstOrDefault();
                    if (adminOrder == null)
                    {
                        return(ReturnData.MessageFailed("Account not found", null));
                    }

                    TBAddress _newAddress = new TBAddress();
                    _newAddress.IDCustomer     = adminOrder.IDCustomer;
                    _newAddress.IDCountry      = idCountry;
                    _newAddress.IDProvince     = idProvince;
                    _newAddress.IDCity         = idCity;
                    _newAddress.IDDistrict     = idDistrict;
                    _newAddress.Name           = addressname;
                    _newAddress.Address        = address;
                    _newAddress.Phone          = phoneNumber;
                    _newAddress.PostalCode     = postalCode;
                    _newAddress.PeopleName     = DeliveryAddressName;
                    _newAddress.Active         = true;
                    _newAddress.DateInsert     = DateTime.Now;
                    _newAddress.DateLastUpdate = DateTime.Now;
                    db.TBAddresses.InsertOnSubmit(_newAddress);
                    db.SubmitChanges();

                    Dictionary <string, dynamic> result = new Dictionary <string, dynamic>();
                    result.Add("IDCustomer", adminOrder.IDCustomer);
                    result.Add("IDAddress", _newAddress.IDAddress);

                    return(ReturnData.MessageSuccess("Register success", result));
                }
            }
        }
        catch (Exception ex)
        {
            return(ReturnData.MessageFailed(ex.Message, null));
        }
    }