private void InitData() { Dictionary <string, string> filters = null; DataTable dataTable = null; string condition = null; try { Tool.ShowWaiting(); condition = "ORDER BY PKID DESC"; filters = new Dictionary <string, string>(); filters.Add("PARENTPKID", string.Format("={0}", pkId.ToString())); filters.Add("CLOSEDDATE", "IS NOT NULL"); filters.Add("ISDECISION", "='Y'"); dataTable = SqlConnector.GetTable(dbName, "Document", filters, condition); if (dataTable.Rows.Count.Equals(0)) { isEditMode = false; filters.Clear(); filters.Add("PKID", string.Format("={0}", pkId)); dataTable = SqlConnector.GetTable(dbName, "Document", filters); if (dataTable.Rows.Count.Equals(0)) { return; } } else { isEditMode = true; dateClosed.EditValue = DateTime.Parse(dataTable.Rows[0]["CLOSEDDATE"].ToString()); memoDecision.EditValue = dataTable.Rows[0]["SHORTDESC"].ToString(); } incomeDoc = new IncomeDoc(dataTable.Rows[0]["PKID"].ToString(), dataTable.Rows[0]["REGNUM"].ToString(), dataTable.Rows[0]["REGDATE"].ToString(), dataTable.Rows[0]["DOCNUM"].ToString(), dataTable.Rows[0]["DOCDATE"].ToString(), dataTable.Rows[0]["CONTROLDIRECTION"].ToString(), dataTable.Rows[0]["STAFFID"].ToString(), dataTable.Rows[0]["TOSTAFFID"].ToString(), dataTable.Rows[0]["TOBRID"].ToString(), dataTable.Rows[0]["DOCNOTEPKID"].ToString(), dataTable.Rows[0]["ORGANIZATIONTYPEPKID"].ToString(), dataTable.Rows[0]["INFROMWHO"].ToString(), dataTable.Rows[0]["ISREPLYDOC"].ToString(), dataTable.Rows[0]["SHORTDESC"].ToString(), dataTable.Rows[0]["PAGENUM"].ToString(), dataTable.Rows[0]["CREATEDDATE"].ToString()); txtRegNum.Text = incomeDoc.RegNum; txtDocNum.Text = incomeDoc.DocNum; lkUpStaff.Properties.DataSource = MainPage.allUser; lkUpStaff.EditValue = isEditMode ? incomeDoc.StaffId : Tool.userStaffId; } catch (MofException ex) { System.Diagnostics.Debug.WriteLine("Шийдвэрийн мэдээллийг авчрахад алдаа гарлаа: " + ex.InnerException.Message); Tool.ShowError(ex.Message, ex.InnerException.Message); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Шийдвэрийн мэдээллийг авчрахад гарлаа: " + ex.Message); Tool.ShowError("Шийдвэрийн мэдээллийг авчрахад гарлаа!", ex.Message); } finally { filters = null; dataTable = null; Tool.CloseWaiting(); } }
private void InitData() { Dictionary <string, string> filters = null; DataTable dataTable = null; Dictionary <string, object> filterStored = null; List <string> tableNames = null; DataSet ds = null; decimal toBrId; try { Tool.ShowWaiting(); filters = new Dictionary <string, string>(); filters.Add("PARENTPKID", string.Format("={0}", document.PkId.ToString())); filters.Add("CLOSEDDATE", "IS NOT NULL"); filters.Add("ISDECISION", "='Y'"); dataTable = SqlConnector.GetTable(dbName, "Document", filters); if (dataTable.Rows.Count.Equals(0)) { isEditMode = false; filters.Clear(); filters.Add("PKID", string.Format("={0}", document.PkId)); dataTable = SqlConnector.GetTable(dbName, "Document", filters); if (dataTable.Rows.Count.Equals(0)) { return; } } else { isChanged = isEditMode = true; dateClosed.EditValue = DateTime.Parse(dataTable.Rows[0]["CLOSEDDATE"].ToString()); memoDecision.EditValue = dataTable.Rows[0]["SHORTDESC"].ToString(); emIndexNumber = txtReplyNum.Text = dataTable.Rows[0]["REGNUM"].ToString(); txtPageNum.Text = dataTable.Rows[0]["PAGENUM"].ToString(); } incomeDoc = new IncomeDoc(dataTable.Rows[0]["PKID"].ToString(), dataTable.Rows[0]["REGNUM"].ToString(), dataTable.Rows[0]["REGDATE"].ToString(), dataTable.Rows[0]["DOCNUM"].ToString(), dataTable.Rows[0]["DOCDATE"].ToString(), dataTable.Rows[0]["CONTROLNUM"].ToString(), dataTable.Rows[0]["CONTROLDIRECTION"].ToString(), dataTable.Rows[0]["STAFFID"].ToString(), dataTable.Rows[0]["TOSTAFFID"].ToString(), dataTable.Rows[0]["TOBRID"].ToString(), dataTable.Rows[0]["DOCNOTEPKID"].ToString(), dataTable.Rows[0]["ORGANIZATIONTYPEPKID"].ToString(), dataTable.Rows[0]["INFROMWHO"].ToString(), dataTable.Rows[0]["ISREPLYDOC"].ToString(), dataTable.Rows[0]["SHORTDESC"].ToString(), dataTable.Rows[0]["PAGENUM"].ToString(), dataTable.Rows[0]["CREATEDDATE"].ToString(), dataTable.Rows[0]["RETURNDATE"].ToString(), dataTable.Rows[0]["SCANNEDFILE"].ToString()); txtRegNum.Text = document.RegNum; txtDocNum.Text = incomeDoc.DocNum; txtControlNum.Text = incomeDoc.ControlNum; dateReturn.EditValue = incomeDoc.ReturnDate; filters.Clear(); filters.Add("STATUS", "='Y'"); lkUpReplyType.Properties.DataSource = SqlConnector.GetTable(dbName, "DocNoteType", new List <String>() { "PKID", "NAME" }, filters); lkUpReplyType.EditValue = isEditMode ? incomeDoc.DocNotePkId : defaultDocNoteType; //lkUpBranch.Properties.DataSource = MainPage.branchInfo.Select("BR_ID NOT IN ('9908', '9905', '9907','9915', '9913')").CopyToDataTable(); lkUpBranch.Properties.DataSource = MainPage.branchInfo; if (isEditMode) { ckIsReturn.Checked = !txtReplyNum.Text.Equals(document.RegNum); } if (isEditMode) { lkUpBranch.EditValue = incomeDoc.ToBrId; emBranchId = (decimal)incomeDoc.ToBrId; lkUpClosedStaff.EditValue = incomeDoc.ToStaffId; } else { filterStored = new Dictionary <string, object>(); filterStored.Add("@PKID", document.PkId); filterStored.Add("@IsFirst", "Y"); tableNames = new List <string>() { "ChildrenDocument" }; ds = SqlConnector.GetStoredProcedure(dbName, "GetChildrenIncome", filterStored, tableNames); if (ds.Tables["ChildrenDocument"] == null) { if (incomeDoc.ToBrId.Equals(9908) || incomeDoc.ToBrId.Equals(9905) || incomeDoc.ToBrId.Equals(9907) || incomeDoc.ToBrId.Equals(9915) || incomeDoc.ToBrId.Equals(9913)) { Tool.ShowInfo("Бичгээ хэлтсийн мэргэжилтэн рүү шилжүүлнэ үү."); this.Dispose(); return; } lkUpBranch.EditValue = incomeDoc.ToBrId; lkUpClosedStaff.EditValue = incomeDoc.ToStaffId; } else { toBrId = decimal.Parse(ds.Tables["ChildrenDocument"].Rows[ds.Tables["ChildrenDocument"].Rows.Count - 1]["TOBRID"].ToString()); if (toBrId.Equals(9908) || toBrId.Equals(9905) || toBrId.Equals(9907) || toBrId.Equals(9915) || toBrId.Equals(9913)) { Tool.ShowInfo("Бичгээ хэлтсийн мэргэжилтэн рүү шилжүүлнэ үү."); this.Dispose(); return; } lkUpBranch.EditValue = toBrId; lkUpClosedStaff.EditValue = decimal.Parse(ds.Tables["ChildrenDocument"].Rows[ds.Tables["ChildrenDocument"].Rows.Count - 1]["TOSTAFFID"].ToString()); } } } catch (MofException ex) { System.Diagnostics.Debug.WriteLine("Шийдвэрийн мэдээллийг авчрахад алдаа гарлаа: " + ex.InnerException.Message); Tool.ShowError(ex.Message, ex.InnerException.Message); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Шийдвэрийн мэдээллийг авчрахад гарлаа: " + ex.Message); Tool.ShowError("Шийдвэрийн мэдээллийг авчрахад гарлаа!", ex.Message); } finally { filters = null; dataTable = null; filterStored = null; tableNames = null; ds = null; Tool.CloseWaiting(); } }