public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode) { Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo(); WorkGroupTypeMaster_wgt_Info info = new WorkGroupTypeMaster_wgt_Info(); returnValue.messageText = ""; info = itemEntity as WorkGroupTypeMaster_wgt_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; isExist = _workGroupTypeMasterDA.IsExistRecord(info); if (!isExist) { returnValue.boolValue = _workGroupTypeMasterDA.InsertRecord(info); } else { returnValue.boolValue = false; returnValue.messageText = "数据重复!"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _workGroupTypeMasterDA.UpdateRecord(info); break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _workGroupTypeMasterDA.DeleteRecord(info); break; default: break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
public List<WorkGroupTypeMaster_wgt_Info> FindRecord(WorkGroupTypeMaster_wgt_Info info) { List<WorkGroupTypeMaster_wgt_Info> list = new List<WorkGroupTypeMaster_wgt_Info>(); string sqlString = string.Empty; string whereString = string.Empty; sqlString = "SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString() + Environment.NewLine; sqlString += "*" + Environment.NewLine; sqlString += "FROM dbo.WorkGroupTypeMaster_wgt" + Environment.NewLine; whereString = "WHERE 1=1" + Environment.NewLine; if (info.wgt_cWGTName != "") { whereString += "AND wgt_cWGTName='" + info.wgt_cWGTName + "' " + Environment.NewLine; } if (info.wgt_cDescription != "") { whereString += "AND wgt_cDescription='" + info.wgt_cDescription + "' " + Environment.NewLine; } IEnumerable<WorkGroupTypeMaster_wgt_Info> infos = null; try { using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<WorkGroupTypeMaster_wgt_Info>(sqlString + whereString, new object[] { }); if (infos != null) { list = infos.ToList<WorkGroupTypeMaster_wgt_Info>(); } } } catch (Exception Ex) { throw Ex; } return list; }
public bool DeleteRecord(Model.IModel.IModelObject KeyObject) { bool isSuccess = false; WorkGroupTypeMaster_wgt_Info info = new WorkGroupTypeMaster_wgt_Info(); info = KeyObject as WorkGroupTypeMaster_wgt_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { WorkGroupTypeMaster_wgt delTab = db.WorkGroupTypeMaster_wgt.SingleOrDefault(t => t.wgt_iRecordID == info.wgt_iRecordID); if (delTab != null) { db.WorkGroupTypeMaster_wgt.DeleteOnSubmit(delTab); db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public List<WorkGroupTypeMaster_wgt_Info> FindRecord(WorkGroupTypeMaster_wgt_Info info) { return _workGroupTypeMasterDA.FindRecord(info); }
/// <summary> /// 工作組 /// </summary> /// <returns></returns> public List<WorkGroupTypeMaster_wgt_Info> GetWorkGroupTypeMaster() { try { List<WorkGroupTypeMaster_wgt_Info> list = new List<WorkGroupTypeMaster_wgt_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select"); strSql.AppendLine("wgt_iRecordID,wgt_cWGTName,wgt_cDescription,wgt_lIsAtive,wgt_cAdd,wgt_dAddDate,wgt_cLast,wgt_dLastDate "); strSql.AppendLine("from WorkGroupTypeMaster_wgt "); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { WorkGroupTypeMaster_wgt_Info model = new WorkGroupTypeMaster_wgt_Info(); if (sdr["wgt_iRecordID"] != null && sdr["wgt_iRecordID"].ToString() != "") { model.wgt_iRecordID = int.Parse(sdr["wgt_iRecordID"].ToString()); } if (sdr["wgt_cWGTName"] != null && sdr["wgt_cWGTName"].ToString() != "") { model.wgt_cWGTName = sdr["wgt_cWGTName"].ToString(); } if (sdr["wgt_cDescription"] != null && sdr["wgt_cDescription"].ToString() != "") { model.wgt_cDescription = sdr["wgt_cDescription"].ToString(); } if (sdr["wgt_lIsAtive"] != null && sdr["wgt_lIsAtive"].ToString() != "") { if ((sdr["wgt_lIsAtive"].ToString() == "1") || (sdr["wgt_lIsAtive"].ToString().ToLower() == "true")) { model.wgt_lIsAtive = true; } else { model.wgt_lIsAtive = false; } } if (sdr["wgt_cAdd"] != null && sdr["wgt_cAdd"].ToString() != "") { model.wgt_cAdd = sdr["wgt_cAdd"].ToString(); } if (sdr["wgt_dAddDate"] != null && sdr["wgt_dAddDate"].ToString() != "") { model.wgt_dAddDate = DateTime.Parse(sdr["wgt_dAddDate"].ToString()); } if (sdr["wgt_cLast"] != null && sdr["wgt_cLast"].ToString() != "") { model.wgt_cLast = sdr["wgt_cLast"].ToString(); } if (sdr["wgt_dLastDate"] != null && sdr["wgt_dLastDate"].ToString() != "") { model.wgt_dLastDate = DateTime.Parse(sdr["wgt_dLastDate"].ToString()); } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
public bool UpdateRecord(WorkGroupTypeMaster_wgt_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { WorkGroupTypeMaster_wgt query = db.WorkGroupTypeMaster_wgt.SingleOrDefault(t => t.wgt_iRecordID == infoObject.wgt_iRecordID); if (query != null) { query.wgt_cWGTName = infoObject.wgt_cWGTName; query.wgt_cDescription = infoObject.wgt_cDescription; //query.wgt_lIsDeleted = infoObject.wgt_lIsDeleted; query.wgt_lIsAtive = infoObject.wgt_lIsAtive; query.wgt_cLast = infoObject.wgt_cLast; query.wgt_dLastDate = infoObject.wgt_dLastDate; db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool IsExistRecord(object KeyObject) { WorkGroupTypeMaster_wgt_Info info = new WorkGroupTypeMaster_wgt_Info(); info = KeyObject as WorkGroupTypeMaster_wgt_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { WorkGroupTypeMaster_wgt query = db.WorkGroupTypeMaster_wgt.SingleOrDefault(t => t.wgt_iRecordID == info.wgt_iRecordID); if (query != null) { return true; } } } catch (Exception Ex) { throw Ex; } return false; }
public bool InsertRecord(WorkGroupTypeMaster_wgt_Info infoObject) { bool isSuccess = false; WorkGroupTypeMaster_wgt_Info info = new WorkGroupTypeMaster_wgt_Info(); info = infoObject; try { using (MainDBDataContext db = new MainDBDataContext()) { WorkGroupTypeMaster_wgt newTab = Common.General.CopyObjectValue<WorkGroupTypeMaster_wgt_Info, WorkGroupTypeMaster_wgt>(info); db.WorkGroupTypeMaster_wgt.InsertOnSubmit(newTab); db.SubmitChanges(); isSuccess = true; } } catch (Exception Ex) { throw Ex; } return isSuccess; }
private string GetWorkGroupTypeMasterSQL(WorkGroupTypeMaster_wgt_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.wgt_iRecordID != null) { strSql1.Append("wgt_iRecordID,"); strSql2.Append("" + model.wgt_iRecordID + ","); } if (model.wgt_cWGTName != null) { strSql1.Append("wgt_cWGTName,"); strSql2.Append("'" + model.wgt_cWGTName + "',"); } if (model.wgt_cDescription != null) { strSql1.Append("wgt_cDescription,"); strSql2.Append("'" + model.wgt_cDescription + "',"); } if (model.wgt_lIsAtive != null) { strSql1.Append("wgt_lIsAtive,"); strSql2.Append("" + (model.wgt_lIsAtive ? 1 : 0) + ","); } if (model.wgt_cAdd != null) { strSql1.Append("wgt_cAdd,"); strSql2.Append("'" + model.wgt_cAdd + "',"); } if (model.wgt_dAddDate != null) { strSql1.Append("wgt_dAddDate,"); strSql2.Append("'" + model.wgt_dAddDate.ToString(this._sqlLiteDatetimeFormat) + "',"); } if (model.wgt_cLast != null) { strSql1.Append("wgt_cLast,"); strSql2.Append("'" + model.wgt_cLast + "',"); } if (model.wgt_dLastDate != null) { strSql1.Append("wgt_dLastDate,"); strSql2.Append("'" + model.wgt_dLastDate.ToString(this._sqlLiteDatetimeFormat) + "',"); } strSql.Append("insert into WorkGroupTypeMaster_wgt("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); return strSql.ToString(); }