Пример #1
0
 public static string AddOrUpdateItem(int itemID, string maLoai, string tenLoai, string ghiChu)
 {
     try
     {
         //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
         xRPDataContext dts = new xRPDataContext();
         //Get current user info
         var user = (from u in dts.aspnet_Users where u.UserName == HttpContext.Current.User.Identity.Name select u).FirstOrDefault();
         int?id   = null;
         if (itemID == 0 || itemID == -1)
         {
         }
         else
         {
             id = itemID;
         }
         Sp_Qlvt_LoaiVatTu_SelectResult current = null;
         if (id.HasValue)
         {
             current = dts.Sp_Qlvt_LoaiVatTu_Select(1, id.Value, "", null, null, "").FirstOrDefault();
         }
         string result = dts.Sp_Qlvt_LoaiVatTu_Add_Edit_Deli(!id.HasValue ? "ADD" : "EDIT", id, maLoai, tenLoai, "", ghiChu,
                                                             current == null || !current.KichHoat.HasValue ? 1 : (current.KichHoat.Value ? 1 : 0),
                                                             current != null ? current.MaNguoiTao : user.UserId, current != null ? user.UserId : (Guid?)null, ref id, "IP", "PC").FirstOrDefault().Column1;
         return(result != null && result != "" ? result : id.ToString());
     }
     catch (Exception ex)
     {
         return("ERROR: " + ex.Message + ex.StackTrace);
     }
 }