/// <summary> /// 物理删除 /// </summary> /// <param name="KeyId">需要删除对象的ID</param> /// <returns>返回受影响的行数</returns> public virtual string LogicDelete(string KeyId) { int counts = 0;//影响行数标记 string strMessage = "InsertError"; System.Guid KeyIdGuid = new Guid(KeyId); //转换成Guid类型 tblScheduler SchedulerObjDelete; //需要跟新的对象 try { ServiceDirectDBEntitiesDelete = new ServiceDirectDBEntities(); SchedulerObjDelete = ServiceDirectDBEntitiesDelete.tblScheduler.First(t => t.ScheduleID == KeyIdGuid); ServiceDirectDBEntitiesDelete.DeleteObject(SchedulerObjDelete); counts = ServiceDirectDBEntitiesDelete.SaveChanges(); } catch (EntityException) { throw; } if (counts > 0) { strMessage = "update success"; return(strMessage); } return(strMessage); }
/// <summary> /// 物理删除 /// </summary> /// <param name="KeyId">需要删除对象的ID</param> /// <returns>返回受影响的行数</returns> public virtual int LogicDelete(string KeyId) { int counts = 0;//影响行数标记 ServiceDirectDBEntities objDB; vUTPCommand vUTPCommandObj; try { objDB = new ServiceDirectDBEntities(); vUTPCommandObj = objDB.vUTPCommand.FirstOrDefault(c => c.RelateID == KeyId); if (vUTPCommandObj != null) { if (vUTPCommandObj.RelateID != null && vUTPCommandObj.RelateID != string.Empty) { objDB.DeleteObject(vUTPCommandObj); counts = objDB.SaveChanges(); } } } catch (EntityException) { throw; } return(counts); }
/// <summary> /// 更新对象 /// </summary> /// <param name="SchedulerObj">需要更新的对象</param> /// <returns>返回受影响的行数</returns> public virtual Boolean UpdateInTaskView(tblScheduler SchedulerObj) { tblScheduler SchedulerObjUpdate;//需要跟新的对象 Boolean flagSuccess = false; int counts = 0;//影响行数标记 try { ServiceDirectDB = new ServiceDirectDBEntities(); SchedulerObjUpdate = ServiceDirectDB.tblScheduler.First(t => t.ScheduleID == SchedulerObj.ScheduleID); } catch (EntitySqlException) { throw; } catch (EntityException) { throw; } //对象进行赋值,准备更新 //SchedulerObjUpdate.Action = SchedulerObj.Action; //SchedulerObjUpdate.TraceType = SchedulerObj.TraceType; //SchedulerObjUpdate.PostAction = SchedulerObj.PostAction; //SchedulerObjUpdate.ScheduleType = SchedulerObj.ScheduleType; //SchedulerObjUpdate.StartTime = SchedulerObj.StartTime; //SchedulerObjUpdate.TaskName = SchedulerObj.TaskName; //SchedulerObjUpdate.RunOnly = SchedulerObj.RunOnly; //SchedulerObjUpdate.RunOnlyStart = SchedulerObj.RunOnlyStart; //SchedulerObjUpdate.RunOnlyEnd = SchedulerObj.RunOnlyEnd; SchedulerObjUpdate.Trace = SchedulerObj.Trace; SchedulerObjUpdate.TraceTable = SchedulerObj.TraceTable; SchedulerObjUpdate.JobID = SchedulerObj.JobID; //SchedulerObjUpdate.Status = SchedulerObj.Status; //SchedulerObjUpdate.UTPPwd = SchedulerObj.UTPPwd; //SchedulerObjUpdate.UTPUser = SchedulerObj.UTPUser; //SchedulerObjUpdate.Cycle = SchedulerObj.Cycle; //SchedulerObjUpdate.Calc = SchedulerObj.Calc; //SchedulerObjUpdate.Company = SchedulerObj.Company; //SchedulerObjUpdate.Copy = SchedulerObj.Copy; try { counts = ServiceDirectDB.SaveChanges(); } catch (EntityException) { throw; } if (counts > 0) { flagSuccess = true; return(flagSuccess); } return(flagSuccess); }
/// <summary> /// 插入的对象 /// </summary> /// <param name="SchedulerObj">需要插入的对象</param> /// <returns>受影响的行数</returns> public virtual string Insert(tblScheduler SchedulerObj) { int counts; //影响行数标记 string strScheduleID; //插入对象的ID string strErrorMessage = "InsertError"; SchedulerObj.ScheduleID = System.Guid.NewGuid(); //插入数据 try { ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities(); ServiceDirectDBEntitieAdd.tblScheduler.AddObject(SchedulerObj); counts = ServiceDirectDBEntitieAdd.SaveChanges(); } catch (EntitySqlException) { throw; } if (counts > 0) { strScheduleID = SchedulerObj.ScheduleID.ToString(); return(strScheduleID); } return(strErrorMessage); }
public void InsertCommand(UTPCommandBuilder builder, string RelateID) { ServiceDirectDBEntities objDB; vUTPCommand vUTPCommandObj; //影响行数标记 int counts = 0; //插入数据 try { objDB = new ServiceDirectDBEntities(); vUTPCommandObj = new vUTPCommand(); vUTPCommandObj.CommandID = builder.CommandID; vUTPCommandObj.CommandLine = builder.CommandString; vUTPCommandObj.RelateID = RelateID; vUTPCommandObj.Sequence = 1; objDB.vUTPCommand.AddObject(vUTPCommandObj); counts = objDB.SaveChanges(); } catch (EntitySqlException) { throw; } }
/// <summary> /// 更新对象 /// </summary> /// <param name="SchedulerObj">需要更新的对象</param> /// <returns>返回受影响的行数</returns> public virtual string UpdateInTaskDetailForm(tblScheduler SchedulerObj) { tblScheduler SchedulerObjUpdate;//需要跟新的对象 string strMessage = "UpdateError"; int counts = 0;//影响行数标记 try { ServiceDirectDB = new ServiceDirectDBEntities(); SchedulerObjUpdate = ServiceDirectDB.tblScheduler.First(t => t.ScheduleID == SchedulerObj.ScheduleID); } catch (EntitySqlException) { throw; } catch (EntityException) { throw; } //对象进行赋值,准备更新 SchedulerObjUpdate.Action = SchedulerObj.Action; SchedulerObjUpdate.TraceType = SchedulerObj.TraceType; SchedulerObjUpdate.PostAction = SchedulerObj.PostAction; SchedulerObjUpdate.ScheduleType = SchedulerObj.ScheduleType; SchedulerObjUpdate.StartTime = SchedulerObj.StartTime; SchedulerObjUpdate.TaskName = SchedulerObj.TaskName; SchedulerObjUpdate.RunOnly = SchedulerObj.RunOnly; SchedulerObjUpdate.RunOnlyStart = SchedulerObj.RunOnlyStart; SchedulerObjUpdate.RunOnlyEnd = SchedulerObj.RunOnlyEnd; SchedulerObjUpdate.BackupID = SchedulerObj.BackupID; SchedulerObjUpdate.Trace = SchedulerObj.Trace; SchedulerObjUpdate.TraceTable = SchedulerObj.TraceTable; //SchedulerObjUpdate.Status = SchedulerObj.Status; //SchedulerObjUpdate.UTPPwd = SchedulerObj.UTPPwd; //SchedulerObjUpdate.UTPUser = SchedulerObj.UTPUser; //SchedulerObjUpdate.Cycle = SchedulerObj.Cycle; //SchedulerObjUpdate.Calc = SchedulerObj.Calc; //SchedulerObjUpdate.Company = SchedulerObj.Company; //SchedulerObjUpdate.Copy = SchedulerObj.Copy; try { counts = ServiceDirectDB.SaveChanges(); } catch (EntityException) { throw; } if (counts > 0) { strMessage = "Update success"; return(strMessage); } return(strMessage); }
/// <summary> /// 更新对象 /// </summary> /// <param name="EmailObj">需要更新的对象</param> /// <returns>返回受影响的行数</returns> public virtual string Update(tblEmail EmailObj) { tblEmail EmailObjUpdate;//需要跟新的对象 string strMessage = "InsertError"; int counts = 0;//影响行数标记 try { ServiceDirectDB = new ServiceDirectDBEntities(); EmailObjUpdate = ServiceDirectDB.tblEmail.First(t => t.EmailID == EmailObj.EmailID); }catch (EntitySqlException) { throw; } catch (EntityException) { throw; } //对象进行赋值,准备更新 EmailObjUpdate.EmailFrom = EmailObj.EmailFrom; //EmailObjUpdate.EmailTo = EmailObj.EmailTo; EmailObjUpdate.EmailPort = EmailObj.EmailPort; EmailObjUpdate.EmailSSL = EmailObj.EmailSSL; EmailObjUpdate.SMTPHost = EmailObj.SMTPHost; EmailObjUpdate.SMTPUsername = EmailObj.SMTPUsername; EmailObjUpdate.SMTPPassword = EmailObj.SMTPPassword; try { counts = ServiceDirectDB.SaveChanges(); } catch (EntityException) { throw; } if (counts > 0) { strMessage = "update success"; return(strMessage); } return(strMessage); }
public bool Delete(tblManufacturer OldManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); objDB.tblManufacturer.DeleteObject(OldManufacturer); try { objDB.SaveChanges(); return(true); } catch { return(false); } }
public bool Delete(tblManufacturer OldManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); objDB.tblManufacturer.DeleteObject(OldManufacturer); try { objDB.SaveChanges(); return true; } catch { return false; } }
public bool Insert(tblManufacturer NewManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); try { objDB.tblManufacturer.AddObject(NewManufacturer); objDB.SaveChanges(); return(true); } catch { return(false); } }
public bool Insert(tblManufacturer NewManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); try { objDB.tblManufacturer.AddObject(NewManufacturer); objDB.SaveChanges(); return true; } catch { return false; } }
public bool Update(tblManufacturer NewManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); tblManufacturer OldManufacturer = objDB.tblManufacturer.First(c => c.MfrID == NewManufacturer.MfrID); try { OldManufacturer.MfrName = NewManufacturer.MfrName; OldManufacturer.MfrType = NewManufacturer.MfrType; objDB.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// 物理删除 /// </summary> /// <param name="KeyId">需要删除对象的ID</param> /// <returns>返回受影响的行数</returns> public virtual int LogicDelete(string KeyId) { int counts = 0; //影响行数标记 System.Guid KeyIdGuid = new Guid(KeyId); //转换成Guid类型 tblBackup BackupObjDelete; //需要跟新的对象 try { ServiceDirectDBEntitiesDelete = new ServiceDirectDBEntities(); BackupObjDelete = ServiceDirectDBEntitiesDelete.tblBackup.First(t => t.BackupID == KeyIdGuid); ServiceDirectDBEntitiesDelete.DeleteObject(BackupObjDelete); counts = ServiceDirectDBEntitiesDelete.SaveChanges(); } catch (EntityException) { throw; } return(counts); }
public bool Update(tblManufacturer NewManufacturer) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); tblManufacturer OldManufacturer= objDB.tblManufacturer.First(c=>c.MfrID==NewManufacturer.MfrID); try { OldManufacturer.MfrName = NewManufacturer.MfrName; OldManufacturer.MfrType = NewManufacturer.MfrType; objDB.SaveChanges(); return true; } catch { return false; } }
protected void RadButton3_Click(object sender, EventArgs e) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); tblGauge objGauge; if (hfGaugeID.Value != string.Empty) { objGauge = objDB.tblGauge.First <tblGauge>(g => g.GaugeID == Guid.Parse(hfGaugeID.Value)); } else { objGauge = objDB.tblGauge.CreateObject(); } if (objGauge.GaugeID == Guid.Empty) { objGauge.GaugeID = Guid.NewGuid(); objGauge.GaugeCode = txtGaugeCode.Text; objGauge.SizeID = Guid.Parse(cboSize.SelectedValue); objGauge.ModelID = Guid.Parse(cboModel.SelectedValue); objGauge.MfrID = Guid.Parse(cboManufacturer.SelectedValue); objGauge.LastCalibrationDate = dtpLastCalibrationDate.SelectedDate; objGauge.LastModifiedDate = DateTime.Now; objGauge.CreatedDate = DateTime.Now; objDB.tblGauge.AddObject(objGauge); } else { objGauge.GaugeCode = txtGaugeCode.Text; objGauge.SizeID = Guid.Parse(cboSize.SelectedValue); objGauge.ModelID = Guid.Parse(cboModel.SelectedValue); objGauge.MfrID = Guid.Parse(cboManufacturer.SelectedValue); objGauge.LastCalibrationDate = dtpLastCalibrationDate.SelectedDate; objGauge.LastModifiedDate = DateTime.Now; } objDB.SaveChanges(); }
/// <summary> /// 插入的对象 /// </summary> /// <param name="BackupObj">需要插入的对象</param> /// <returns>受影响的行数</returns> public virtual string Insert(tblBackup BackupObj) { int counts = 0;//影响行数标记 string strErrorMessage = "InsertError"; //插入数据 try { ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities(); ServiceDirectDBEntitieAdd.tblBackup.AddObject(BackupObj); counts = ServiceDirectDBEntitieAdd.SaveChanges(); } catch (EntitySqlException) { throw; } if (counts > 0) { return(BackupObj.BackupID.ToString()); } return(strErrorMessage); }
/// <summary> /// 更新对象 /// </summary> /// <param name="BackupObj">需要更新的对象</param> /// <returns>返回受影响的行数</returns> public virtual string Update(tblBackup BackupObj) { tblBackup SchedulerObjUpdate;//需要跟新的对象 string strMessage = "InsertError"; int counts = 0;//影响行数标记 try { ServiceDirectDB = new ServiceDirectDBEntities(); SchedulerObjUpdate = ServiceDirectDB.tblBackup.FirstOrDefault(t => t.BackupID == BackupObj.BackupID); }catch (EntitySqlException) { throw; } catch (EntityException) { throw; } if (SchedulerObjUpdate != null)//如果为空则进行插入 { //对象进行赋值,准备更新 SchedulerObjUpdate.BackupFloder = BackupObj.BackupFloder; SchedulerObjUpdate.BackupDatabase = BackupObj.BackupDatabase; SchedulerObjUpdate.DeleteBackupOlder = BackupObj.DeleteBackupOlder; SchedulerObjUpdate.BackupServer = BackupObj.BackupServer; SchedulerObjUpdate.BackupUser = BackupObj.BackupUser; SchedulerObjUpdate.BackupPassword = BackupObj.BackupPassword; try { counts = ServiceDirectDB.SaveChanges(); } catch (EntityException) { throw; } } else { try { ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities(); ServiceDirectDBEntitieAdd.tblBackup.AddObject(BackupObj); counts = ServiceDirectDBEntitieAdd.SaveChanges(); } catch (EntityException) { throw; } } if (counts > 0) { strMessage = "update success"; return(strMessage); } return(strMessage); }
protected void RadButton3_Click(object sender, EventArgs e) { ServiceDirectDBEntities objDB = new ServiceDirectDBEntities(); tblGauge objGauge; if (hfGaugeID.Value != string.Empty) { objGauge = objDB.tblGauge.First<tblGauge>(g => g.GaugeID == Guid.Parse(hfGaugeID.Value)); } else { objGauge = objDB.tblGauge.CreateObject(); } if (objGauge.GaugeID==Guid.Empty) { objGauge.GaugeID = Guid.NewGuid(); objGauge.GaugeCode = txtGaugeCode.Text; objGauge.SizeID =Guid.Parse(cboSize.SelectedValue); objGauge.ModelID = Guid.Parse(cboModel.SelectedValue); objGauge.MfrID = Guid.Parse(cboManufacturer.SelectedValue); objGauge.LastCalibrationDate = dtpLastCalibrationDate.SelectedDate; objGauge.LastModifiedDate = DateTime.Now; objGauge.CreatedDate = DateTime.Now; objDB.tblGauge.AddObject(objGauge); } else { objGauge.GaugeCode = txtGaugeCode.Text; objGauge.SizeID = Guid.Parse(cboSize.SelectedValue); objGauge.ModelID = Guid.Parse(cboModel.SelectedValue); objGauge.MfrID = Guid.Parse(cboManufacturer.SelectedValue); objGauge.LastCalibrationDate = dtpLastCalibrationDate.SelectedDate; objGauge.LastModifiedDate = DateTime.Now; } objDB.SaveChanges(); }