コード例 #1
0
 public int Update(Road_Village e)
 {
     DataLayer.Road_Village r = (from t in Context.Road_Villages
                                 where t.Id == e.Id
                                 select t).FirstOrDefault();
     if (r != null)
     {
         r.Id          = e.Id;
         r.Text        = e.Text;
         r.Description = e.Description;
         r.Type        = e.Type;
         r.WardId      = e.WardId;
         r.RegionId    = e.RegionId;
         try
         {
             Context.SubmitChanges();
             return(r.Id);
         }
         catch (Exception ex)
         {
             string data = className + " " + ex.Message.ToString();
             Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
             return((int)Enums.Errors.UPDATE_ERROR);
         }
     }
     else
     {
         string data = className + " Không có thông tin trong database";
         Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
         return((int)Enums.Errors.UPDATE_ERROR);
     }
 }
コード例 #2
0
 public int Delete(int id)
 {
     DataLayer.Road_Village r = (from t in Context.Road_Villages
                                 where t.Id == id
                                 select t).FirstOrDefault();
     if (r != null)
     {
         try
         {
             Context.Road_Villages.DeleteOnSubmit(r);
             Context.SubmitChanges();
             return(id);
         }
         catch (Exception ex)
         {
             string data = className + " " + ex.Message.ToString();
             Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
             return((int)Enums.Errors.DELETE_ERROR);
         }
     }
     else
     {
         string data = className + " Không có trong database";
         Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
         return((int)Enums.Errors.DELETE_ERROR);
     }
 }
コード例 #3
0
        public int Insert(Road_Village e)
        {
            DataLayer.Road_Village r = new DataLayer.Road_Village();
            r.Text        = e.Text;
            r.Description = e.Description;
            r.Type        = e.Type;
            r.WardId      = e.WardId;
            r.RegionId    = e.RegionId;

            try
            {
                Context.Road_Villages.InsertOnSubmit(r);
                Context.SubmitChanges();
                return(r.Id);
            }
            catch (Exception ex)
            {
                string data = className + " " + ex.Message.ToString();
                Logs.LogWrite(string.Format(Configs.ERROR_ACTION, data));
                return((int)Enums.Errors.INSERT_ERROR);
            }
        }