Clone() private method

private Clone ( ) : DataSet
return DataSet
        private void Load_catesearch()
        {
            var list = per.Load_danhmuc_search(1);
            if (list.Count > 0)
            {
                DataRelation relCat;
                DataTable tbl = DataUtil.LINQToDataTable(list);
                DataSet ds = new DataSet();
                ds.Tables.Add(tbl);

                tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                ds.Relations.Add(relCat);
                DataSet dsCat = ds.Clone();
                DataTable CatTable = ds.Tables[0];

                DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                Drcate_search.DataSource = dsCat.Tables[0];
                Drcate_search.DataTextField = "CAT_NAME";
                Drcate_search.DataValueField = "CAT_ID";
                Drcate_search.DataBind();
            }
            ListItem l = new ListItem("Tất cả", "0");
            l.Selected = true;
            Drcate_search.Items.Insert(0, l);
        }
        public void Loadchuyenmuc()
        {
            try
            {
                var CatList = (
                                from t2 in DB.ESHOP_CATEGORies
                                where t2.CAT_RANK > 0
                                
                                select new
                                {
                                    CAT_ID = t2.CAT_NAME == "------- Root -------" ? 0 : t2.CAT_ID,
                                    CAT_NAME = (string.IsNullOrEmpty(t2.CAT_CODE) ? t2.CAT_NAME : t2.CAT_NAME + "(" + t2.CAT_CODE + ")"),
                                    CAT_NAME_EN = (string.IsNullOrEmpty(t2.CAT_CODE_EN) ? t2.CAT_NAME_EN : t2.CAT_NAME_EN + "(" + t2.CAT_CODE_EN + ")"),
                                    CAT_PARENT_ID = t2.CAT_PARENT_ID,
                                    CAT_RANK = t2.CAT_RANK
                                }
                            );

                if (CatList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    DataTable tbl = DataUtil.LINQToDataTable(CatList);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    ddlCategory.DataSource = dsCat.Tables[0];
                    ddlCategory.DataTextField = "CAT_NAME";
                    ddlCategory.DataValueField = "CAT_ID";
                    ddlCategory.DataBind();

                }
                ListItem l = new ListItem("------ Chọn chuyên mục ------", "0", true);
                l.Selected = true;
                ddlCategory.Items.Insert(0, l);

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Reduces the DataSet "set" removing the strongly-typed DataTables from the input Type array
        /// </summary>
        /// <param name="set">           Data set to reduce</param>
        /// <param name="DataTableTypes">
        /// input Type array of strongly-typed DataTables to remove from set
        /// </param>
        public static void Preserve(System.Data.DataSet set, Type[] DataTableTypes)
        {
            System.Data.DataSet Set = set.Clone();

            bool orgConst = set.EnforceConstraints;

            Set.EnforceConstraints = false;

            foreach (System.Data.DataTable table in Set.Tables)
            {
                System.Data.DataTable toremove = null;

                HashSet <Type> hs = new HashSet <Type>(DataTableTypes.ToArray());

                Type t = table.GetType();

                if (!hs.Contains(t))
                {
                    toremove = set.Tables[table.TableName, table.Namespace];
                }

                if (toremove != null)
                {
                    toremove.ChildRelations.Clear();
                    toremove.ParentRelations.Clear();
                    foreach (System.Data.Constraint constraint in table.Constraints)
                    {
                        if (constraint.GetType().Equals(typeof(System.Data.ForeignKeyConstraint)))
                        {
                            toremove.Constraints.Remove(constraint.ConstraintName);
                        }
                    }
                    toremove.TableName += "...";
                }
            }

            foreach (System.Data.DataTable table in Set.Tables)
            {
                System.Data.DataTable toremove = set.Tables[table.TableName + "...", table.Namespace];
                if (toremove != null)
                {
                    toremove.Dispose();
                    set.Tables.Remove(toremove);
                }
            }

            Set.EnforceConstraints = orgConst;
        }
Esempio n. 4
0
        void IContentEditor.ResetAll()
        {
            workSheetDataGrid.DataMember = null;
            workSheetDataGrid.DataSource = null;
            workSheetDataSet.Dispose();
            workSheetDataSet = workSheetDataSetTemplate.Clone();

            try
            {
                workSheetDataGrid.SetDataBinding(workSheetDataSet, "Worksheet1");
            }
            catch
            {}                  //DataGrid has error while setting databinding in event: "'0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'"
            m_currentNoteCaption = "";
            m_currentNoteID      = "";
        }
Esempio n. 5
0
 public static DataSet GetNhatKyTheoNgay(PLMultiCombobox NV_ID, DateTime TuNgay, DateTime DenNgay)
 {
     DataSet ds = new DataSet();
     DatabaseFB db = HelpDB.getDatabase();
     DbCommand cmd = db.GetStoredProcCommand("IN_NHAT_KY_CONG_VIEC");
     db.AddInParameter(cmd, "@TUNGAY", DbType.DateTime, TuNgay);
     db.AddInParameter(cmd, "@DENNGAY", DbType.DateTime, DenNgay);
     db.LoadDataSet(cmd, ds, "IN_NHAT_KY_CONG_VIEC");
     #region Lọc lại dữ liệu trên DataSet
     DataRow[] dsrow = ds.Tables[0].Select("NV_ID in " + NV_ID._getStrSelectedIDs());
     DataSet NewDs = ds.Clone();
     foreach (DataRow item in dsrow)
         NewDs.Tables[0].ImportRow(item);
     #endregion
     return NewDs;
 }
        private void LoadCat()
        {
            try
            {
                var AllList = (from g in db.TYPE_COMPANies
                               where g.TYPE_RANK > 0
                               select new
                               {
                                   g.TYPE_ID,
                                   g.TYPE_PARENT,
                                   g.TYPE_RANK,
                                   g.TYPE_ACTIVE,
                                   g.ORDERBY,
                                   g.TYPE_NAME
                               });

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    Session["companies.listmenucha"] = DataUtil.LINQToDataTable(AllList);
                    DataTable tbl = Session["companies.listmenucha"] as DataTable;

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["TYPE_ID"] };
                    relCat = new DataRelation("TYPE_PARENT", ds.Tables[0].Columns["TYPE_ID"], ds.Tables[0].Columns["TYPE_PARENT"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    unit_data.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    HttpContext.Current.Session["companies.listmenucha"] = dsCat.Tables[0];
                    ASPxTreeList_menu.DataSource = dsCat.Tables[0];
                    ASPxTreeList_menu.DataBind();
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 7
0
 public static DataSet GetThoiGianLamViec(PLMultiCombobox NV_ID, bool LoaiLV, bool LoaiDTVS, bool LoaiNP, DateTime TuNgay, DateTime DenNgay)
 {
     DataSet ds = new DataSet();
     DatabaseFB db = HelpDB.getDatabase();
     DbCommand cmd = db.GetStoredProcCommand("IN_THOI_GIAN_LAM_VIEC");
     db.AddInParameter(cmd, "@ILOAILV", DbType.Byte, LoaiLV == true ? 1 : 0);
     db.AddInParameter(cmd, "@ILOAIDTVS", DbType.Byte, LoaiDTVS == true ? 2 : 0);
     db.AddInParameter(cmd, "@ILOAINP", DbType.Byte, LoaiNP == true ? 3 : 0);
     db.AddInParameter(cmd, "@TUNGAY", DbType.DateTime, TuNgay);
     db.AddInParameter(cmd, "@DENNGAY", DbType.DateTime, DenNgay);
     db.LoadDataSet(cmd, ds, "IN_THOI_GIAN_LAM_VIEC");
     #region Lọc lại dữ liệu trên DataSet
     DataRow[] dsrow = ds.Tables[0].Select("NV_ID in " + NV_ID._getStrSelectedIDs());
     DataSet NewDs = ds.Clone();
     foreach (DataRow item in dsrow)
         NewDs.Tables[0].ImportRow(item);
     #endregion
     return NewDs;
 }
        private void SearchResult()
        {
            try
            {
                string keyword = txtKeyword.Value;
                int _limit = 20;
                int _skip = 0;
                if (_page != 0)
                    _skip = _page * _limit - _limit;
                var AllList = (from g in DB.MENUs
                               where "" == keyword || g.MENU_NAME.Contains(keyword)
                               orderby g.ID descending
                               select g);

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;

                    DataTable tbl = DataUtil.LINQToDataTable(AllList);

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["MENU_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    CpanelUtils.TransformTableWithSpace2(ref CatTable, dsCat.Tables[0], relCat, null);
                    RplistMenu.DataSource = dsCat.Tables[0];
                    RplistMenu.DataBind();
                    //LitPage.Text = pagechange.changePage("customer_list.aspx", AllList.ToList().Count, _limit, _page);
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
        private void LoadMenu()
        {
            try
            {
                var AllList = DB.MENUs.Where(n => n.MENU_ACTIVE == 1);

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;

                    DataTable tbl = DataUtil.LINQToDataTable(AllList);

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["MENU_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    CpanelUtils.TransformTableWithSpace2(ref CatTable, dsCat.Tables[0], relCat, null);
                    Drchuyenmuc.DataValueField = "ID";
                    Drchuyenmuc.DataTextField = "MENU_NAME";
                    Drchuyenmuc.DataSource = dsCat.Tables[0];
                    Drchuyenmuc.DataBind();
                }
                ListItem l = new ListItem("------- Root -------", "0");
                l.Selected = true;
                Drchuyenmuc.Items.Insert(0, l);
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 10
0
        private DataSet resolveSplits(DataSet thisDS)
        {
            DataTable allocation = thisDS.Tables["Allocation"];
            DataTable split = thisDS.Tables["Split"];

            DataSet newAllocation = thisDS.Clone();
            newAllocation.Relations.Clear();
            newAllocation.EnforceConstraints = false;
            //newAllocation.Tables["Allocation"].PrimaryKey = null;
            //newAllocation.Tables["Split"].PrimaryKey = null;
            //newAllocation.Tables["Allocation"].Constraints.Clear();
            //newAllocation.Tables["Split"].Constraints.Clear();

            var query1 = from DataRow o in allocation.Rows
                        where o["Company"].ToString() != "Split"
                        select new
                        {
                            ChargeID = o["ChargeID"],
                            Cardholder_Name = o["Cardholder Name"],
                            Process_Date = o["Process Date"],
                            Merchant_Name_Location = o["Merchant Name/Location"],
                            Amount = o["Amount"],
                            Company = o["Company"],
                            Account = o["Account"],
                            Description = o["Description"]
                        };
            //TODO: Clean this up? Use OO?
            foreach (var row in query1)
            {
                DataRow dr = newAllocation.Tables["Allocation"].NewRow();
                dr["ChargeID"] = row.ChargeID;
                dr["Cardholder Name"] = row.Cardholder_Name;
                dr["Process Date"] = row.Process_Date;
                dr["Merchant Name/Location"] = row.Merchant_Name_Location;
                dr["Amount"] = row.Amount;
                dr["Company"] = row.Company;
                dr["Account"] = row.Account;
                dr["Description"] = row.Description;
                newAllocation.Tables["Allocation"].Rows.Add(dr);
            }

            var query = from DataRow o in allocation.Rows
                        where o["Company"].ToString() == "Split"
                        join DataRow ol in split.Rows on o["ChargeID"] equals ol["ChargeID"]
                        //where ol["Company"].ToString() == company
                        select new
                        {
                            ChargeID = o["ChargeID"],
                            Cardholder_Name = o["Cardholder Name"],
                            Process_Date = o["Process Date"],
                            Merchant_Name_Location = o["Merchant Name/Location"],
                            Company = ol["Company"],
                            Account = ol["Account"],
                            Amount = ol["Amount"],
                            Description = o["Description"]
                        };

            foreach (var row in query)
            {
                DataRow dr = newAllocation.Tables["Allocation"].NewRow();
                dr["ChargeID"] = row.ChargeID;
                dr["Cardholder Name"] = row.Cardholder_Name;
                dr["Process Date"] = row.Process_Date;
                dr["Merchant Name/Location"] = row.Merchant_Name_Location;
                dr["Amount"] = row.Amount;
                dr["Company"] = row.Company;
                dr["Account"] = row.Account;
                dr["Description"] = row.Description;
                newAllocation.Tables["Allocation"].Rows.Add(dr);
            }

            return newAllocation;
        }
        private void LoadTypeReg(int _id_prof)
        {
            try
            {
                //Kiểm tra type của prof
                int _type = Utils.CIntDef(ddlType.SelectedValue);
                var AllList = (from g in db.TYPE_COMPANies
                               where g.TYPE_RANK > 0 && (g.TYPE_REG == null || g.TYPE_REG == _type)
                               select new
                               {
                                   g.TYPE_ID,
                                   g.TYPE_PARENT,
                                   g.TYPE_RANK,
                                   g.TYPE_NAME
                               });

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    Session["companies.listmenucha"] = DataUtil.LINQToDataTable(AllList);
                    DataTable tbl = Session["companies.listmenucha"] as DataTable;

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["TYPE_ID"] };
                    relCat = new DataRelation("TYPE_PARENT", ds.Tables[0].Columns["TYPE_ID"], ds.Tables[0].Columns["TYPE_PARENT"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    unit_data.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    HttpContext.Current.Session["companies.listmenucha"] = dsCat.Tables[0];
                    ASPxTreeList_menu.DataSource = dsCat.Tables[0];
                    ASPxTreeList_menu.DataBind();
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 12
0
        private DataSetCollection categorizeRows(string sortColumn1, string sortColumn2, string sortColumn3, DataSet dataSet)
        {
            // Create the query.
            var transaction =
                from DataRow row in dataSet.Tables["Allocation"].Rows
                orderby row[sortColumn1] ascending, row[sortColumn2] ascending, row[sortColumn3] ascending
                group row by row[sortColumn1] into newGroup
                orderby newGroup.Key
                select newGroup;

            // create a temporary dataset
            DataSetCollection dataSetArray = new DataSetCollection();

            foreach (var rowGroup in transaction)
            {
                DataSet tempDS = dataSet.Clone();
                tempDS.ExtendedProperties["user"] = rowGroup.Key.ToString();

                foreach (var row in rowGroup)
                {
                    tempDS.Tables["Allocation"].ImportRow(row);

                    foreach(DataRow sRow in dataSet.Tables["Split"].Rows)
                    {
                        //TODO: Does this actually do anything?
                        if(sRow["ChargeID"] == ((DataRow)row)["ChargeID"])
                        {
                            tempDS.Tables["Split"].ImportRow(sRow);
                        }
                    }

                }

                dataSetArray.Add(tempDS);
            }

            return dataSetArray;
        }
Esempio n. 13
0
        private DataSet createAudit(string sortColumn, DataSet dataSet)
        {
            // Create the query.
            var transaction =
                from DataRow row in dataSet.Tables["Allocation"].Rows
                orderby row[sortColumn] ascending
                select row;

            DataSet tempDS = dataSet.Clone();
            tempDS.ExtendedProperties["user"] = sortColumn;

            foreach (var row in transaction)
            {
                tempDS.Tables["Allocation"].ImportRow(row);

                foreach (DataRow sRow in dataSet.Tables["Split"].Rows)
                {
                    //TODO: Does this actually do anything?
                    if (sRow["ChargeID"] == ((DataRow)row)["ChargeID"])
                    {
                        tempDS.Tables["Split"].ImportRow(sRow);
                    }
                }
                // try it but it needs to organize splits by company too (no split total)
            }

            return tempDS;
        }
        private void SearchResult()
        {
            try
            {
                string keyword = txtKeyword.Value;

                var AllList = (from g in DB.ESHOP_PROPERTies
                               where ("" == keyword || (g.PROP_NAME).Contains(keyword)) && g.PROP_RANK > 0
                               select new
                               {
                                   g.PROP_ID,
                                   g.PROP_PARENT_ID,
                                   g.PROP_NAME,
                                   g.PROP_RANK
                               });

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    Session["PropList"] = DataUtil.LINQToDataTable(AllList);
                    //DataTable tbl = Session["CatList"] as DataTable;
                    DataTable tbl = DataUtil.LINQToDataTable(AllList);

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["PROP_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["PROP_ID"], ds.Tables[0].Columns["PROP_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    CpanelUtils.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    GridItemList.DataSource = dsCat.Tables[0];
                    //if (CatTable.Rows.Count > GridItemList.PageSize)
                    //    GridItemList.AllowPaging = true;
                    //else
                    //    GridItemList.AllowPaging = false;
                    GridItemList.DataBind();
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 15
0
		public void DataSet_ColumnNameWithSpaces ()
		{
			DataSet ds = new DataSet ("New Data Set");

			DataTable table1 = ds.Tables.Add ("New Table 1");
			DataTable table2 = ds.Tables.Add ("New Table 2");

			table1.Columns.Add ("col 1" , typeof (int));
			table1.Columns.Add ("col 2" , typeof (int));

			table1.PrimaryKey = new DataColumn[] {ds.Tables [0].Columns [0]};

			// No exception shud be thrown
			XmlDataDocument doc = new XmlDataDocument (ds);

			// Should fail to save as there are no rows
			try {
				doc.Save (new StringWriter ());
				Fail ("#1");
			} catch (InvalidOperationException) {
			}

			table1.Rows.Add (new object[] {0});
			table1.Rows.Add (new object[] {1});
			table1.Rows.Add (new object[] {2});

			// No exception shud be thrown
			StringWriter swriter = new StringWriter ();
			doc.Save (swriter);

			StringReader sreader = new StringReader (swriter.ToString ());
			DataSet ds1 = ds.Clone ();
			XmlDataDocument doc1 = new XmlDataDocument (ds1);
			AssertEquals ("#2" , 0, ds1.Tables [0].Rows.Count);
			doc1.Load (sreader);
			AssertEquals ("#3" , 3, ds1.Tables [0].Rows.Count);
		}
        private void LoadCat()
        {
            try
            {
                var AllList = (from g in DB.ESHOP_CATEGORies
                               where g.CAT_RANK > 0
                               select new
                               {
                                   g.CAT_ID,
                                   g.CAT_PARENT_ID,
                                   g.CAT_RANK,
                                   CAT_NAME = (string.IsNullOrEmpty(g.CAT_CODE) ? g.CAT_NAME : g.CAT_NAME + "(" + g.CAT_CODE + ")")
                               });

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    Session["CatGroupList"] = DataUtil.LINQToDataTable(AllList);
                    DataTable tbl = Session["CatGroupList"] as DataTable;

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    GridItemList.DataSource = CatTable;
                    GridItemList.DataBind();
                }

                //var allCat=DB.GetTable<ESHOP_CATEGORy>();

                //GridItemList.DataSource = allCat;
                //GridItemList.DataBind();

                //Session["CatGroupList"] = allCat;
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
        private void SearchResult()
        {
            try
            {
                string keyword =CpanelUtils.ClearUnicode(txtKeyword.Value);

                var AllList = (from g in DB.ESHOP_CATEGORies
                               where ("" == keyword || (DB.fClearUnicode(g.CAT_NAME)).Contains(keyword)) && g.CAT_RANK > 0
                               select new { 
                                   g.CAT_ID,
                                   g.CAT_PARENT_ID,
                                   CAT_NAME = (string.IsNullOrEmpty(g.CAT_CODE) ? g.CAT_NAME : g.CAT_NAME + "(" + g.CAT_CODE + ")"),
                                   g.CAT_POSITION,
                                   g.CAT_LANGUAGE,
                                   g.CAT_ORDER,
                                   g.CAT_PERIOD_ORDER,
                                   g.CAT_RANK
                               });

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    //Session["CatList"] = DataUtil.LINQToDataTable(AllList);
                    //DataTable tbl = Session["CatList"] as DataTable;
                    DataTable tbl = DataUtil.LINQToDataTable(AllList);

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);
                    if (IsPostBack)
                    {
                        GridItemList.DataSource = AllList;
                        GridItemList.DataBind();
                    }
                    else
                    {
                        GridItemList.DataSource = dsCat.Tables[0];
                        GridItemList.DataBind();
                    }
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 18
0
        private void LoadMenu()
        {
            try
            {
                var AllList = DB.MENUs.Where(n => n.MENU_ACTIVE == 1);

                if (AllList.ToList().Count > 0)
                {
                    DataRelation relCat;

                    DataTable tbl = DataUtil.LINQToDataTable(AllList);

                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["MENU_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    CpanelUtils.TransformTableWithSpace2(ref CatTable, dsCat.Tables[0], relCat, null);
                    Rplistmenu.DataSource = dsCat.Tables[0];
                    Rplistmenu.DataBind();
                }


                //var allCat=DB.GetTable<ESHOP_CATEGORy>();

                //GridItemList.DataSource = allCat;
                //GridItemList.DataBind();

                //Session["CatGroupList"] = allCat;
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 取XML中的第几条记录,指定排序字段
        /// </summary>
        /// <param name="pageSize">每页显示的记录条数</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="orderbyFiled">排序字段</param>
        /// <param name="sortOrder">排序顺序 true:倒叙 false:正序</param>
        /// <returns></returns>
        public DataView GetRecord(int pageSize, int pageIndex, string orderbyFiled, bool sortOrder)
        {
            // 开始记录位置
            int sartIndex = pageSize * (pageIndex - 1);
            // 终止记录位置
            int endIndex = pageSize * pageIndex;
            // 返回结果集
            DataSet dsResult = new DataSet();
            // 临时DataSet,用来读取XML内容
            DataSet dsTemp = new DataSet();
            // 读取XML内容
            dsTemp.ReadXml(strXmlFile);

            if (endIndex > dsTemp.Tables[0].Rows.Count)
            {
                endIndex = dsTemp.Tables[0].Rows.Count;
            }

            // 克隆XML数据结构到结果集中
            dsResult = dsTemp.Clone();
            // 循环把要读取的记录添加到结果集中
            for (int i = sartIndex; i < endIndex; i++)
            {
                dsResult.Tables[0].Rows.Add(dsTemp.Tables[0].Rows[i].ItemArray);
            }

            DataView dvResult = dsResult.Tables[0].DefaultView;
            if (sortOrder)
            {
                dvResult.Sort = orderbyFiled + " desc";
            }
            else
            {
                dvResult.Sort = orderbyFiled + " asc";
            }

            return dvResult;
        }
        private void btnSearchResults_Click(object sender, System.EventArgs e)
        {
            dsResults = Session["search"] as DataSet;

            // If we can't get the previous results then we lost session
            // information (failure), or no previous results were available.
            // Default to normal search.
            if (dsResults == null)
            {
                btnSearch_Click(sender, e);
            }

            // We can't use parameters as this is a common filter
            // expression to use with the DataSet.
            StringBuilder qry = new StringBuilder();

            if (txtFirstName.Text != String.Empty)
            {
                qry.Append("FirstName LIKE '%");
                qry.Append(txtFirstName.Text).Append("%' AND ");
            }
            if (txtLastName.Text != String.Empty)
            {
                qry.Append("LastName LIKE '%");
                qry.Append(txtLastName.Text).Append("%' AND ");
            }
            if (cbPlace.SelectedItem.Value != "0")
            {
                qry.Append("PlaceID = '");
                qry.Append(cbPlace.SelectedItem.Value).Append("' AND ");
            }
            if (cbType.SelectedItem.Value != "0")
            {
                qry.Append("TypeID = '");
                qry.Append(cbType.SelectedItem.Value).Append("' AND ");
            }
            if (txtYearIn.Text != String.Empty)
            {
                qry.Append("YearIn = ");
                qry.Append(txtYearIn.Text).Append(" AND ");
            }
            if (txtYearOut.Text != String.Empty)
            {
                qry.Append("YearOut = ");
                qry.Append(txtYearOut.Text).Append(" AND ");
            }

            string filter = qry.ToString();

            if (filter.Length != 0)
            {
                // Remove trailing AND
                filter = filter.Remove(filter.Length - 4, 4);
            }

            DataRow[] rows = dsResults.Tables["User"].Select(filter);

            // Rebuild results with new filtered set of rows, maintaining
            // structure
            dsResults = dsResults.Clone();
            foreach (DataRow row in rows)
            {
                dsResults.Tables["User"].ImportRow(row);
            }

            // Place results in session state.
            Session["search"] = dsResults;

            BindFromSession();
        }
Esempio n. 21
0
        private DataSet GetCachedData(string CacheKeyName, int NoOfTopRecords, string SQLQueryOrSP, CommandType cmdType, params SqlParameter[] commandParameters)
        {
            DataSet dsCached = new DataSet();
            try
            {
                if (HttpContext.Current.Cache.Get(CacheKeyName) != null)
                {
                    dsCached = (DataSet)HttpContext.Current.Cache[CacheKeyName];
                }
                else
                {
                    Database dbObj = new SqlDatabase(this.connectionStr);
                    DbCommand command = dbObj.GetStoredProcCommand(SQLQueryOrSP);
                    if (commandParameters != null)
                    {
                        for (int index = 0; index < commandParameters.Length; index++)
                        {
                            dbObj.AddInParameter(command, commandParameters[index].ParameterName, commandParameters[index].DbType, commandParameters[index].Value);
                        }
                    }
                    dsCached = dbObj.ExecuteDataSet(command);
                    HttpContext.Current.Cache.Insert(CacheKeyName, dsCached, null, dtCacheTime, TimeSpan.Zero);
                }
                if (NoOfTopRecords > 0)
                {
                    DataSet ds = new DataSet();
                    ds = dsCached.Clone();
                    for (int j = 0; j < NoOfTopRecords; j++)
                    {
                        ds.Tables[0].Rows.Add(dsCached.Tables[0].Rows[j].ItemArray);
                    }
                    dsCached = ds;
                }
            }
            catch (SqlException ex)
            {

            }
            catch (Exception ex)
            {

            }
            return dsCached;

        }
Esempio n. 22
0
        private static void HistoryRefreshDataSetTable(DataSet ds, SqlDataAdapter adapter)
        {
            string tableName = adapter.TableMappings[0].DataSetTable;
            var srcTable = ds.Tables[tableName];
            DataTable dtTmp = srcTable.Clone();
            DataSet dsTmp = ds.Clone();

            adapter.Fill(dsTmp);
            ds.Merge(dsTmp);

            //adapter.Fill(dsTmp,tableName); //(dtTmp);
            //var x = adapter.SelectCommand.ExecuteReader();

            //srcTable.Merge(dtTmp);
        }
Esempio n. 23
0
		public void CloneCopy2 ()
		{
			DataSet ds = new DataSet ();
			ds.ReadXmlSchema ("Test/System.Data/store.xsd");
			ds.Clone ();
		}
Esempio n. 24
0
		public void CloneCopy_TestForeignKeyConstraints ()
		{
			DataTable dirTable = new DataTable("Directories");

			DataColumn dir_UID = new DataColumn("UID", typeof(int));
			dir_UID.Unique = true;
			dir_UID.AllowDBNull = false;

			dirTable.Columns.Add(dir_UID);

			// Build a simple Files table
			DataTable fileTable = new DataTable("Files");

			DataColumn file_DirID = new DataColumn("DirectoryID", typeof(int));
			file_DirID.Unique = false;
			file_DirID.AllowDBNull = false;

			fileTable.Columns.Add(file_DirID);

			// Build the DataSet
			DataSet ds = new DataSet("TestDataset");
			ds.Tables.Add(dirTable);
			ds.Tables.Add(fileTable);

			// Add a foreign key constraint
			DataColumn[] parentColumns = new DataColumn[1];
			parentColumns[0] = ds.Tables["Directories"].Columns["UID"];

			DataColumn[] childColumns = new DataColumn[1];
			childColumns[0] = ds.Tables["Files"].Columns["DirectoryID"];

			ForeignKeyConstraint fk = new ForeignKeyConstraint("FK_Test", parentColumns, childColumns);
			ds.Tables["Files"].Constraints.Add(fk);		
			ds.EnforceConstraints = true;

			Assert.AreEqual (1, ds.Tables["Directories"].Constraints.Count, "#1");
			Assert.AreEqual (1, ds.Tables["Files"].Constraints.Count, "#2");

			// check clone works fine
			DataSet cloned_ds = ds.Clone ();
			Assert.AreEqual (1, cloned_ds.Tables["Directories"].Constraints.Count, "#3");
			Assert.AreEqual (1, cloned_ds.Tables["Files"].Constraints.Count, "#4");

			ForeignKeyConstraint clonedFk =  (ForeignKeyConstraint)cloned_ds.Tables["Files"].Constraints[0];
			Assert.AreEqual ("FK_Test", clonedFk.ConstraintName, "#5");
			Assert.AreEqual (1, clonedFk.Columns.Length, "#6");
			Assert.AreEqual ("DirectoryID", clonedFk.Columns[0].ColumnName, "#7");

			UniqueConstraint clonedUc = (UniqueConstraint)cloned_ds.Tables ["Directories"].Constraints[0];
			UniqueConstraint origUc = (UniqueConstraint)ds.Tables ["Directories"].Constraints[0];
			Assert.AreEqual (origUc.ConstraintName, clonedUc.ConstraintName, "#8");
			Assert.AreEqual (1, clonedUc.Columns.Length, "#9");
			Assert.AreEqual ("UID", clonedUc.Columns[0].ColumnName, "#10");

			// check copy works fine
			DataSet copy_ds = ds.Copy ();
			Assert.AreEqual (1, copy_ds.Tables["Directories"].Constraints.Count, "#11");
			Assert.AreEqual (1, copy_ds.Tables["Files"].Constraints.Count, "#12");

			ForeignKeyConstraint copyFk =  (ForeignKeyConstraint)copy_ds.Tables["Files"].Constraints[0];
			Assert.AreEqual ("FK_Test", copyFk.ConstraintName, "#13");
			Assert.AreEqual (1, copyFk.Columns.Length, "#14");
			Assert.AreEqual ("DirectoryID", copyFk.Columns[0].ColumnName, "#15");

			UniqueConstraint copyUc = (UniqueConstraint)copy_ds.Tables ["Directories"].Constraints[0];
			origUc = (UniqueConstraint)ds.Tables ["Directories"].Constraints[0];
			Assert.AreEqual (origUc.ConstraintName, copyUc.ConstraintName, "#16");
			Assert.AreEqual (1, copyUc.Columns.Length, "#17");
			Assert.AreEqual ("UID", copyUc.Columns[0].ColumnName, "#18");
		}
Esempio n. 25
0
                public void CloneCopy ()
                {
                        DataTable table = new DataTable ("pTable");
			DataTable table1 = new DataTable ("cTable");
			DataSet set = new DataSet ();

                        set.Tables.Add (table);
                        set.Tables.Add (table1);

			DataColumn col = new DataColumn ();
                        col.ColumnName = "Id";
                        col.DataType = Type.GetType ("System.Int32");
                        table.Columns.Add (col);
                        UniqueConstraint uc = new UniqueConstraint ("UK1", table.Columns[0] );
                        table.Constraints.Add (uc);

                        col = new DataColumn ();
                        col.ColumnName = "Name";
                        col.DataType = Type.GetType ("System.String");
                        table.Columns.Add (col);

                        col = new DataColumn ();
                        col.ColumnName = "Id";
                        col.DataType = Type.GetType ("System.Int32");
                        table1.Columns.Add (col);

                        col = new DataColumn ();
                        col.ColumnName = "Name";
                        col.DataType = Type.GetType ("System.String");
		        table1.Columns.Add (col);
			  ForeignKeyConstraint fc = new ForeignKeyConstraint ("FK1", table.Columns[0], table1.Columns[0] );
                        table1.Constraints.Add (fc);


                        DataRow row = table.NewRow ();

                        row ["Id"] = 147;
                        row ["name"] = "Row1";
                        row.RowError = "Error#1";
                        table.Rows.Add (row);

			// Set column to RO as commonly used by auto-increment fields.
			// ds.Copy() has to omit the RO check when cloning DataRows 
			table.Columns["Id"].ReadOnly = true;
			
                        row = table1.NewRow ();
                        row ["Id"] = 147;
                        row ["Name"] = "Row1";
                        table1.Rows.Add (row);

                        //Setting properties of DataSet
                        set.CaseSensitive = true;
                        set.DataSetName = "My DataSet";
                        set.EnforceConstraints = false;
                        set.Namespace = "Namespace#1";
                        set.Prefix = "Prefix:1";
                        DataRelation dr = new DataRelation ("DR", table.Columns [0],table1.Columns [0]);
                        set.Relations.Add (dr);
                        set.ExtendedProperties.Add ("TimeStamp", DateTime.Now);
                        CultureInfo cultureInfo = new CultureInfo( "ar-SA" );
                        set.Locale = cultureInfo;

                        //Testing Copy ()
                        DataSet copySet = set.Copy ();
                        Assert.AreEqual (set.CaseSensitive, copySet.CaseSensitive, "#A01");
			Assert.AreEqual (set.DataSetName, copySet.DataSetName, "#A02");
                        Assert.AreEqual (set.EnforceConstraints, copySet.EnforceConstraints, "#A03");
                        Assert.AreEqual (set.HasErrors, copySet.HasErrors, "#A04");
                        Assert.AreEqual (set.Namespace, copySet.Namespace, "#A05");
                        Assert.AreEqual (set.Prefix, copySet.Prefix, "#A06");
                        Assert.AreEqual (set.Relations.Count, copySet.Relations.Count, "#A07");
                        Assert.AreEqual (set.Tables.Count, copySet.Tables.Count, "#A08");
                        Assert.AreEqual (set.ExtendedProperties ["TimeStamp"], copySet.ExtendedProperties ["TimeStamp"], "#A09");
                        for (int i = 0;i < copySet.Tables.Count; i++) {
                                Assert.AreEqual (set.Tables [i].Rows.Count, copySet.Tables [i].Rows.Count, "#A10");
                                Assert.AreEqual (set.Tables [i].Columns.Count, copySet.Tables [i].Columns.Count, "#A11");
                        }
                        //Testing Clone ()
                        copySet = set.Clone ();
                        Assert.AreEqual (set.CaseSensitive, copySet.CaseSensitive, "#A12");
                        Assert.AreEqual (set.DataSetName, copySet.DataSetName, "#A13");
                        Assert.AreEqual (set.EnforceConstraints, copySet.EnforceConstraints, "#A14");
                        Assert.IsFalse (copySet.HasErrors, "#A15");
                        Assert.AreEqual (set.Namespace, copySet.Namespace, "#A16");
                        Assert.AreEqual (set.Prefix, copySet.Prefix, "#A17");
                        Assert.AreEqual (set.Relations.Count, copySet.Relations.Count, "#A18");
                        Assert.AreEqual (set.Tables.Count, copySet.Tables.Count, "#A19");
                        Assert.AreEqual (set.ExtendedProperties ["TimeStamp"], copySet.ExtendedProperties ["TimeStamp"], "#A20");
                        for (int i = 0;i < copySet.Tables.Count; i++) {
                                Assert.AreEqual (0, copySet.Tables [i].Rows.Count, "#A21");
                                Assert.AreEqual (set.Tables [i].Columns.Count, copySet.Tables [i].Columns.Count, "#A22");
                        }
		}
Esempio n. 26
0
		[Test] public void Clone()
		{
			DataSet ds = new DataSet(), dsTarget = null;
			ds.Tables.Add(DataProvider.CreateParentDataTable());
			ds.Tables.Add(DataProvider.CreateChildDataTable());
			ds.Relations.Add(new DataRelation("myRelation",ds.Tables[0].Columns[0],ds.Tables[1].Columns[0]));
			ds.Tables[0].Rows.Add(new object[] {9,"",""});
			ds.Tables[1].Columns[2].ReadOnly = true;
			ds.Tables[0].PrimaryKey = new DataColumn[] {ds.Tables[0].Columns[0],ds.Tables[0].Columns[1]};

			//copy schema only, no data

			// Clone 1
			dsTarget = ds.Clone();
			//Assert.AreEqual(ds.GetXmlSchema(), dsTarget.GetXmlSchema() , "DS16");
			//use my function because GetXmlSchema not implemented in java
			Assert.AreEqual(DataProvider.GetDSSchema(ds), DataProvider.GetDSSchema(dsTarget), "DS17");

			// Clone 2
			Assert.AreEqual(false, dsTarget.GetXml() == ds.GetXml(), "DS18");
		}
        private void LoadTypeParent()
        {
            try
            {
                var CatList = (
                                from t2 in db.TYPE_COMPANies
                                select new
                                {
                                    TYPE_ID = t2.TYPE_NAME == "-------Root-------" ? 0 : t2.TYPE_ID,
                                    TYPE_PARENT = t2.TYPE_PARENT,
                                    TYPE_RANK = t2.TYPE_RANK,
                                    TYPE_NAME = t2.TYPE_NAME
                                }
                            );

                if (CatList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    DataTable tbl = DataUtil.LINQToDataTable(CatList);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["TYPE_ID"] };
                    relCat = new DataRelation("TYPE_PARENT", ds.Tables[0].Columns["TYPE_ID"], ds.Tables[0].Columns["TYPE_PARENT"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    unit_data.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    Drmenu_parent.DataSource = dsCat.Tables[0];
                    Drmenu_parent.DataTextField = "TYPE_NAME";
                    Drmenu_parent.DataValueField = "TYPE_ID";
                    Drmenu_parent.DataBind();

                }
                else
                {
                    DataTable dt = new DataTable("Newtable");

                    dt.Columns.Add(new DataColumn("TYPE_ID"));
                    dt.Columns.Add(new DataColumn("TYPE_NAME"));

                    DataRow row = dt.NewRow();
                    row["TYPE_ID"] = 0;
                    row["TYPE_NAME"] = "-------Root-------";
                    dt.Rows.Add(row);

                    Drmenu_parent.DataTextField = "TYPE_NAME";
                    Drmenu_parent.DataValueField = "TYPE_ID";
                    Drmenu_parent.DataSource = dt;
                    Drmenu_parent.DataBind();



                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 28
0
        public void RefreshView(bool initialize)
        {
            try
            {
                if (currentConnection == null)
                {
                    return;
                }

                if (!currentConnection.Connected)
                {
                    return;
                }

                RefreshTimer.Enabled = false;
                String  s  = currentConnection.Ps();
                DataSet ds = JobRuntimeDS.Clone();
                ds.Clear();
                ds.ReadXml(new StringReader(s), XmlReadMode.Auto);

                JobGrid.SuspendLayout();

                if (initialize)
                {
                    JobRuntimeDS.Clear();
                }

                JobRuntimeDS.Merge(ds.Tables["JobRuntimeType"]);

                ServerConfigRefreshRate r = UIConfigFileHandler.Instance().Config.RefreshRate;

                switch (r)
                {
                case ServerConfigRefreshRate.High:
                    RefreshTimer.Interval = 1000;
                    RefreshTimer.Enabled  = true;
                    break;

                case ServerConfigRefreshRate.Low:
                    RefreshTimer.Interval = 30000;
                    RefreshTimer.Enabled  = true;
                    break;

                case ServerConfigRefreshRate.Normal:
                    RefreshTimer.Interval = 10000;
                    RefreshTimer.Enabled  = true;
                    break;

                case ServerConfigRefreshRate.Paused:
                    RefreshTimer.Enabled = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                currentConnection.Disconnect();
                MessageBox.Show(ex.Message);
            }
            finally
            {
                JobGrid.ResumeLayout(true);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 取XML中的第几条记录
        /// </summary>
        /// <param name="pageSize">每页显示的记录条数</param>
        /// <param name="pageIndex">页索引</param>
        /// <returns></returns>
        public DataSet GetRecord(int pageSize, int pageIndex)
        {
            // 开始记录位置
            int sartIndex = pageSize * (pageIndex - 1);
            // 终止记录位置
            int endIndex = pageSize * pageIndex;
            // 返回结果集
            DataSet dsResult = new DataSet();
            // 临时DataSet,用来读取XML内容
            DataSet dsTemp = new DataSet();
            // 读取XML内容
            dsTemp.ReadXml(strXmlFile);

            if (endIndex > dsTemp.Tables[0].Rows.Count)
            {
                endIndex = dsTemp.Tables[0].Rows.Count;
            }

            if (dsTemp.Tables.Count > 0)
            {
                if (dsTemp.Tables[0].Rows.Count > 0)
                {
                    // 克隆XML数据结构到结果集中
                    dsResult = dsTemp.Clone();
                    // 循环把要读取的记录添加到结果集中
                    for (int i = sartIndex; i < endIndex; i++)
                    {
                        dsResult.Tables[0].Rows.Add(dsTemp.Tables[0].Rows[i].ItemArray);
                    }
                }
            }

            return dsResult;
        }
Esempio n. 30
0
		public void Rows_With_Null_Values ()
		{
			DataSet ds = new DataSet ();
			DataTable table = ds.Tables.Add ("table1");
			table.Columns.Add ("col1", typeof (int));
			table.Columns.Add ("col2", typeof (int));

			XmlDataDocument doc = new XmlDataDocument (ds);
			table.Rows.Add (new object[] {1});

			StringWriter sw = new StringWriter ();
			doc.Save (sw);

			DataSet ds1 = ds.Clone ();
			XmlDataDocument doc1 = new XmlDataDocument (ds1);
			StringReader sr = new StringReader (sw.ToString());
			doc1.Load (sr);

			AssertEquals ("#1", 1, ds1.Tables [0].Rows [0][0]);
			AssertEquals ("#2", true, ds1.Tables [0].Rows [0].IsNull (1));
		}
Esempio n. 31
0
        private void LoadCategoryParent()
        {
            try
            {
                var CatList = (
                                from t2 in DB.ESHOP_PROPERTies
                                select new
                                {
                                    PROP_ID = t2.PROP_NAME == "------- Root -------" ? 0 : t2.PROP_ID,
                                    PROP_NAME = t2.PROP_NAME,
                                    PROP_PARENT_ID = t2.PROP_PARENT_ID,
                                    PROP_RANK = t2.PROP_RANK

                                }
                            );

                if (CatList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    DataTable tbl = DataUtil.LINQToDataTable(CatList);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["PROP_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["PROP_ID"], ds.Tables[0].Columns["PROP_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    CpanelUtils.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                    ddlCategory.DataSource = dsCat.Tables[0];
                    ddlCategory.DataTextField = "PROP_NAME";
                    ddlCategory.DataValueField = "PROP_ID";
                    ddlCategory.DataBind();

                }
                else
                {
                    DataTable dt = new DataTable("Newtable");

                    dt.Columns.Add(new DataColumn("PROP_ID"));
                    dt.Columns.Add(new DataColumn("PROP_NAME"));

                    DataRow row = dt.NewRow();
                    row["ARE_ID"] = 0;
                    row["ARE_NAME"] = "--------Root--------";
                    dt.Rows.Add(row);

                    ddlCategory.DataTextField = "PROP_NAME";
                    ddlCategory.DataValueField = "PROP_ID";
                    ddlCategory.DataSource = dt;
                    ddlCategory.DataBind();



                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 32
0
        private void btnSearchFurther_Click(object sender, System.EventArgs e)
        {
            dsResults = Session["search"] as DataSet;

            //return a normal search if the session doesn't exist anymore
            if( dsResults == null ) btnSearch_Click( sender, e );

            //here this is a filter not an sql query so no parameters :<
            //similar to the regular search, though
            StringBuilder qry = new StringBuilder();
            if( txtOrderNumber.Text != String.Empty )
            {
                qry.Append( "orderNumber = " );
                qry.Append( txtOrderNumber.Text ).Append( " AND " );
            }
            if( txtSalesRepUName.Text != String.Empty )
            {
                qry.Append( "UID1 LIKE '%" );
                qry.Append( txtSalesRepUName.Text ).Append( "%' AND " );
            }
            if( txtSalesRepName.Text != String.Empty )
            {
                qry.Append( "employeename LIKE '%" );
                qry.Append( txtSalesRepName.Text ).Append( "%' AND " );
            }

            string filter = qry.ToString();
            if( filter.Length != 0 )
            {
                filter = filter.Remove( filter.Length - 4, 4 );
            }

            DataRow[] rows = dsResults.Tables["Order"].Select( filter );

            //get the results back
            dsResults = dsResults.Clone();
            foreach( DataRow row in rows )
            {
                dsResults.Tables["Order"].ImportRow( row );
            }

            //put the results in the session
            Session["search"] = dsResults;

            BindFromSession();
        }
        private void LoadCategoryParent()
        {
            try
            {
                var CatList = (
                                from t2 in DB.ESHOP_CATEGORies
                                where t2.CAT_RANK > 0
                                   && (_type == 0 ? (t2.CAT_TYPE != 1) : t2.CAT_TYPE == 1)
                                  && (_gtype != 1 ? (getCatid().Contains(t2.CAT_ID.ToString()) || getCatid().Contains(t2.CAT_PARENT_ID.ToString())) : true)
                                select new
                                {
                                    CAT_ID = t2.CAT_NAME == "------- Root -------" ? 0 : t2.CAT_ID,
                                    CAT_NAME = (string.IsNullOrEmpty(t2.CAT_CODE) ? t2.CAT_NAME : t2.CAT_NAME + "(" + t2.CAT_CODE + ")"),
                                    CAT_NAME_EN = (string.IsNullOrEmpty(t2.CAT_CODE_EN) ? t2.CAT_NAME_EN : t2.CAT_NAME_EN + "(" + t2.CAT_CODE_EN + ")"),
                                    CAT_PARENT_ID = t2.CAT_PARENT_ID,
                                    CAT_RANK = t2.CAT_RANK
                                }
                            );

                if (CatList.ToList().Count > 0)
                {
                    DataRelation relCat;
                    DataTable tbl = DataUtil.LINQToDataTable(CatList);
                    DataSet ds = new DataSet();
                    ds.Tables.Add(tbl);

                    tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                    relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                    ds.Relations.Add(relCat);
                    DataSet dsCat = ds.Clone();
                    DataTable CatTable = ds.Tables[0];

                    DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);
                    if (CatList.ToList()[0].CAT_RANK > 1)
                        ddlCategory.DataSource = CatList;
                    else
                        ddlCategory.DataSource = dsCat.Tables[0];
                    ddlCategory.DataTextField = "CAT_NAME";
                    ddlCategory.DataValueField = "CAT_ID";
                    ddlCategory.DataBind();

                }
                else
                {
                    DataTable dt = new DataTable("Newtable");

                    dt.Columns.Add(new DataColumn("CAT_ID"));
                    dt.Columns.Add(new DataColumn("CAT_NAME"));
                    dt.Columns.Add(new DataColumn("CAT_NAME_EN"));

                    DataRow row = dt.NewRow();
                    row["CAT_ID"] = 0;
                    row["CAT_NAME"] = "--------Root--------";
                    row["CAT_NAME_EN"] = "--------Root--------";
                    dt.Rows.Add(row);

                    ddlCategory.DataTextField = "CAT_NAME";
                    ddlCategory.DataValueField = "CAT_ID";
                    ddlCategory.DataSource = dt;
                    ddlCategory.DataBind();
                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Esempio n. 34
0
		public void CopyClone_RelationWithoutConstraints ()
		{
			DataSet ds = new DataSet ();

			DataTable table1 = ds.Tables.Add ("table1");
			DataTable table2 = ds.Tables.Add ("table2");

			DataColumn pcol = table1.Columns.Add ("col1", typeof (int));
			DataColumn ccol = table2.Columns.Add ("col1", typeof (int));

			DataRelation rel = ds.Relations.Add ("rel1", pcol, ccol, false);

			DataSet ds1 = ds.Copy ();
			DataSet ds2 = ds.Clone ();
			
			Assert.AreEqual (1, ds1.Relations.Count, "#1");
			Assert.AreEqual (1, ds2.Relations.Count, "#2");

			Assert.AreEqual (0, ds1.Tables [0].Constraints.Count, "#3");
			Assert.AreEqual (0, ds1.Tables [1].Constraints.Count, "#4");

			Assert.AreEqual (0, ds2.Tables [0].Constraints.Count, "#5");
			Assert.AreEqual (0, ds2.Tables [1].Constraints.Count, "#6");
		}