public bool DeleteRecord(Model.IModel.IModelObject KeyObject) { bool isSuccess = false; Model.HBPMS.Master.StaffInfoMaster_sim_Info info = new Model.HBPMS.Master.StaffInfoMaster_sim_Info(); info = KeyObject as Model.HBPMS.Master.StaffInfoMaster_sim_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { LinqToSQLModel.StaffInfoMaster_sim delTab = db.StaffInfoMaster_sim.SingleOrDefault(t => t.sim_iRecordID == info.sim_iRecordID); if (delTab != null) { db.StaffInfoMaster_sim.DeleteOnSubmit(delTab); db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); StaffInfoMaster_sim_Info staffInfoEntity; this.ppgWorkMan.Font = ControlSetting.ListFont; if (this.BaseParam != null) { staffInfoEntity = this.BaseParam as StaffInfoMaster_sim_Info; staffInfoEntity = (StaffInfoMaster_sim_Info)this._StaffInfoMasterBL.DisplayRecord(staffInfoEntity); } else { staffInfoEntity = new StaffInfoMaster_sim_Info(); } WorkManProperty wmp = new WorkManProperty(); wmp.sim_iRecordID = staffInfoEntity.sim_iRecordID; wmp.sim_cStaffNo = staffInfoEntity.sim_cStaffNo; wmp.sim_cStaffName = staffInfoEntity.sim_cStaffName; wmp.sim_cDescription = staffInfoEntity.sim_cDescription; wmp.IsCaptainChiness = (WorkManProperty.YesNo)Enum.Parse(typeof(WorkManProperty.YesNo), staffInfoEntity.IsCaptainChiness); wmp.sim_cMachineID = staffInfoEntity.sim_cMachineID; wmp.IsActiveChiness = (WorkManProperty.YesNo)Enum.Parse(typeof(WorkManProperty.YesNo), staffInfoEntity.IsActiveChiness); wmp.sim_amrID = staffInfoEntity.sim_amrID.ToString(); this.ppgWorkMan.SelectedObject = wmp; InitSysBar(); }
private void BingGv() { #region StaffInfoMaster_sim_Info entity = new StaffInfoMaster_sim_Info(); entity.sim_cStaffName = txtStaffName.Text.Trim().Replace("'", "''"); entity.sim_cStaffNo = txtStaffNO.Text.Trim().Replace("'", "''"); var info = _StaffInfoMasterBL.SearchRecords(entity); this.lvInfo.SetDataSource(info); #endregion }
public Model.HBPMS.Master.StaffInfoMaster_sim_Info DisplayRecord(Model.IModel.IModelObject KeyObject) { // Model.HBPMS.Master.StaffInfoMaster_sim_Info info = new Model.HBPMS.Master.StaffInfoMaster_sim_Info(); info = KeyObject as Model.HBPMS.Master.StaffInfoMaster_sim_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { //LinqToSQLModel.StaffInfoMaster_sim disTab = db.StaffInfoMaster_sim.SingleOrDefault(t => t.sim_iRecordID == info.sim_iRecordID && t.sim_lIsDeleted == false); LinqToSQLModel.StaffInfoMaster_sim disTab = db.StaffInfoMaster_sim.SingleOrDefault(t => t.sim_iRecordID == info.sim_iRecordID); if (disTab != null) { info = Common.General.CopyObjectValue<LinqToSQLModel.StaffInfoMaster_sim, Model.HBPMS.Master.StaffInfoMaster_sim_Info>(disTab); } } } catch (Exception Ex) { throw Ex; } return info; }
public bool InsertRecord(Model.HBPMS.Master.StaffInfoMaster_sim_Info infoObject) { bool isSuccess = false; Model.HBPMS.Master.StaffInfoMaster_sim_Info info = new Model.HBPMS.Master.StaffInfoMaster_sim_Info(); info = infoObject; try { using (MainDBDataContext db = new MainDBDataContext()) { LinqToSQLModel.StaffInfoMaster_sim newTab = Common.General.CopyObjectValue<Model.HBPMS.Master.StaffInfoMaster_sim_Info, LinqToSQLModel.StaffInfoMaster_sim>(info); newTab.sim_iRecordID = Guid.NewGuid(); db.StaffInfoMaster_sim.InsertOnSubmit(newTab); db.SubmitChanges(); isSuccess = true; } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public bool IsExistRecord(object KeyObject) { bool isExist = false; Model.HBPMS.Master.StaffInfoMaster_sim_Info info = new Model.HBPMS.Master.StaffInfoMaster_sim_Info(); info = KeyObject as Model.HBPMS.Master.StaffInfoMaster_sim_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { //LinqToSQLModel.StaffInfoMaster_sim query = db.StaffInfoMaster_sim.SingleOrDefault(t => t.sim_cStaffNo == info.sim_cStaffNo && t.sim_lIsDeleted == false); LinqToSQLModel.StaffInfoMaster_sim query = db.StaffInfoMaster_sim.SingleOrDefault(t => t.sim_cStaffNo == info.sim_cStaffNo && t.sim_lIsAtive == true); if (query != null) { isExist = true; } } } catch (Exception Ex) { throw Ex; } return isExist; }
public bool InsertRecord(StaffInfoMaster_sim_Info infoObject) { throw new NotImplementedException(); }
/// <summary> /// 人員主檔 /// </summary> /// <returns></returns> public List<StaffInfoMaster_sim_Info> GetStaffInfoMaster() { try { List<StaffInfoMaster_sim_Info> list = new List<StaffInfoMaster_sim_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select"); strSql.AppendLine("sim_iRecordID,sim_cStaffName,sim_cStaffNo,sim_cDescription,sim_lIsAtive,sim_lIsCaptain,sim_cMachineID,sim_cAdd,sim_dAddDate,sim_cLast,sim_dLastDate,sim_amrID "); strSql.AppendLine("from StaffInfoMaster_sim "); strSql.AppendLine("where sim_lIsAtive=1 "); strSql.AppendLine("order by sim_cStaffNo "); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { StaffInfoMaster_sim_Info model = new StaffInfoMaster_sim_Info(); if (sdr["sim_iRecordID"] != null && sdr["sim_iRecordID"].ToString() != "") { model.sim_iRecordID = new Guid(sdr["sim_iRecordID"].ToString()); } if (sdr["sim_cStaffName"] != null && sdr["sim_cStaffName"].ToString() != "") { model.sim_cStaffName = sdr["sim_cStaffName"].ToString(); } if (sdr["sim_cStaffNo"] != null && sdr["sim_cStaffNo"].ToString() != "") { model.sim_cStaffNo = sdr["sim_cStaffNo"].ToString(); } if (sdr["sim_cDescription"] != null && sdr["sim_cDescription"].ToString() != "") { model.sim_cDescription = sdr["sim_cDescription"].ToString(); } if (sdr["sim_lIsAtive"] != null && sdr["sim_lIsAtive"].ToString() != "") { if ((sdr["sim_lIsAtive"].ToString() == "1") || (sdr["sim_lIsAtive"].ToString().ToLower() == "true")) { model.sim_lIsAtive = true; } else { model.sim_lIsAtive = false; } } if (sdr["sim_lIsCaptain"] != null && sdr["sim_lIsCaptain"].ToString() != "") { if ((sdr["sim_lIsCaptain"].ToString() == "1") || (sdr["sim_lIsCaptain"].ToString().ToLower() == "true")) { model.sim_lIsCaptain = true; } else { model.sim_lIsCaptain = false; } } if (sdr["sim_cMachineID"] != null && sdr["sim_cMachineID"].ToString() != "") { model.sim_cMachineID = sdr["sim_cMachineID"].ToString(); } if (sdr["sim_cAdd"] != null && sdr["sim_cAdd"].ToString() != "") { model.sim_cAdd = sdr["sim_cAdd"].ToString(); } if (sdr["sim_dAddDate"] != null && sdr["sim_dAddDate"].ToString() != "") { model.sim_dAddDate = DateTime.Parse(sdr["sim_dAddDate"].ToString()); } if (sdr["sim_cLast"] != null && sdr["sim_cLast"].ToString() != "") { model.sim_cLast = sdr["sim_cLast"].ToString(); } if (sdr["sim_dLastDate"] != null && sdr["sim_dLastDate"].ToString() != "") { model.sim_dLastDate = DateTime.Parse(sdr["sim_dLastDate"].ToString()); } if (sdr["sim_amrID"] != null && sdr["sim_amrID"].ToString() != "") { model.sim_amrID = new Guid(sdr["sim_amrID"].ToString()); } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
private string GetStaffInfoMasterSQL(StaffInfoMaster_sim_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.sim_iRecordID != null) { strSql1.Append("sim_iRecordID,"); strSql2.Append("'" + model.sim_iRecordID + "',"); } if (model.sim_cStaffName != null) { strSql1.Append("sim_cStaffName,"); strSql2.Append("'" + model.sim_cStaffName + "',"); } if (model.sim_cStaffNo != null) { strSql1.Append("sim_cStaffNo,"); strSql2.Append("'" + model.sim_cStaffNo + "',"); } if (model.sim_cDescription != null) { strSql1.Append("sim_cDescription,"); strSql2.Append("'" + model.sim_cDescription + "',"); } if (model.sim_lIsAtive != null) { strSql1.Append("sim_lIsAtive,"); strSql2.Append("" + (model.sim_lIsAtive ? 1 : 0) + ","); } if (model.sim_lIsCaptain != null) { strSql1.Append("sim_lIsCaptain,"); strSql2.Append("" + (model.sim_lIsCaptain ? 1 : 0) + ","); } if (model.sim_cMachineID != null) { strSql1.Append("sim_cMachineID,"); strSql2.Append("'" + model.sim_cMachineID + "',"); } if (model.sim_cAdd != null) { strSql1.Append("sim_cAdd,"); strSql2.Append("'" + model.sim_cAdd + "',"); } if (model.sim_dAddDate != null) { strSql1.Append("sim_dAddDate,"); strSql2.Append("'" + model.sim_dAddDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } if (model.sim_cLast != null) { strSql1.Append("sim_cLast,"); strSql2.Append("'" + model.sim_cLast + "',"); } if (model.sim_dLastDate != null) { strSql1.Append("sim_dLastDate,"); strSql2.Append("'" + model.sim_dLastDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } if (model.sim_amrID != null) { strSql1.Append("sim_amrID,"); strSql2.Append("'" + model.sim_amrID + "',"); } strSql.Append("insert into StaffInfoMaster_sim("); 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(); }
public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode) { Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo(); StaffInfoMaster_sim_Info info = new StaffInfoMaster_sim_Info(); returnValue.messageText = ""; info = itemEntity as StaffInfoMaster_sim_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; isExist = _StaffInfoMasterDA.IsExistRecord(info); if (!isExist) { returnValue.boolValue = _StaffInfoMasterDA.InsertRecord(info); } else { returnValue.boolValue = false; returnValue.messageText = "該工號的人員已存在,請檢查"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _StaffInfoMasterDA.UpdateRecord(info); break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _StaffInfoMasterDA.DeleteRecord(info); break; default: break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
private void SysToolBar_OnItemDelete_Click(object sender, EventArgs e) { if (this.lvInfo.SelectedItems.Count > 0) { if (this.ShowQuestionMessage("是否確定刪除人員" + this.lvInfo.SelectedItems[0].SubItems[1].Text + "?工號:" + this.lvInfo.SelectedItems[0].SubItems[2].Text)) { StaffInfoMaster_sim_Info delinfo = new StaffInfoMaster_sim_Info(); delinfo.sim_iRecordID = new Guid(this.lvInfo.SelectedItems[0].SubItems[0].Text.Trim()); ReturnValueInfo rvInfo = this._StaffInfoMasterBL.Save(delinfo, Common.DefineConstantValue.EditStateEnum.OE_Delete); if (!rvInfo.isError && rvInfo.boolValue) { this.ShowInformationMessage("刪除成功。"); } else { this.ShowWarningMessage("刪除失敗,失敗信息:" + rvInfo.messageText); } RefreshAllState(); } } else { this.ShowWarningMessage("請先選擇人員!"); } }
private void BtnSave_Click(object sender, EventArgs e) { WorkManProperty wmp = this.ppgWorkMan.SelectedObject as WorkManProperty; if (CheckCanSave() == false) { this.ShowWarningMessage("工作人員名稱或工號不能為空,請檢查。"); this.Cursor = Cursors.Default; return; } this.Cursor = Cursors.WaitCursor; ReturnValueInfo rvInfo = null; StaffInfoMaster_sim_Info staffInfoEntity = new StaffInfoMaster_sim_Info(); staffInfoEntity.sim_iRecordID = new Guid(wmp.sim_iRecordID.ToString()); staffInfoEntity.sim_cStaffName = wmp.sim_cStaffName; staffInfoEntity.sim_cStaffNo = wmp.sim_cStaffNo; staffInfoEntity.sim_cDescription = wmp.sim_cDescription; staffInfoEntity.sim_lIsCaptain = wmp.IsCaptainChiness == WorkManProperty.YesNo.是; staffInfoEntity.sim_cMachineID = wmp.sim_cMachineID; staffInfoEntity.sim_lIsAtive = wmp.IsActiveChiness == WorkManProperty.YesNo.是; if (wmp.sim_amrID != string.Empty) { staffInfoEntity.sim_amrID = new Guid(wmp.sim_amrID); } else { staffInfoEntity.sim_amrID =Guid.Empty; } if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Insert) { if (_StaffInfoMasterBL.IsExistRecord(staffInfoEntity)) { this.ShowWarningMessage("該工號的人員已存在,請檢查。"); // this.Cursor = Cursors.Default; return; } staffInfoEntity.sim_cAdd = this.UserInformation.usm_cChaName; staffInfoEntity.sim_dAddDate = DateTime.Now; staffInfoEntity.sim_cLast = this.UserInformation.usm_cChaName; staffInfoEntity.sim_dLastDate = DateTime.Now; rvInfo = this._StaffInfoMasterBL.Save(staffInfoEntity, Common.DefineConstantValue.EditStateEnum.OE_Insert); } if (this.EditState == Common.DefineConstantValue.EditStateEnum.OE_Update) { //if (_StaffNo != wmp.sim_cStaffNo) //{ // if (_StaffInfoMasterBL.IsExistRecord(staffInfoEntity)) // { // this.ShowWarningMessage("該工號的人員已存在,請檢查。"); // this.Cursor = Cursors.Default; // return; // } //} staffInfoEntity.sim_cLast = this.UserInformation.usm_cChaName; staffInfoEntity.sim_dLastDate = DateTime.Now; rvInfo = this._StaffInfoMasterBL.Save(staffInfoEntity, Common.DefineConstantValue.EditStateEnum.OE_Update); } if (rvInfo.boolValue && !rvInfo.isError) { this.ShowInformationMessage("保存成功。"); this.systemToolBar1.BtnSave_IsEnabled = false; } else { this.ShowWarningMessage("保存失敗,異常信息:" + rvInfo.messageText); } this.Cursor = Cursors.Default; }
/// <summary> /// 獲取非機長員工信息 /// </summary> /// <returns></returns> private List<ComboboxDataInfo> GetStaffMasterInfo(string strMacType) { List<ComboboxDataInfo> infoList = new List<ComboboxDataInfo>(); try { IStaffInfoMasterDA da = SQLiteDAFacotry.GetDAL<IStaffInfoMasterDA>(SQLiteDAFacotry.StaffInfoMaster); StaffInfoMaster_sim_Info stsaffInfo = new StaffInfoMaster_sim_Info(); Dictionary<string, object> dicParam = new Dictionary<string, object>(); dicParam.Add("sim_lIsCaptain", false); dicParam.Add("sim_cMachineID", strMacType); List<StaffInfoMaster_sim_Info> listCaptainMaster = da.GetEntities<StaffInfoMaster_sim_Info>(dicParam).ToList(); if (listCaptainMaster != null && listCaptainMaster.Count > 0) { foreach (StaffInfoMaster_sim_Info captainItem in listCaptainMaster) { ComboboxDataInfo info = new ComboboxDataInfo(); info.DisplayMember = captainItem.sim_cStaffNo.Trim() + "-" + captainItem.sim_cStaffName.Trim(); info.ValueMember = captainItem.sim_iRecordID.ToString(); infoList.Add(info); } } } catch (Exception Ex) { throw Ex; } return infoList; }
public Model.General.ReturnValueInfo UpdateRecord_Sqlite(StaffInfoMaster_sim_Info model) { throw new NotImplementedException(); //try //{ // return this._StaffInfoMasterDA_Sqlite.Update(model); //} //catch (Exception ex) //{ // throw ex; //} }
public List<StaffInfoMaster_sim_Info> SearchRecord_Sqlite(StaffInfoMaster_sim_Info searchInfo) { throw new NotImplementedException(); //try //{ // Dictionary<string, object> param = new Dictionary<string, object>(); // if (searchInfo != null) // { // if (searchInfo.sim_iRecordID != Guid.Empty) // { // param.Add("RecordID", searchInfo.sim_iRecordID); // } // if (!string.IsNullOrEmpty(searchInfo.sim_cMachineID)) // { // param.Add("sim_cMachineID", searchInfo.sim_cMachineID); // } // if (!string.IsNullOrEmpty(searchInfo.sim_cStaffName)) // { // param.Add("sim_cStaffName", searchInfo.sim_cStaffName); // } // if (!string.IsNullOrEmpty(searchInfo.sim_cStaffNo)) // { // param.Add("sim_cStaffNo", searchInfo.sim_cStaffNo); // } // if (searchInfo.sim_lIsAtive) // { // param.Add("sim_lIsAtive", searchInfo.sim_lIsAtive); // } // if (searchInfo.sim_lIsCaptain) // { // param.Add("sim_lIsCaptain", searchInfo.sim_lIsCaptain); // } // if (searchInfo.sim_amrID != Guid.Empty) // { // param.Add("sim_amrID", searchInfo.sim_amrID); // } // } // return this._StaffInfoMasterDA_Sqlite.GetEntities<StaffInfoMaster_sim_Info>(param).OrderBy(d => d.sim_cStaffNo).ToList(); //} //catch (Exception ex) //{ // throw ex; //} }
public List<StaffInfoMaster_sim_Info> SearchRecord(StaffInfoMaster_sim_Info searchInfo) { throw new NotImplementedException(); //try //{ // return this._StaffInfoMasterDA_Sqlite.SearchRecords(searchInfo); //} //catch (Exception ex) //{ // throw ex; //} }
private void SysToolBar_OnItemModify_Click(object sender, EventArgs e) { if (lvInfo.SelectedItems.Count > 0) { StaffInfoMaster_sim_Info entity = new StaffInfoMaster_sim_Info(); MenuItem itemMenu = new MenuItem(); entity.sim_iRecordID = new Guid(lvInfo.SelectedItems[0].SubItems[0].Text); entity.sim_cStaffName = lvInfo.SelectedItems[0].SubItems[1].Text; entity.sim_cStaffNo = lvInfo.SelectedItems[0].SubItems[2].Text; entity.sim_cDescription = lvInfo.SelectedItems[0].SubItems[3].Text; entity.sim_lIsCaptain = lvInfo.SelectedItems[0].SubItems[4].Text.Trim().ToLower() == "是" ? true : false; entity.sim_cMachineID = lvInfo.SelectedItems[0].SubItems[7].Text; itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.WorkingManAppSetting"; BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, "修改工作人員記錄", DockState.Document, entity, DefineConstantValue.EditStateEnum.OE_Update); form.FromCloseCallBack += BingGv; } }
public Model.General.ReturnValueInfo InsertRecord(StaffInfoMaster_sim_Info model) { throw new NotImplementedException(); //try //{ // return this._StaffInfoMasterDA.Insert(model); //} //catch (Exception ex) //{ // throw ex; //} }