private void btnTimKiem_Click(object sender, EventArgs e) { XmlTextReader reader = new XmlTextReader("Hang.xml"); DataSet ds = new DataSet(); ds.ReadXml(reader); DataView dv = new DataView(ds.Tables[0]); dv.Sort = "MaHang"; reader.Close(); int index = dv.Find(txtTimKiem.Text); if (index == -1) { MessageBox.Show("Không tìm thấy"); txtTimKiem.Text = ""; txtTimKiem.Focus(); } else { DataTable dt = new DataTable(); dt.Columns.Add("Mã hàng"); dt.Columns.Add("Tên hàng"); dt.Columns.Add("Đơn vị tính"); dt.Columns.Add("Đơn giá"); dt.Columns.Add("Sô lượng"); dt.Columns.Add("Mã NCC"); object[] list = { dv[index]["MaHang"], dv[index]["TenHang"],dv[index]["DonViTinh"], dv[index]["DonGia"], dv[index]["SoLuong"], dv[index]["MaNCC"]}; dt.Rows.Add(list); dgvHang.DataSource = dt; txtTimKiem.Text = ""; } }
private void btnTimKiem_Click(object sender, EventArgs e) { XmlTextReader reader = new XmlTextReader("NhanVien.xml"); DataSet ds = new DataSet(); ds.ReadXml(reader); DataView dv = new DataView(ds.Tables[0]); dv.Sort = "MaNhanVien"; reader.Close(); int index = dv.Find(txtTimKiem.Text); if (index == -1) { MessageBox.Show("Không tìm thấy"); txtTimKiem.Text = ""; txtTimKiem.Focus(); } else { DataTable dt = new DataTable(); dt.Columns.Add("Mã nhân viên"); dt.Columns.Add("Họ và tên"); dt.Columns.Add("Ngày sinh"); dt.Columns.Add("Địa chỉ"); dt.Columns.Add("Số điện thoại"); dt.Columns.Add("Email"); object[] list = { dv[index]["MaNhanVien"], dv[index]["TenNhanVien"],dv[index]["NgaySinh"], dv[index]["DiaChi"], dv[index]["SDT"], dv[index]["Email"]}; dt.Rows.Add(list); dgvNhanVien.DataSource = dt; txtTimKiem.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Int32 IdInt = Convert.ToInt32(Request.Params["id"]); if (IdInt == 0) { IdInt = Convert.ToInt32(Session["id"]); } else Session["id"] = IdInt; SqlConnection sqlConn = GetConnection(); sqlConn.Open(); string sqlStr = "select * from Teacher where TeacherID = " + IdInt + ""; SqlCommand sqlComm = new SqlCommand(sqlStr, sqlConn); SqlDataAdapter sda = new SqlDataAdapter(); sda.SelectCommand = sqlComm; DataSet ds = new DataSet(); sda.Fill(ds, "Teacher"); DataView dv = new DataView(ds.Tables["Teacher"], "", "TeacherID", DataViewRowState.CurrentRows); int rowIndex = dv.Find(IdInt); //Image1.ImageUrl = dv[rowIndex]["MyPhoto"].ToString().Trim(); Image1.ImageUrl = "~/images/person/" + dv[rowIndex]["MyPhoto"].ToString(); SqlDataSource1.FilterExpression = "TeacherID = " + IdInt + ""; DetailsView1.DataSourceID = "SqlDataSource1"; DetailsView1.DataBind(); } }
/// <summary> /// Receives a string value and a DataView as parameters and searches the /// DataView for that string using the current sort order. Unlike VFP, /// this function does not change the position of the record but returns /// the record number if a seek is successful. The function returns a -1 /// if the seek is unsuccessful /// </summary> /// <param name="tcString"></param> /// <param name="toView"></param> /// <returns></returns> public static int Seek(string tcString, System.Data.DataView toView) { int nFound = 0; nFound = toView.Find(tcString); //If we seek is successful, update the Found flag and return the position if (nFound != -1) { vfpData._Found = true; } return(nFound); }
public bool GetRtValue(int nNum, numInf[] nrst, int sNum, strInf[] srst) { try { using (SqlCommand cmd = new SqlCommand("SELECT a.TAG,a.VALUE,a.TIME FROM REALVALUE a INNER JOIN TAGCONFIG b ON b.TYPE=0 AND a.TAG=b.TAG ORDER BY b.ID_KEY", _con)) using (SqlDataAdapter dad = new SqlDataAdapter(cmd)) using (DataTable dtbl = new DataTable()) { dad.Fill(dtbl); using (DataView dvw = new DataView(dtbl, "", "TAG", DataViewRowState.CurrentRows)) { for (int i = 0; i < nrst.Length; ++i) { int idx = dvw.Find(nrst[i].srcId); if (-1 != idx) { nrst[i].val = Convert.ToSingle(dvw[idx][1]); nrst[i].dtm = Convert.ToDateTime(dvw[idx][2]); } } } } using (SqlCommand cmd = new SqlCommand("SELECT a.TAG,a.VALUE,a.TIME FROM REALVALUE a INNER JOIN TAGCONFIG b ON b.TYPE=1 AND a.TAG=b.TAG ORDER BY b.ID_KEY", _con)) using (SqlDataAdapter dad = new SqlDataAdapter(cmd)) using (DataTable dtbl = new DataTable()) { dad.Fill(dtbl); using (DataView dvw = new DataView(dtbl, "", "TAG", DataViewRowState.CurrentRows)) { for (int i = 0; i < srst.Length; ++i) { int idx = dvw.Find(srst[i].srcId); if (-1 != idx) { srst[i].val = dvw[idx][1].ToString(); srst[i].dtm = Convert.ToDateTime(dvw[idx][2]); } } } } return true; } catch (Exception ex) { DisConnect(); Connect(); err.WrtMsg(ex.Message); return false; } }
private static void FillAllParents(string id, DataView view, bool includingSelf, SCSimpleObjectCollection parents) { int index = view.Find(id); if (index >= 0) { DataRow row = view[index].Row; if (includingSelf) parents.Add(MapDataRowToSimpleObject(row)); FillAllParentsRecursively(row["ParentID"].ToString(), view, parents); } }
private static void CompareAndAddUserExtendData(DataTable srcTable, DataTable targetTable, DataView compareView) { //提出要添加的行 foreach (DataRow dr in srcTable.Rows) { int index = compareView.Find(dr["ID"]); if (index == -1) { //添加新纪录 DataRow newdr = targetTable.NewRow(); AD2DBHelper.CopyDataRow(dr, newdr, "ID", "MOBILE", "OFFICE_TEL", "GENDER", "NATION", "IM_ADDRESS"); targetTable.Rows.Add(newdr); } } }
private static void CompareAndAddUserData(DataTable srcTable, DataTable targetTable, DataView compareView) { //提出要添加的行 foreach (DataRow dr in srcTable.Rows) { int index = compareView.Find(dr["GUID"]); if (index == -1) { //添加新纪录 DataRow newdr = targetTable.NewRow(); AD2DBHelper.CopyDataRow(dr, newdr, "GUID", "FIRST_NAME", "LAST_NAME", "LOGON_NAME", "PWD_TYPE_GUID", "USER_PWD", "RANK_CODE", "POSTURAL", "PINYIN", "E_MAIL"); targetTable.Rows.Add(newdr); } } }
public static Boolean CheckUserAccount(string pUserName, string pPassword) { try { DataView dv = new DataView(clsDeclare.glbDataSet.Tables["SYS_User"]); dv.Sort = "UserName"; int index = dv.Find(pUserName); if (index < 0) { return false; } if (Security.Encrypte(pPassword) != dv[index]["Password"].ToString()) { return false; } return true; } catch { return false; } }
private static void CompareAndAddOguData(DataTable srcTable, DataTable targetTable, DataView compareView, AD2DBTransferContext context) { //提出要添加的行 foreach (DataRow dr in srcTable.Rows) { int index = compareView.Find(dr["GUID"]); if (index == -1) { //添加新纪录 DataRow newdr = targetTable.NewRow(); UpdateSort(dr, context); AD2DBHelper.CopyDataRow(dr, newdr, "GUID", "PARENT_GUID", "OBJ_NAME", "DISPLAY_NAME", "DESCRIPTION", "DESCRIPTION", "ALL_PATH_NAME", "ORIGINAL_SORT", "CHILDREN_COUNTER", "GLOBAL_SORT", "RANK_CODE", "INNER_SORT", "ORG_TYPE", "ORG_CLASS", "STATUS", "SEARCH_NAME"); targetTable.Rows.Add(newdr); } } }
/// <summary>Finds a a Object record using a configuration and an external identifier.</summary> /// <param name="configurationId">Specified which mappings (user id columns) to use when looking up external identifiers.</param> /// <param name="parameterId">The name of the parameter as specified in the configuration table.</param> /// <param name="externalId">The external (user supplied) identifier for the record.</param> public static int FindKey(object configurationId, string parameterId, object externalId) { // A missing key will never match a column. if ((externalId == null)) { return int.MinValue; } // Accessor for the Object Table. ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object; // Look for the record using the external identifier. The configuration selected the key to use, which effectively // selected the external id column to use for the search. If a record is found in the view, a translation still needs // to be made back to the original table before an index to the record can be returned to the caller. int externalKeyIndex = Object.GetExternalKeyIndex(configurationId, parameterId); System.Data.DataView externalKeyView = Object.externalKeyArray[externalKeyIndex]; int recordIndex = externalKeyView.Find(new object[] { externalId}); if ((recordIndex == -1)) { return int.MinValue; } return ((int)(externalKeyView[recordIndex].Row[objectTable.ObjectIdColumn])); }
public bool generateBainaryMatchData() { DataTable dt = new DataTable(); genologyDAL genology = new genologyDAL(); string LeftChild = ""; string RightChild = ""; bool status = false; DataRow dr = null; try { dt = getStakeJoiningList(); DataTable dtnode = getMatchingNodeList(); DataTable dtParent = getStakeJoiningParentList(); for (int i = 0; i < dt.Rows.Count; i++) { InserNode = new DataTable(); InserNode.Columns.Add(new DataColumn("NodeId")); InserNode.Columns.Add(new DataColumn("ChildId")); InserNode.Columns.Add(new DataColumn("Amount")); InserNode.Columns.Add(new DataColumn("Position")); LeftChild = ""; RightChild = ""; findLeftRight(dt.Rows[i]["PleacementId"].ToString(), out LeftChild, out RightChild); if (LeftChild != "") { viststack.Push(LeftChild); DataView view = new DataView(dt); view.RowFilter = "UserId = '" + LeftChild + "'"; DataView viewNode = new DataView(dtnode); viewNode.Sort = "ChildId"; viewNode.RowFilter = "NodeID = '" + dt.Rows[i]["PleacementId"].ToString() + "'"; if (viewNode.Count > 0) { int index = viewNode.Find(view[0]["UserId"].ToString()); if (index == -1) { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = dt.Rows[i]["PleacementId"].ToString(); dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = "L"; InserNode.Rows.Add(dr); } } } else { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = dt.Rows[i]["PleacementId"].ToString(); dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = "L"; InserNode.Rows.Add(dr); } } VisitChildrenByParentId(dt.Rows[i]["PleacementId"].ToString(), dt, dtnode, "L"); } if (RightChild != "") { viststack.Push(RightChild); DataView view = new DataView(dt); view.RowFilter = "UserId = '" + RightChild + "'"; DataView viewNode = new DataView(dtnode); viewNode.Sort = "ChildId"; viewNode.RowFilter = "NodeID = '" + dt.Rows[i]["PleacementId"].ToString() + "'"; if (viewNode.Count > 0) { int index = viewNode.Find(view[0]["UserId"].ToString()); if (index == -1) { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = dt.Rows[i]["PleacementId"].ToString(); dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = "R"; InserNode.Rows.Add(dr); } } } else { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = dt.Rows[i]["PleacementId"].ToString(); dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = "R"; InserNode.Rows.Add(dr); } } VisitChildrenByParentId(dt.Rows[i]["PleacementId"].ToString(), dt, dtnode, "R"); } if (InserNode.Rows.Count > 0) { insertIntoNodeList(InserNode); status = true; } } //LumexDBPlayer db = LumexDBPlayer.Start(true); //dt = genology.getStakeJoiningList(db); //db.Stop(); // return dt; return status; } catch (Exception) { throw; } }
private bool VisitChildrenByParentId(string Node, DataTable alldata, DataTable dtnode, string position) { bool status = false; while (viststack.Count > 0) { string MainUser = viststack.Pop(); DataView view = new DataView(alldata); view.RowFilter = "PleacementId = '" + MainUser + "'"; DataView viewNode = new DataView(dtnode); viewNode.Sort = "ChildId"; viewNode.RowFilter = "NodeID = '" + Node + "'"; DataRow dr = null; if (view.Count > 1) { if (viewNode.Count > 0) { int index = viewNode.Find(view[0]["UserId"].ToString()); if (index == -1) { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } } index = viewNode.Find(view[1]["UserId"].ToString()); if (index == -1) { if (Convert.ToDecimal(view[1]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[1]["UserId"].ToString(); dr["Amount"] = view[1]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } } // viststack.Push(view[0]["UserId"].ToString()); //viststack.Push(view[1]["UserId"].ToString()); } else { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } if (Convert.ToDecimal(view[1]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[1]["UserId"].ToString(); dr["Amount"] = view[1]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } } //if (view[0]["UserId"].ToString() != Node) //{ viststack.Push(view[0]["UserId"].ToString()); // } // if (view[1]["UserId"].ToString() != Node) // { viststack.Push(view[1]["UserId"].ToString()); // } // viststack.Push(view[1]["UserId"].ToString()); } else if (view.Count == 1) { if (viewNode.Count > 0) { int index = viewNode.Find(view[0]["UserId"].ToString()); if (index == -1) { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } // viststack.Push(view[0]["UserId"].ToString()); // if (view[0]["UserId"].ToString() != Node) // { // } } viststack.Push(view[0]["UserId"].ToString()); } else { if (Convert.ToDecimal(view[0]["StakeAmount"].ToString()) > 0) { dr = InserNode.NewRow(); dr["NodeId"] = Node; dr["ChildId"] = view[0]["UserId"].ToString(); dr["Amount"] = view[0]["StakeAmount"].ToString(); dr["Position"] = position; InserNode.Rows.Add(dr); } // viststack.Push(view[0]["UserId"].ToString()); // if (view[0]["UserId"].ToString() != Node) // { viststack.Push(view[0]["UserId"].ToString()); //} } } //if (viststack.Count >= 1) //{ // VisitChildrenByParentId(Node, alldata, dtnode, position); //} //else if (VisitChildrenByParentId(Node, alldata, dtnode, position)) //{ // break; //} status = false; } return status; }
public void SetValues() { //set the values of the txtboxes //note that we need both dataviews (they could be differnt versions of the same //dataset but either way, we need two, one sorted by waterbodyid and one by //waterbodyname. LoadWaterDataSet(); DataView dvWatersheds = new DataView(objdsWatersheds.Tables["DE-Watersheds"],"","WaterBodyID", DataViewRowState.CurrentRows); int j = dvWatersheds.Find(Session["SelectedWaterBodyID"].ToString()); txtwaterbodyid.Text = dvWatersheds[j]["WaterBodyID"].ToString(); txtwaterbodyname.Text = dvWatersheds[j]["WaterBodyName"].ToString(); txtwatershed.Text = dvWatersheds[j]["DrainageCd"].ToString(); }
public Boolean CheckKeyOnGlb(string pTable, string pSort, object[] pValues, DataSet pDataset) { DataView dv = new DataView(pDataset.Tables[pTable]); dv.Sort = pSort; int index = dv.Find(pValues); if (index >= 0) { return true; } else { return false; } }
private void SetCaptionDefault(Control ctr, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; keys[0] = pForm.Name; keys[1] = ctr.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctr.Text = row["Text"].ToString(); } }
private void SetCaption(DevExpress.XtraTreeList.TreeList ctrTree, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; foreach (DevExpress.XtraTreeList.Columns.TreeListColumn col in ctrTree.Columns) { keys[0] = pForm.Name; keys[1] = col.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; col.Caption = row["Text"].ToString(); } } }
private void SetCaption(DevExpress.XtraEditors.RadioGroup pRadioGroup, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; foreach (DevExpress.XtraEditors.Controls.RadioGroupItem ctr in pRadioGroup.Properties.Items) { keys[0] = pForm.Name; keys[1] = ctr.Description; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctr.Description = row["Text"].ToString(); } } }
private void SetCaption(DevExpress.XtraEditors.SplitContainerControl pctrSplitContainer, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; foreach (Control ctrSplit in pctrSplitContainer.Controls) { if (ctrSplit.GetType().Name == "SplitGroupPanel") { DevExpress.XtraEditors.SplitGroupPanel ctrSplitGroupPanel = (DevExpress.XtraEditors.SplitGroupPanel)ctrSplit; foreach (Control ctrSplitGroupPanel_ in ctrSplitGroupPanel.Controls) { if (ctrSplitGroupPanel_.GetType().Name == "NavBarControl") { DevExpress.XtraNavBar.NavBarControl ctrNavBar = (DevExpress.XtraNavBar.NavBarControl)ctrSplitGroupPanel_; foreach (DevExpress.XtraNavBar.NavBarGroup group in ctrNavBar.Groups) { keys[0] = pForm.Name; keys[1] = group.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; group.Caption = row["Text"].ToString(); group.Hint = row["Hint"].ToString(); } } foreach (DevExpress.XtraNavBar.NavBarItem item in ctrNavBar.Items) { keys[0] = pForm.Name; keys[1] = item.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; item.Caption = row["Text"].ToString(); item.Hint = row["Hint"].ToString(); } } } else { CallSetCaption(ctrSplitGroupPanel_.GetType().Name, ctrSplitGroupPanel_, pForm, pLanguage, dv); } } } } }
public DataRow GetRowByKey(string pTable, string pSort, object pValues, DataSet pDataset) { if (!pDataset.Tables.Contains(pTable)) { return null; } DataView dv = new DataView(pDataset.Tables[pTable]); dv.Sort = pSort; int index = dv.Find(pValues); if (index >= 0) { return pDataset.Tables[pTable].Rows[index]; } return null; }
private void EnableRemoteManagementQuota(List<HostingPlanQuotaInfo> quotas, DataView dataView) { // Sort by quota name dataView.Sort = "QuotaName"; // Try to find out the quota we are looking for... var indexOf = dataView.Find(Quotas.WEB_REMOTEMANAGEMENT); // Exit if nothing has been found if (indexOf == -1) return; // Retrieve QuotaID value from the row we have found var quotaId = Convert.ToInt32(dataView[indexOf]["QuotaID"]); // Look for the quota in quotas list var quotaInfo = quotas.Find(x => x.QuotaId.Equals(quotaId)); // Exit if nothing has been found if (quotaInfo == default(HostingPlanQuotaInfo)) return; // Enable quota if found quotaInfo.QuotaValue = 1; }
[Test] public void Find_ByArray() { int FindResult,ExpectedResult=-1; //create the source datatable DataTable dt = DataProvider.CreateParentDataTable(); //create the dataview for the table DataView dv = new DataView(dt); for (int i=0; i<dt.Rows.Count ; i++) { if ((int)dt.Rows[i]["ParentId"] == 3 && dt.Rows[i]["String1"].ToString() == "3-String1") { ExpectedResult = i; break; } } // Find ,no sort - exception try { FindResult = dv.Find(new object[] {"3","3-String1"}); Assert.Fail("DV49: Find Failed to throw ArgumentException"); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { Assert.Fail("DV50: Find. Wrong exception type. Got:" + exc); } dv.Sort = "String1,ParentId"; // Find = wrong sort, can not find FindResult = dv.Find(new object[] {"3","3-String1"}); Assert.AreEqual(-1, FindResult , "DV51"); dv.Sort = "ParentId,String1"; // Find FindResult = dv.Find(new object[] {"3","3-String1"}); Assert.AreEqual(ExpectedResult, FindResult , "DV52"); }
private void SetCaption(DevExpress.XtraEditors.ImageComboBoxEdit ctrImageComboBoxEdit, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; for (int i = 0; i < ctrImageComboBoxEdit.Properties.Items.Count; i++) { keys[0] = pForm.Name; keys[1] = ctrImageComboBoxEdit.Name + ctrImageComboBoxEdit.Properties.Items[i].Value.ToString(); keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctrImageComboBoxEdit.Properties.Items[i].Description = row["Text"].ToString(); } } }
public static string getOptionValue(string pOptionID, DataTable pDatTable) { string OptionValue = ""; DataView dv = new DataView(pDatTable); int i; try { dv.Sort = "OptionID"; i = dv.Find(pOptionID); if (i >= 0) { OptionValue = Convert.ToString(dv[i]["Value"]); } } catch { } return OptionValue; }
private DialogResult ShowMessage(string pMessageCode, int pMessageType, string pLanguage) { if (glbDataTable != null) { DataView dv = new DataView(glbDataTable); dv.Sort = "MessageCode"; int index = dv.Find(pMessageCode); if (index < 0) { index = dv.Find("AT_SY_0000"); if (index < 0) { return MessageBox.Show("Not found message code " + pMessageCode); } else { return ShowMessage("AT_SY_0000", Convert.ToInt32(MessageType.MSInform), pLanguage); } } else { string MS = ""; if (pLanguage.ToUpper() == "VIETNAMESE") { MS = dv[index]["MessageVN"] == DBNull.Value ? "" : dv[index]["MessageVN"].ToString(); } else { MS = dv[index]["MessageEN"] == DBNull.Value ? "" : dv[index]["MessageEN"].ToString(); } if (pMessageType == 1) { return MessageBox.Show(frmMain, MS, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else if (pMessageType == 2) { return MessageBox.Show(frmMain, MS, "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); } else if (pMessageType == 3) { return MessageBox.Show(frmMain, MS, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else if (pMessageType == 4) { return MessageBox.Show(frmMain, MS, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else if (pMessageType == 5) { return MessageBox.Show(frmMain, MS, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1); } else { return MessageBox.Show(frmMain, MS, pMessageCode, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); } } } else { return MessageBox.Show("Not found table SYS_Message"); } }
public Boolean GetValueOfglbDataset(string pTable, string pSort, object pValues, string pColumn, ref object pReturn, DataSet pDataset) { pReturn = null; if (!pDataset.Tables.Contains(pTable)) { return false; } DataView dv = new DataView(pDataset.Tables[pTable]); dv.Sort = pSort; int index = dv.Find(pValues); if (index >= 0) { pReturn = dv[index][pColumn]; if (pReturn == null) { return false; } return true; } else { return false; } }
private void SetCaption(DevExpress.XtraEditors.ImageListBoxControl ctrImageListBoxControl, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; for (int i = 0; i < ctrImageListBoxControl.Items.Count; i++) { keys[0] = pForm.Name; keys[1] = ctrImageListBoxControl.Items[i].Value.ToString(); keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctrImageListBoxControl.Items[i].Value = row["Text"].ToString(); //ctrImageListBoxControl.Items[i].Hint = row["Hint"].ToString(); } // InsertControl(pForm.Name, ctrImageListBoxControl.Items[i].Value.GetType().FullName, ctrImageListBoxControl.Items[i].Value.ToString(), ctrImageListBoxControl.Items[i].Value.ToString(), pLanguage, ""); } }
private void SetCaption(DevExpress.XtraGrid.GridControl ctrGrid, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; foreach (DevExpress.XtraEditors.Repository.RepositoryItem crtRepositoryItem in ctrGrid.RepositoryItems) { if (crtRepositoryItem.GetType().Name == "RepositoryItemImageComboBox") { DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox ctrRepositoryItemImageComboBox = (DevExpress.XtraEditors.Repository.RepositoryItemImageComboBox)crtRepositoryItem; foreach (DevExpress.XtraEditors.Controls.ImageComboBoxItem ctrImageComboBoxItem in ctrRepositoryItemImageComboBox.Items) { keys[0] = pForm.Name; keys[1] = ctrImageComboBoxItem.Description; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctrImageComboBoxItem.Description = row["Text"].ToString(); } //InsertControl(pForm.Name, ctrImageComboBoxItem.GetType().FullName, ctrImageComboBoxItem.Description, ctrImageComboBoxItem.Description, pLanguage, ""); } } } if (ctrGrid.MainView.GetType().Name == "GridView") { DevExpress.XtraGrid.Views.Grid.GridView ctrGridView = (DevExpress.XtraGrid.Views.Grid.GridView)ctrGrid.MainView; foreach (DevExpress.XtraGrid.Columns.GridColumn col in ctrGridView.Columns) { keys[0] = pForm.Name; keys[1] = col.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; col.Caption = row["Text"].ToString(); } } } }
/// <summary> /// Print out the Hierarchy using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Account Hierarchy"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } if (!FMainDS.AAccount.Columns.Contains("AccountPath")) { FMainDS.AAccount.Columns.Add("AccountPath", typeof(String)); FMainDS.AAccount.Columns.Add("AccountLevel", typeof(Int32)); } DataView PathView = new DataView(FMainDS.AAccountHierarchyDetail); PathView.Sort = "a_reporting_account_code_c"; DataView AccountView = new DataView(FMainDS.AAccount); AccountView.Sort = "a_account_code_c"; // I need to make the "AccountPath" field that will be used to sort the table for printout: foreach (DataRowView rv in PathView) { DataRow Row = rv.Row; String AccountCode = Row["a_reporting_account_code_c"].ToString(); String Path = Row["a_report_order_i"] + "-" + AccountCode + '~'; Int32 Level = 0; String ReportsTo = Row["a_account_code_to_report_to_c"].ToString(); while (ReportsTo != "") { Int32 ParentIdx = PathView.Find(ReportsTo); if (ParentIdx >= 0) { DataRow ParentRow = PathView[ParentIdx].Row; ReportsTo = ParentRow["a_account_code_to_report_to_c"].ToString(); Path = ParentRow["a_report_order_i"] + "-" + ParentRow["a_reporting_account_code_c"].ToString() + "~" + Path; Level++; if (Level > 100) // Surely this is a fault. If I just break here, { break; // the report will print and I should be able to see what the fault is. } } else { ReportsTo = ""; } } Int32 AccountIdx = AccountView.Find(AccountCode); DataRow AccountRow = AccountView[AccountIdx].Row; AccountRow["AccountPath"] = Path; AccountRow["AccountLevel"] = Level; } AccountView.Sort = "AccountPath"; DataTable SortedByPath = AccountView.ToTable(); ReportingEngine.RegisterData(SortedByPath, "AccountHierarchy"); ReportingEngine.RegisterData(FMainDS.AAnalysisAttribute, "AnalysisAttribute"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
private void SetCaption(System.Windows.Forms.GroupBox groupbox, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; keys[0] = pForm.Name; keys[1] = groupbox.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; groupbox.Text = row["Text"].ToString(); } foreach (Control ctr in groupbox.Controls) { CallSetCaption(ctr.GetType().Name, ctr, pForm, pLanguage, dv); } }
public void FindRowsWithoutSort () { DataTable dt = new DataTable ("table"); dt.Columns.Add ("col1"); dt.Columns.Add ("col2"); dt.Columns.Add ("col3"); dt.Rows.Add (new object [] {1,2,3}); dt.Rows.Add (new object [] {4,5,6}); dt.Rows.Add (new object [] {4,7,8}); dt.Rows.Add (new object [] {5,7,8}); dt.Rows.Add (new object [] {4,8,9}); DataView dv = new DataView (dt); dv.Find (1); }
private void SetCaption(DevExpress.XtraTab.XtraTabPage ctrPage, Form pForm, string pLanguage, DataView dv) { dv.Sort = "FormName,ControlName,Language"; int index; DataRowView row; object[] keys = new object[3]; keys[0] = pForm.Name; keys[1] = ctrPage.Name; keys[2] = pLanguage; index = dv.Find(keys); if (index >= 0) { row = dv[index]; ctrPage.Text = row["Text"].ToString(); } foreach (Control ctr in ctrPage.Controls) { CallSetCaption(ctr.GetType().Name, ctr, pForm, pLanguage, dv); } }