public static bool login(user ExisitingUser, MetroForm ui)
 {
     try
     {
         row = UserDataTable.FindByusername(ExisitingUser.username);
         if (row == null)
         {
             MSG.ERROR(ui, "User Doesn't Exists in the System");
             return(false);
         }
         if ((row.username.ToString() == ExisitingUser.username) && (row.password.ToString() == ExisitingUser.password))
         {
             MSG.SUCCESS(ui, "Login Success.!");
             ui.Hide();
             frm_dashboard n = new frm_dashboard();
             n.ShowDialog();
             ui.Close();
             return(true);
         }
         else
         {
             MSG.ERROR(ui, "Username and Password Doesn't Match!");
             return(false);
         }
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MSG.ERROR(ui, "Login Error.!, " + ex.Message);
         return(false);
     }
 }
 private void btn_save_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txt_name.Text == "") || (txt_email.Text == "") || (txt_age.Text == "") || (txt_phone.Text == "") || (txt_address.Text == "") || (txt_proffession.Text == ""))
         {
             MSG.ERROR(this, "Please Enter Required Fields...");
         }
         else
         {
             Customer.name       = txt_name.Text;
             Customer.address    = txt_address.Text;
             Customer.age        = int.Parse(txt_age.Text);
             Customer.email      = txt_email.Text;
             Customer.phone      = txt_phone.Text;
             Customer.profession = txt_proffession.Text;
             Customer.saveCustomer(this);
             MSG.SUCCESS(this, "Customer Saved Successfully...Please Refresh the Customer List to Get Updated One");
         }
     }
     catch (MySql.Data.MySqlClient.MySqlException)
     {
         MSG.ERROR(this, "Can not Save Customer");
     }
 }
        public static void saveLenseOrder(MetroForm f)
        {
            //update summary
            summary.Insert(NewSpectaclesInvoice.OrderNumber, NewSpectaclesInvoice.receiptNumber, Customer.id, "S", NewSpectaclesInvoice.OrderStatus, NewSpectaclesInvoice.Balance.ToString(), "UNPAID");
            //update order
            spec_order.Insert(NewSpectaclesInvoice.receiptNumber, NewSpectaclesInvoice.OrderNumber, Customer.id, NewSpectaclesInvoice.TestedBy, NewSpectaclesInvoice.EyeWear, NewSpectaclesInvoice.Lense, NewSpectaclesInvoice.Total, NewSpectaclesInvoice.Advance, NewSpectaclesInvoice.Discount, NewSpectaclesInvoice.Balance, NewSpectaclesInvoice.DistRightSph, NewSpectaclesInvoice.DistRightCyl, NewSpectaclesInvoice.DistRightAxis, NewSpectaclesInvoice.DistLeftSph, NewSpectaclesInvoice.DistLeftCyl, NewSpectaclesInvoice.DistLeftAxis, NewSpectaclesInvoice.AddRightSph, NewSpectaclesInvoice.AddRightCyl, NewSpectaclesInvoice.AddRightAxis, NewSpectaclesInvoice.AddLeftSph, NewSpectaclesInvoice.AddLeftCyl, NewSpectaclesInvoice.AddLeftAxis, NewSpectaclesInvoice.LensType, NewSpectaclesInvoice.Frame, NewSpectaclesInvoice.PD, NewSpectaclesInvoice.SegmentHeight, NewSpectaclesInvoice.SpecialInc, NewSpectaclesInvoice.Remarks, NewSpectaclesInvoice.OrderStatus, DateTime.Parse(NewSpectaclesInvoice.OrderDate), DateTime.Parse(NewSpectaclesInvoice.DueDate), NewSpectaclesInvoice.PayMethod, NewSpectaclesInvoice.PayPlan);

            //update receipt
            payments.Insert(NewSpectaclesInvoice.OrderNumber, NewSpectaclesInvoice.receiptNumber + "- 01", NewSpectaclesInvoice.Advance, DateTime.Now.Date);
            MSG.SUCCESS(f, "Saved!");
        }
 public static bool register(user NewUser, MetroForm ui)
 {
     try
     {
         UserTable.Insert(NewUser.username, NewUser.password, NewUser.fullName, NewUser.nic, NewUser.contactNumber);
         MSG.SUCCESS(ui, "New User Registration Success!");
         return(true);
     }
     catch (MySql.Data.MySqlClient.MySqlException)
     {
         MSG.ERROR(ui, "New User Registration Failed!");
         return(false);
     }
 }
        public static bool reset(user ExisitingUser, string NewPassword, MetroForm ui)
        {
            try
            {
                row = UserDataTable.FindByusername(ExisitingUser.username);
                if (row == null)
                {
                    MSG.ERROR(ui, "Invalid Username...!");
                    return(false);
                }

                else if (row.nic != ExisitingUser.nic)
                {
                    MSG.ERROR(ui, "Invalid NIC...!");
                    return(false);
                }
                else if (row.contactNumber != ExisitingUser.contactNumber)
                {
                    MSG.ERROR(ui, "Invalid Contact Number...!");
                    return(false);
                }
                else if (NewPassword == "")
                {
                    MSG.ERROR(ui, "Password Can not be empty......!");
                    return(false);
                }
                else if (row.username == ExisitingUser.username && row.nic == ExisitingUser.nic && row.contactNumber == ExisitingUser.contactNumber)
                {
                    UserTable.UpdatePasswordByUsername(NewPassword, ExisitingUser.username);
                    MSG.SUCCESS(ui, "Password Reset Success.!");
                    UserDataTable.Clear();
                    UserDataTable = UserTable.GetData();
                    return(true);
                }
                else
                {
                    MSG.ERROR(ui, "Password Reset Error.!");
                    return(false);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MSG.ERROR(ui, "Password Reset Error.Please Try again..." + ex.Message);
                return(false);
            }
        }
Exemple #6
0
 public static void save(MetroFramework.Forms.MetroForm ui)
 {
     contactLenseInvoiceController.saveLenseOrder(ui);
     MSG.SUCCESS(ui, "Data Saved Successfully...");
 }