/// <summary> /// 綁定ListView,當TargetID為-1時搜索全部記錄 /// </summary> /// <param name="TargetID">區域或啤機的ID</param> private void BingGv(Guid TargetID) { VacationMaster_vcm_Info query = new VacationMaster_vcm_Info(); query.vcm_TargetID = TargetID; var info = _VacationMasterBL.SearchRecords(query); this.lvInfo.BeginUpdate(); lvInfo.Items.Clear(); foreach (VacationMaster_vcm_Info item in info) { ListViewItem Item = new ListViewItem(); Item.SubItems.Clear(); for (int i = 0; i < lvInfo.Columns.Count; i++) { TextBox t = new TextBox(); Item.SubItems.Add(""); } Item.SubItems[0].Text = item.vcm_RecordID.ToString(); Item.SubItems[1].Text = item.vcm_cHolidayName; Item.SubItems[2].Text = item.vcm_cType.ToString();//假期類型 //Item.SubItems[3].Text = item.vcm_TargetID.ToString();//區域ID Item.SubItems[3].Text = _AreaInfo.SingleOrDefault(t => t.Key == item.vcm_TargetID).Value; Item.SubItems[4].Text = item.vcm_dStartDate.ToString("dd/MM/yyyy HH:mm"); Item.SubItems[5].Text = item.vcm_dEndDate.ToString("dd/MM/yyyy HH:mm"); Item.SubItems[6].Text = item.vcm_cWeekDate;//星期數 Item.SubItems[7].Text = item.vcm_lIsAtive == true ? "是" : "否"; this.lvInfo.Items.Add(Item);//显示 } this.lvInfo.EndUpdate(); }
public VacationManagementAppSetting() { InitializeComponent(); this._VacationMasterBL = MasterBLLFactory.GetBLL<IVacationMasterBL>(MasterBLLFactory.VacationMaster); this.SysToolBar.OnItemSave_Click += new SystemToolBar.ItemSave_Click(SysToolBar_ItemSave_Click); this.SysToolBar.OnItemExit_Click += new SystemToolBar.ItemExit_Click(SysToolBar_ItemExit_Click); _isChanged = false; _CurrentAfwInfo = null; //todo: 需初始化用戶信息 if (base.UserInformation == null) { base.UserInformation = new Model.SysMaster.Sys_UserMaster_usm_Info(); base.UserInformation.usm_cUserLoginID = "sys"; } }
public bool InsertRecord(VacationMaster_vcm_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { VacationMaster_vcm newTab = Common.General.CopyObjectValue<VacationMaster_vcm_Info, VacationMaster_vcm>(infoObject); db.VacationMaster_vcm.InsertOnSubmit(newTab); db.SubmitChanges(); isSuccess = true; } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public VacationMaster_vcm_Info DisplayRecord(Model.IModel.IModelObject KeyObject) { VacationMaster_vcm_Info info = new VacationMaster_vcm_Info(); info = KeyObject as VacationMaster_vcm_Info; try { using(MainDBDataContext db = new MainDBDataContext ()) { VacationMaster_vcm disTab = db.VacationMaster_vcm.SingleOrDefault(t => t.vcm_RecordID == info.vcm_RecordID ); if (disTab != null) { info = Common.General.CopyObjectValue<VacationMaster_vcm, VacationMaster_vcm_Info>(disTab); } } } catch (Exception Ex) { throw Ex; } return info; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Set_AreaInfo(); if (this.EditState == DefineConstantValue.EditStateEnum.OE_Insert) { this.TabText = "新增" + this.Text; if (base.BaseParam != null) { VacationMaster_vcm_Info info = BaseParam as VacationMaster_vcm_Info; info.vcm_RecordID = Guid.NewGuid(); this._CurrentAfwInfo = info; } } else if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update) { this.TabText = "編輯" + this.Text; if (base.BaseParam != null) { VacationMaster_vcm_Info info = BaseParam as VacationMaster_vcm_Info; //_iRocordID = info.vcm_iRecordID; this._CurrentAfwInfo = info; } } else if (this.EditState == DefineConstantValue.EditStateEnum.OE_ReaOnly) { this.TabText = "查看" + this.Text; if (base.BaseParam != null) { VacationMaster_vcm_Info info = BaseParam as VacationMaster_vcm_Info; //_iRocordID = info.vcm_iRecordID; this._CurrentAfwInfo = info; } } InitSysBar(); InitControls(); CheckChanged(); }
public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode) { Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo(); VacationMaster_vcm_Info info = new VacationMaster_vcm_Info(); returnValue.messageText = ""; info = itemEntity as VacationMaster_vcm_Info; try { switch (EditMode) { case Common.DefineConstantValue.EditStateEnum.OE_Insert: bool isExist = false; isExist = _VacationMasterDA.IsExistRecord(info); if (!isExist) { returnValue.boolValue = _VacationMasterDA.InsertRecord(info); } else { returnValue.boolValue = false; returnValue.messageText = "數據重複!"; } break; case Common.DefineConstantValue.EditStateEnum.OE_Update: returnValue.boolValue = _VacationMasterDA.UpdateRecord(info); break; case Common.DefineConstantValue.EditStateEnum.OE_Delete: returnValue.boolValue = _VacationMasterDA.DeleteRecord(info); break; } } catch (Exception Ex) { throw Ex; } return returnValue; }
public bool IsExistRecord(object KeyObject) { bool isExist = false; VacationMaster_vcm_Info info = new VacationMaster_vcm_Info(); info = KeyObject as VacationMaster_vcm_Info; try { using (MainDBDataContext db = new MainDBDataContext()) { VacationMaster_vcm query = db.VacationMaster_vcm.SingleOrDefault(t => t.vcm_RecordID == info.vcm_RecordID ); if (query != null) { isExist = true; } } } catch (Exception Ex) { throw Ex; } return isExist; }
public bool UpdateRecord(VacationMaster_vcm_Info infoObject) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { VacationMaster_vcm query = db.VacationMaster_vcm.SingleOrDefault(t => t.vcm_RecordID == infoObject.vcm_RecordID); if (query != null) { query.vcm_cHolidayName = infoObject.vcm_cHolidayName; query.vcm_cType = infoObject.vcm_cType; //query.vcm_TargetID = infoObject.vcm_TargetID; query.vcm_dStartDate =infoObject.vcm_dStartDate; query.vcm_dEndDate = infoObject.vcm_dEndDate; query.vcm_cWeekDate = infoObject.vcm_cWeekDate; query.vcm_lIsAtive = infoObject.vcm_lIsAtive; query.vcm_cLast = infoObject.vcm_cLast; query.vcm_dLastDate = infoObject.vcm_dLastDate; db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
public List<VacationMaster_vcm_Info> SearchRecords(Model.IModel.IModelObject searchCondition) { List<VacationMaster_vcm_Info> list = new List<VacationMaster_vcm_Info>(); VacationMaster_vcm_Info info = new VacationMaster_vcm_Info(); info = searchCondition as VacationMaster_vcm_Info; string strSQL = ""; strSQL += " SELECT vcm_RecordID,vcm_cHolidayName,vcm_cType,vcm_TargetID,vcm_dStartDate,vcm_dEndDate,vcm_cWeekDate,vcm_lIsAtive " + Environment.NewLine; strSQL += " FROM VacationMaster_vcm " + Environment.NewLine; //strSQL += " WHERE vcm_lIsAtive =0 " + Environment.NewLine; strSQL += " WHERE 1 =1 " + Environment.NewLine; if (info.vcm_TargetID != Guid.Empty) //小於零時搜索全部 { strSQL += " AND vcm_TargetID = '" + info.vcm_TargetID + "' " + Environment.NewLine; } IEnumerable<VacationMaster_vcm_Info> infos = null; try { using (MainDBDataContext db = new MainDBDataContext()) { infos = db.ExecuteQuery<VacationMaster_vcm_Info>(strSQL, new object[] { }); if (infos != null) { list = infos.ToList<VacationMaster_vcm_Info>(); } } } catch (Exception Ex) { throw Ex; } return list; }
/// <summary> /// 假期主檔 /// </summary> /// <returns></returns> public List<VacationMaster_vcm_Info> GetVacationMaster() { try { List<VacationMaster_vcm_Info> list = new List<VacationMaster_vcm_Info>(); StringBuilder strSql = new StringBuilder(); strSql.AppendLine("select "); strSql.AppendLine("vcm_RecordID,vcm_cHolidayName,vcm_cType,vcm_TargetID,vcm_lIsAtive,vcm_dStartDate,vcm_dEndDate,vcm_cWeekDate,vcm_cAdd,vcm_dAddDate,vcm_cLast,vcm_dLastDate "); strSql.AppendLine("from VacationMaster_vcm "); using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString())) { while (sdr.Read()) { VacationMaster_vcm_Info model = new VacationMaster_vcm_Info(); if (sdr["vcm_RecordID"] != null && sdr["vcm_RecordID"].ToString() != "") { model.vcm_RecordID = new Guid(sdr["vcm_RecordID"].ToString()); } if (sdr["vcm_cHolidayName"] != null && sdr["vcm_cHolidayName"].ToString() != "") { model.vcm_cHolidayName = sdr["vcm_cHolidayName"].ToString(); } if (sdr["vcm_cType"] != null && sdr["vcm_cType"].ToString() != "") { model.vcm_cType = sdr["vcm_cType"].ToString(); } if (sdr["vcm_TargetID"] != null && sdr["vcm_TargetID"].ToString() != "") { model.vcm_TargetID = new Guid(sdr["vcm_TargetID"].ToString()); } if (sdr["vcm_lIsAtive"] != null && sdr["vcm_lIsAtive"].ToString() != "") { if ((sdr["vcm_lIsAtive"].ToString() == "1") || (sdr["vcm_lIsAtive"].ToString().ToLower() == "true")) { model.vcm_lIsAtive = true; } else { model.vcm_lIsAtive = false; } } if (sdr["vcm_dStartDate"] != null && sdr["vcm_dStartDate"].ToString() != "") { model.vcm_dStartDate = DateTime.Parse(sdr["vcm_dStartDate"].ToString()); } if (sdr["vcm_dEndDate"] != null && sdr["vcm_dEndDate"].ToString() != "") { model.vcm_dEndDate = DateTime.Parse(sdr["vcm_dEndDate"].ToString()); } if (sdr["vcm_cWeekDate"] != null && sdr["vcm_cWeekDate"].ToString() != "") { model.vcm_cWeekDate = sdr["vcm_cWeekDate"].ToString(); } if (sdr["vcm_cAdd"] != null && sdr["vcm_cAdd"].ToString() != "") { model.vcm_cAdd = sdr["vcm_cAdd"].ToString(); } if (sdr["vcm_dAddDate"] != null && sdr["vcm_dAddDate"].ToString() != "") { model.vcm_dAddDate = DateTime.Parse(sdr["vcm_dAddDate"].ToString()); } if (sdr["vcm_cLast"] != null && sdr["vcm_cLast"].ToString() != "") { model.vcm_cLast = sdr["vcm_cLast"].ToString(); } if (sdr["vcm_dLastDate"] != null && sdr["vcm_dLastDate"].ToString() != "") { model.vcm_dLastDate = DateTime.Parse(sdr["vcm_dLastDate"].ToString()); } list.Add(model); } } return list; } catch (Exception ex) { throw ex; } }
private void ShowReadForm(object sender, EventArgs evArgs) { MenuItem itemMenu = new MenuItem(); itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.VacationManagementAppSetting"; if (lvInfo.SelectedItems.Count > 0) { VacationMaster_vcm_Info vcmParam = new VacationMaster_vcm_Info(); vcmParam.vcm_RecordID = new Guid(lvInfo.SelectedItems[0].SubItems[0].Text.Trim()); vcmParam.vcm_cHolidayName = lvInfo.SelectedItems[0].SubItems[1].Text.Trim(); vcmParam.vcm_cType = lvInfo.SelectedItems[0].SubItems[2].Text.Trim(); //vcmParam.vcm_TargetID = new Guid(lvInfo.SelectedItems[0].SubItems[3].Text.Trim()); vcmParam.vcm_TargetID = _AreaInfo.SingleOrDefault(t => t.Value == lvInfo.SelectedItems[0].SubItems[3].Text).Key; vcmParam.vcm_dStartDate = DateTime.Parse(lvInfo.SelectedItems[0].SubItems[4].Text.Trim(), new CultureInfo("fr-FR", true)); vcmParam.vcm_dEndDate = DateTime.Parse(lvInfo.SelectedItems[0].SubItems[5].Text.Trim(), new CultureInfo("fr-FR", true)); vcmParam.vcm_cWeekDate = lvInfo.SelectedItems[0].SubItems[6].Text.Trim(); vcmParam.vcm_lIsAtive = lvInfo.SelectedItems[0].SubItems[7].Text == "是" ? true : false; BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, "查看假期管理主檔", DockState.Document, vcmParam, DefineConstantValue.EditStateEnum.OE_ReaOnly); form.FromCloseCallBack += RefreshAllState; } else { this.ShowInformationMessage("先選擇一條記錄!"); } }
private void ShowAddForm(object sender, EventArgs evArgs) { MenuItem itemMenu = new MenuItem(); VacationMaster_vcm_Info vcmParam = new VacationMaster_vcm_Info(); itemMenu.Tag = "WindowUI.HBManagerTerminal.Management.RunningManagement.VacationManagementAppSetting"; if (_TargetID != Guid.Empty) { vcmParam.vcm_TargetID = _TargetID; } else { this.ShowInformationMessage("先選擇一個區域!"); return; } //this.ShowSubForm(itemMenu, this.BaseDockPanel); BaseForm form = this.ShowSubForm(itemMenu, this.BaseDockPanel, "新增假期管理主檔", DockState.Document, vcmParam, DefineConstantValue.EditStateEnum.OE_Insert); form.FromCloseCallBack += RefreshAllState; }
private void DeleteVcm(object sender, EventArgs evArgs) { this.Cursor = Cursors.WaitCursor; VacationMaster_vcm_Info delTab = new VacationMaster_vcm_Info(); ReturnValueInfo rvInfo = null; if (lvInfo.SelectedItems.Count > 0) { if (this.ShowQuestionMessage("是否確定刪除工作假期:" + this.lvInfo.SelectedItems[0].SubItems[1].Text + ",假期類型:" + this.lvInfo.SelectedItems[0].SubItems[2].Text)) { delTab.vcm_RecordID = new Guid(lvInfo.SelectedItems[0].SubItems[0].Text); rvInfo = _VacationMasterBL.Save(delTab, DefineConstantValue.EditStateEnum.OE_Delete); } else { this.Cursor = Cursors.Default; return; } } else { this.ShowInformationMessage("請選擇要刪除的記錄!"); this.Cursor = Cursors.Default; return; } if (rvInfo.boolValue && !rvInfo.isError) { this.ShowInformationMessage("刪除成功。"); RefreshAllState(); } else { this.ShowWarningMessage("刪除失敗,異常信息:" + rvInfo.messageText); } this.Cursor = Cursors.Default; }
////保存 private void SysToolBar_ItemSave_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; VacationMaster_vcm_Info saveInfo = new VacationMaster_vcm_Info(); ReturnValueInfo rvInfo = null; bool checkCanSave = CheckCanSave(); if (checkCanSave == false) { //this.ShowWarningMessage("保存失敗,獲取鍵入資料有誤。"); this.Cursor = Cursors.Default; return; } //this.ShowWarningMessage("可以保存"); if (this.EditState == DefineConstantValue.EditStateEnum.OE_Insert) { saveInfo.vcm_RecordID = _CurrentAfwInfo.vcm_RecordID; saveInfo.vcm_cHolidayName = lbVacationName.Text.Trim(); if (rbOnce.Checked == true) { saveInfo.vcm_cType = rbOnce.Text; } else if (rbEveryWeek.Checked == true) { saveInfo.vcm_cType = rbEveryWeek.Text; } saveInfo.vcm_TargetID = _TargetID; //saveInfo.vcm_lIsAtive = false; saveInfo.vcm_lIsAtive = true; saveInfo.vcm_dStartDate = dateTimePickerStrat.Value; saveInfo.vcm_dEndDate = dateTimePickerEnd.Value; saveInfo.vcm_cWeekDate = lbVacationWeekDate.Text; saveInfo.vcm_cAdd = base.UserInformation.usm_cUserLoginID; saveInfo.vcm_dAddDate = DateTime.Now; saveInfo.vcm_cLast = base.UserInformation.usm_cUserLoginID; saveInfo.vcm_dLastDate = DateTime.Now; rvInfo = _VacationMasterBL.Save(saveInfo, DefineConstantValue.EditStateEnum.OE_Insert); } else if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update) { saveInfo.vcm_RecordID = _iRocordID; saveInfo.vcm_cHolidayName = lbVacationName.Text.Trim(); if (rbOnce.Checked == true) { saveInfo.vcm_cType = rbOnce.Text; } else if (rbEveryWeek.Checked == true) { saveInfo.vcm_cType = rbEveryWeek.Text; } //saveInfo.vcm_TargetID = _CurrentAfwInfo.vcm_TargetID; //saveInfo.vcm_lIsAtive = false; saveInfo.vcm_lIsAtive = rbIsActive.Checked; saveInfo.vcm_dStartDate = dateTimePickerStrat.Value; saveInfo.vcm_dEndDate = dateTimePickerEnd.Value; saveInfo.vcm_cWeekDate = lbVacationWeekDate.Text; saveInfo.vcm_cLast = base.UserInformation.usm_cUserLoginID; saveInfo.vcm_dLastDate = DateTime.Now; rvInfo = _VacationMasterBL.Save(saveInfo, DefineConstantValue.EditStateEnum.OE_Update); } if (rvInfo.boolValue && !rvInfo.isError) { this.ShowInformationMessage("保存成功。"); } else { this.ShowWarningMessage("保存失敗,異常信息:" + rvInfo.messageText); } this.Cursor = Cursors.Default; }
private string GetVacationMasterSQL(VacationMaster_vcm_Info model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.vcm_RecordID != null) { strSql1.Append("vcm_RecordID,"); strSql2.Append("'" + model.vcm_RecordID + "',"); } if (model.vcm_cHolidayName != null) { strSql1.Append("vcm_cHolidayName,"); strSql2.Append("'" + model.vcm_cHolidayName + "',"); } if (model.vcm_cType != null) { strSql1.Append("vcm_cType,"); strSql2.Append("'" + model.vcm_cType + "',"); } if (model.vcm_TargetID != null) { strSql1.Append("vcm_TargetID,"); strSql2.Append("'" + model.vcm_TargetID + "',"); } if (model.vcm_lIsAtive != null) { strSql1.Append("vcm_lIsAtive,"); strSql2.Append("" + (model.vcm_lIsAtive ? 1 : 0) + ","); } if (model.vcm_dStartDate != null) { strSql1.Append("vcm_dStartDate,"); strSql2.Append("'" + model.vcm_dStartDate.ToString("s") + "',"); } if (model.vcm_dEndDate != null) { strSql1.Append("vcm_dEndDate,"); strSql2.Append("'" + model.vcm_dEndDate.ToString("s") + "',"); } if (model.vcm_cWeekDate != null) { strSql1.Append("vcm_cWeekDate,"); strSql2.Append("'" + model.vcm_cWeekDate + "',"); } if (model.vcm_cAdd != null) { strSql1.Append("vcm_cAdd,"); strSql2.Append("'" + model.vcm_cAdd + "',"); } if (model.vcm_dAddDate != null) { strSql1.Append("vcm_dAddDate,"); strSql2.Append("'" + model.vcm_dAddDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } if (model.vcm_cLast != null) { strSql1.Append("vcm_cLast,"); strSql2.Append("'" + model.vcm_cLast + "',"); } if (model.vcm_dLastDate != null) { strSql1.Append("vcm_dLastDate,"); strSql2.Append("'" + model.vcm_dLastDate.Value.ToString(this._sqlLiteDatetimeFormat) + "',"); } strSql.Append("insert into VacationMaster_vcm("); 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(); }