Ejemplo n.º 1
0
        public bool Delete_KH(string Customer_Id)
        {
            string repair   = (String)Customer_Id;
            string repairID = repair.Substring(2);

            try
            {
                Detail_Inf_Repair Detail = data.Detail_Inf_Repair.FirstOrDefault(p => p.Repair_Id == "RP" + repairID);
                if (Detail != null)
                {
                    data.Detail_Inf_Repair.Remove(Detail);
                    data.SaveChanges();
                }

                Inf_Repair Repair = data.Inf_Repair.FirstOrDefault(p => p.Customer_Id == Customer_Id);
                if (Repair != null)
                {
                    data.Inf_Repair.Remove(Repair);
                    data.SaveChanges();
                }

                Inf_Customers Customer = data.Inf_Customers.FirstOrDefault(p => p.Customer_Id == Customer_Id);
                if (Customer != null)
                {
                    data.Inf_Customers.Remove(Customer);
                    data.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
 public bool Update_Status(string status, string Repair_Id, string note)
 {
     try
     {
         Inf_Repair repair = data.Inf_Repair.FirstOrDefault(p => p.Repair_Id == Repair_Id);
         if (repair != null)
         {
             if (note.ToString() == "Hẹn ngày lấy")
             {
                 string NameTo        = repair.Inf_Customers.Customer_Name;
                 string EmailTo       = repair.Inf_Customers.Customer_Email;
                 string SDTTo         = repair.Inf_Customers.Customer_Phone;
                 string Laptop_Name   = repair.Laptop_Name;
                 string Repair_Reason = repair.Detail_Inf_Repair.Repair_Reason;
                 string Repair_Money  = repair.Detail_Inf_Repair.Repair_Money;
                 try
                 {
                     var thread = new Thread(() => sendMail(NameTo, EmailTo, SDTTo, Laptop_Name, Repair_Reason, Repair_Money));
                     thread.Start();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("Lỗi gửi mail");
                 }
             }
             repair.Detail_Inf_Repair.Repair_Status = status;
             data.SaveChanges();
         }
     }catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        public bool Update_NhanDon(string name, string Repair_Id)
        {
            Inf_Repair repair = data.Inf_Repair.FirstOrDefault(p => p.Repair_Id == Repair_Id);

            if (repair != null)
            {
                repair.Staff_Id = name;
                data.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public bool Done_RP(string Repair_Id)
        {
            try
            {
                data = new Data();
                Inf_Repair repair = data.Inf_Repair.FirstOrDefault(p => p.Repair_Id == Repair_Id);
                if (repair != null)
                {
                    Inf_LichSu ls = new Inf_LichSu()
                    {
                        Customer_Name      = repair.Inf_Customers.Customer_Name,
                        Customer_Id        = repair.Inf_Customers.Customer_Id,
                        Customer_Sex       = repair.Inf_Customers.Customer_Sex,
                        Customer_Birth     = repair.Inf_Customers.Customer_Birth.Value,
                        Customer_Email     = repair.Inf_Customers.Customer_Email,
                        Customer_Phone     = repair.Inf_Customers.Customer_Phone,
                        Customer_TimeAdd   = repair.Inf_Customers.Customer_TimeAdd.Value,
                        Repair_Id          = repair.Repair_Id,
                        Laptop_Name        = repair.Laptop_Name,
                        Laptop_Status      = repair.Laptop_Status,
                        Staff_Id           = repair.Staff_Id,
                        Repair_Appointment = repair.Detail_Inf_Repair.Repair_Appointment.Value,
                        Repair_Money       = repair.Detail_Inf_Repair.Repair_Money,
                        Repair_Note        = repair.Detail_Inf_Repair.Repair_Note,
                        Repair_Reason      = repair.Detail_Inf_Repair.Repair_Reason,
                        Repair_Status      = repair.Detail_Inf_Repair.Repair_Status,
                        Repair_Time_End    = time.Date
                    };
                    data.Inf_LichSu.Add(ls);
                    data.SaveChanges();
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(false);

                throw;
            }
            return(true);
        }
Ejemplo n.º 5
0
        public bool Update_RP(string Laptop_Name, string Laptop_Status, string Repair_Reason, string Repair_Note, DateTime Repair_Appointment, string Repair_Money, string Repair_Id)
        {
            Inf_Repair repair = data.Inf_Repair.FirstOrDefault(p => p.Repair_Id == Repair_Id);

            if (repair != null)
            {
                repair.Laptop_Name   = Laptop_Name;
                repair.Laptop_Status = Laptop_Status;
                repair.Detail_Inf_Repair.Repair_Reason      = Repair_Reason;
                repair.Detail_Inf_Repair.Repair_Note        = Repair_Note;
                repair.Detail_Inf_Repair.Repair_Appointment = Repair_Appointment;
                repair.Detail_Inf_Repair.Repair_Money       = Repair_Money;
                try
                {
                    data.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 6
0
        public bool Add_KH(string Customer_Name, string Customer_Sex, DateTime Customer_Birth, string Customer_Email, string Customer_Phone)
        {
            if (Customer_Sex == "Nam")
            {
                Sex = "1";
            }
            else if (Customer_Sex == "Nữ")
            {
                Sex = "2";
            }
            else if (Customer_Sex == "Khác")
            {
                Sex = "3";
            }
            try
            {
                Inf_Customers Customer = new Inf_Customers
                {
                    Customer_Id      = "KH" + day + "" + Min + "" + sec + "",
                    Customer_Name    = Customer_Name,
                    Customer_Sex     = Sex,
                    Customer_Birth   = Customer_Birth,
                    Customer_Email   = Customer_Email,
                    Customer_Phone   = Customer_Phone,
                    Customer_TimeAdd = time.Date
                };

                data.Inf_Customers.Add(Customer);
                data.SaveChanges();

                Inf_Repair Repair = new Inf_Repair
                {
                    Repair_Id     = "RP" + day + "" + Min + "" + sec + "",
                    Customer_Id   = "KH" + day + "" + Min + "" + sec + "",
                    Laptop_Name   = "Chưa biết",
                    Laptop_Status = "Chưa biết",
                    Staff_Id      = "Chưa biết",
                };

                data.Inf_Repair.Add(Repair);
                data.SaveChanges();

                Detail_Inf_Repair Detail = new Detail_Inf_Repair
                {
                    Repair_Id          = "RP" + day + "" + Min + "" + sec + "",
                    Repair_Reason      = "Chưa biết",
                    Repair_Note        = "Sửa lấy ngay",
                    Repair_Appointment = DateTime.Parse("31/12/2020"),
                    Repair_Status      = "2",
                    Repair_Money       = "0"
                };

                data.Detail_Inf_Repair.Add(Detail);
                data.SaveChanges();
                time = DateTime.Now;
                day  = DateTime.Now.ToString("dd");
                Min  = DateTime.Now.ToString("mm");
                sec  = DateTime.Now.ToString("ss");
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }