示例#1
0
 public void RegisterCustomer(Customer c)
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_ADD))
         {
             if (Helper.MessageHelper.AlertRegisterConfirmation() == DialogResult.Yes)
             {
                 context.Customers.Add(c);
                 if (context.SaveChanges() == 1)
                 {
                     Helper.MessageHelper.AlertRegisterSuccess();
                 }
                 else
                 {
                     throw new Exception("Unknown Error Occured!");
                 }
             }
         }
         else
         {
             throw new Exception("Access Denied.!");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
示例#2
0
 public Customer GetCustomerByMobile(string mobile)
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_VIEW))
         {
             var cust = context.Customers.FirstOrDefault(x => x.Mobile == mobile);
             if (cust == null)
             {
                 throw new Exception("Customer Not Found!");
             }
             else
             {
                 return(cust);
             }
         }
         else
         {
             throw new Exception("Access Denied!");
         }
     }
     catch (Exception e)
     {
         Helper.MessageHelper.AlertError(e.Message);
         return(null);
     }
 }
示例#3
0
 public void DeleteCustomer(int id)
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_DELETE))
         {
             if (Helper.MessageHelper.AlertRemoveConfirmation() == DialogResult.Yes)
             {
                 var c = context.Customers.FirstOrDefault(x => x.Id == id);
                 context.Customers.Remove(c);
                 if (context.SaveChanges() == 1)
                 {
                     Helper.MessageHelper.AlertRemoveSuccess();
                 }
                 else
                 {
                     throw new Exception("Unknown Error Occured!");
                 }
             }
         }
         else
         {
             throw new Exception("Access Denied.!");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
示例#4
0
 public void EditCustomer()
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_EDIT))
         {
             if (Helper.MessageHelper.AlertUpdateConfirmation() == DialogResult.Yes)
             {
                 if (context.SaveChanges() == 1)
                 {
                     Helper.MessageHelper.AlertUpdateSuccess();
                 }
                 else
                 {
                     throw new Exception("Unknown Error Occured!");
                 }
             }
         }
         else
         {
             throw new Exception("Access Denied.!");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
示例#5
0
 public BindingList <Customer> GetCustomerListForDataGrid()
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.CUSTOMER_VIEW))
         {
             return(context.Customers.Local.ToBindingList());
         }
         else
         {
             throw new Exception("Access Denied!");
         }
     }
     catch (Exception e)
     {
         Helper.MessageHelper.AlertError(e.Message);
         return(null);
     }
 }
示例#6
0
 public void UpdateProduct()
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.PRODUCT_EDIT))
         {
             if (MessageHelper.AlertUpdateConfirmation() == DialogResult.Yes)
             {
                 context.SaveChanges();
                 MessageHelper.AlertUpdateSuccess();
             }
         }
         else
         {
             throw new Exception("Access Denied! (PRODUCT_EDIT)");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
示例#7
0
 public void DeleteProductBatch(int id)
 {
     try
     {
         if (PermissionController.CheckPermission(PermissionType.PRODUCT_DELETE))
         {
             var pb = context.ProductBatches.FirstOrDefault(x => x.Id == id);
             if (MessageHelper.AlertRemoveConfirmation() == DialogResult.Yes)
             {
                 context.ProductBatches.Remove(pb);
                 context.SaveChanges();
             }
         }
         else
         {
             throw new Exception("Access Denied.! (PRODUCT_DELETE)");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }