Пример #1
0
    /// <summary>
    /// 根据父级ID创建对应子级菜单
    /// </summary>
    /// <param name="menuId"></param>
    protected void rptSecond_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //model = e.Item.DataItem as Tz888.Model.Sys.SysMenuTab;
        string sid = "";

        if (ListItemType.Item == e.Item.ItemType || ListItemType.AlternatingItem == e.Item.ItemType)
        {
            // 读当前行数据
            DataRowView dr = (DataRowView)e.Item.DataItem;

            sid = dr["sid"].ToString();
        }
        Repeater childRep = e.Item.FindControl("rptThird") as Repeater;
        //childRep.DataSource = bll.GetList(model.sid, "desc");
        DataSet ds1 = new DataSet();

        ds1 = GetDataList();
        DataRow[] dr1 = ds1.Tables[0].Select("SParentCode=" + sid);
        DataSet   ds2 = new DataSet();

        ds2 = ds1.Clone();
        ds2.Merge(dr1);
        childRep.DataSource = ds2;
        childRep.DataBind();
        ds2.Dispose();
        ds2 = null;
        ds1.Dispose();
        ds1 = null;
    }
Пример #2
0
        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);
        }
Пример #3
0
        private void btExcel_Click(object sender, EventArgs e)
        {
            DataSet ds    = ads.Clone();
            string  sText = txtTim.Text.Trim().Replace("'", "''");
            string  aft   = "hoten like '%" + sText + "%' or mabn like '%" + sText + "%' or soluutru like '%" + sText + "%'";

            ds.Merge(ads.Tables[0].Select(aft));
            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    ds.Tables[0].Columns.Remove("dienthoai");
                    exp_excel(false, ds);
                }
            }
        }
        /// <summary>
        ///Return dataset containing data for the page number which will be passed as argument
        /// </summary>
        /// <param name="dataSet">Pass filled data set to convert in pages</param>
        /// <param name="PerPage">Rows per page</param>
        /// <param name="PageNo">Page Number you want to get</param>
        /// <returns>Dataset containing data for the page number which will be passed as argument</returns>
        /// <exception cref="IncorrectPageNoException"></exception>
        ///  <exception cref="EmptyDataSetException"></exception>
        public DataSet GetPage(DataSet dataSet, int PerPage, int?PageNo)
        {
            if (PageNo.HasValue && PageNo.Value > 0)
            {
                int limit = PageNo.Value * PerPage;

                int Start = (limit - PerPage);
                //eg 12/2=6 this tells that 12rows can take 6 pages if you set 2 rows per page so if we multiply 2 by 6 then its 12 again ceiling function is for odd number of rows so that we get nearest greater integer for pages.
                TotalPages = Math.Ceiling((double)dataSet.Tables[0].Rows.Count / PerPage);
                System.Data.DataSet ds1 = new System.Data.DataSet();
                ds1 = dataSet.Clone();


                for (int i = Start; i < limit; i++)
                {
                    try
                    {
                        ds1.Tables[0].ImportRow(dataSet.Tables[0].Rows[i]);
                    }
                    catch (IndexOutOfRangeException) { }
                }
                return(ds1);
            }
            else
            {
                throw new IncorrectPageNoException();
            }
        }
Пример #5
0
        private void txtCodClassMerc_Leave(object sender, EventArgs e)
        {
            if (txtCodClassMerc.Text.Trim() == "")
            {
                txtCodClassMerc.Text  = "";
                txtDescClassMerc.Text = "";
                return;
            }
            string filter = QHS.CmpEq("active", "S");

            string Code = txtCodClassMerc.Text;

            if (!Code.EndsWith("%"))
            {
                Code += "%";
            }
            if (!Code.StartsWith("%"))
            {
                Code = "%" + Code;
            }
            filter = QHS.AppAnd(filter, QHS.Like("codelistclass", Code), QHS.CmpEq("ayear", Conn.GetSys("esercizio")));

            MetaData E = Disp.Get("listclass");

            E.FilterLocked = true;
            E.DS           = D.Clone();
            Selected       = E.SelectOne("default", filter, "listclass", null);

            riempiTextBox(Selected);
        }
Пример #6
0
        // Sort the tables (messages) by the Modified Time
        public static DataSet dsSort(DataSet ds, String strSortBy)
        {
            DataSet dsSorted = ds.Clone(); // copy the existing table

            dsSorted.Tables.Clear();       // clear out the values

            // make a new table and put two columns in it for sorting
            DataTable dtSort = new DataTable();

            dtSort.Columns.Add(strSortBy, Type.GetType("System.DateTime"));
            dtSort.Columns.Add("Index", Type.GetType("System.Int32"));

            for (int i = 0; i < ds.Tables.Count; i++)
            {
                dtSort.Rows.Add((DateTime)ds.Tables[i].ExtendedProperties[strSortBy], i);
            }

            dtSort.DefaultView.Sort = strSortBy;

            // Then copy the tables (messages) into the new data set sorted by modified time
            foreach (DataRow drSort in dtSort.DefaultView.ToTable().Rows)
            {
                DataTable dt = ds.Tables[(int)drSort["Index"]];
                dsSorted.Tables.Add(dt.Copy());
            }

            return(dsSorted);
        }
Пример #7
0
        private void txtAnagrafica_Leave(object sender, EventArgs e)
        {
            if (txtAnagrafica.Text.Trim() == "")
            {
                txtAnagrafica.Text = "";
                return;
            }
            DataSet D;

            D = new DataSet();
            string filter = QHS.CmpEq("active", "S");

            string Testo = txtAnagrafica.Text;

            if (!Testo.EndsWith("%"))
            {
                Testo += "%";
            }
            //if (!Testo.StartsWith("%")) Testo = "%" + Testo;
            filter = QHS.AppAnd(filter, QHS.Like("title", Testo));
            MetaData E = Meta.Dispatcher.Get("registrymainview");

            E.FilterLocked = true;
            E.DS           = D.Clone();

            riempiTextBox(E.SelectOne("default", filter, "registrymainview", null));
        }
Пример #8
0
        public void CloneVSCopy(int noOfTables, int rowsPerTable)
        {
            DataSet original   = GetDataSet(noOfTables, rowsPerTable);
            var     watchClone = global::System.Diagnostics.Stopwatch.StartNew();
            DataSet clone      = original.Clone();

            watchClone.Stop();
            var     watchCopy = global::System.Diagnostics.Stopwatch.StartNew();
            DataSet copy      = original.Copy();

            watchCopy.Stop();

            var logString = $"Times (ms) Clone: {watchClone.ElapsedMilliseconds.ToString()} Copy: {watchCopy.ElapsedMilliseconds.ToString()}";

            Console.WriteLine(logString);
            global::System.Diagnostics.Trace.WriteLine(logString);

            //Both clone and copy has the tables
            Assert.That(clone.Tables.Count, Is.EqualTo(original.Tables.Count));
            Assert.That(copy.Tables.Count, Is.EqualTo(original.Tables.Count));

            //The clone has no rows - the copy has
            for (int i = 0; i < noOfTables; i++)
            {
                Assert.That(clone.Tables[i].Rows.Count, Is.EqualTo(0));
                Assert.That(copy.Tables[i].Rows.Count, Is.EqualTo(original.Tables[i].Rows.Count));
            }
        }
Пример #9
0
        public void run()
        {
            Exception exp = null;

            DataSet ds = new DataSet(), dsTarget = null;

            ds.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
            ds.Tables.Add(GHTUtils.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

            try
            {
                BeginCase("Clone 1");
                dsTarget = ds.Clone();
                //Compare(dsTarget.GetXmlSchema() ,ds.GetXmlSchema());
                //use my function because GetXmlSchema not implemented in java
                Compare(DataProvider.GetDSSchema(dsTarget), DataProvider.GetDSSchema(ds));
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }

            try
            {
                BeginCase("Clone 2");
                Compare(dsTarget.GetXml() == ds.GetXml(), false);
            }
            catch (Exception ex)     { exp = ex; }
            finally { EndCase(exp); exp = null; }
        }
Пример #10
0
        public DataSet GetProductSequenceByDefault(int pintProductionLineID)
        {
            PRO_DCOptionMasterDS dsMaster = new PRO_DCOptionMasterDS();
            DataSet dstData = dsMaster.GetProductSequenceByDefault(pintProductionLineID);
            DataSet dstNew  = dstData.Clone();

            dstNew.Tables[0].Columns.Add(new DataColumn("ProductProductionOrderID", typeof(int)));
            dstNew.Tables[0].Columns["ProductProductionOrderID"].AutoIncrement     = true;
            dstNew.Tables[0].Columns["ProductProductionOrderID"].AutoIncrementSeed = 1;
            dstNew.Tables[0].Columns["ProductProductionOrderID"].AutoIncrementStep = 1;
            int intSequence = 1;

            foreach (DataRow drowData in dstData.Tables[0].Rows)
            {
                DataRow drowNew = dstNew.Tables[0].NewRow();
                foreach (DataColumn dcolData in dstData.Tables[0].Columns)
                {
                    drowNew[dcolData.ColumnName] = drowData[dcolData.ColumnName];
                }
                drowNew["Seq"] = intSequence;
                dstNew.Tables[0].Rows.Add(drowNew);
                intSequence++;
            }
            return(dstData);
        }
Пример #11
0
        private void btn_FetchData_Click(object sender, EventArgs e)
        {
            dsRecords = null;
            btnDataTransfer.Enabled = false;
            try {
                if (FillDestinationDbInfo() == true)
                {
                    if (FillMappingFields() == true)
                    {
                        DG1.DataSource = null;

                        dsRecords = new DataSet();

                        DataSet     dsdata = new DataSet();
                        ClassSqlLit obj    = new ClassSqlLit();
                        dsdata = obj.FillData(varSourceTableName);

                        dsRecords = dsdata.Clone();


                        ReconcileData(dsdata);
                        lblStatus.Text          = "Fetched Successfully - " + dsRecords.Tables[0].Rows.Count.ToString() + " Records to tansfer.";
                        btnDataTransfer.Enabled = true;
                        DG1.DataSource          = dsRecords.Tables[0];
                    }
                }
            }
            catch (Exception ex)
            {
                WriteErrorLog(spath, ex.Message + "   " + ex.ToString());
                MessageBox.Show(ex.Message.ToString(), "btn_FetchData_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #12
0
    // <Snippet1>
    private void GetClone(DataSet dataSet)
    {
        // Get a clone of the original DataSet.
        DataSet cloneSet = dataSet.Clone();

        // Insert code to work with clone of the DataSet.
    }
Пример #13
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));
        }
Пример #14
0
        static void Main(string[] args)
        {
            /*创建DataSet对象*/
            DataSet myds = new DataSet("chsharp51zxw");

            /*创建DataTable对象*/
            DataTable mydt = new DataTable("mytable002");

            /*将DataTable对象加入DataSet对象*/
            myds.Tables.Add(mydt);

            /*定义列,并向DataTable中增加已经定义好的列*/
            DataColumn mydcoll1 = new DataColumn("id", Type.GetType("System.Int32"));
            DataColumn mydcoll2 = new DataColumn("name", Type.GetType("System.String"));
            DataColumn mydcoll3 = new DataColumn("department", Type.GetType("System.String"));

            mydt.Columns.Add(mydcoll1);
            mydt.Columns.Add(mydcoll2);
            mydt.Columns.Add(mydcoll3);

            /*插入行数据*/
            string[,] mystr = { { "张三", "研发部" }, { "李四", "研发部" }, { "王五", "研发部" }, { "赵六", "研发部" } };

            for (int i = 0; i < mystr.Length / 2; i++)
            {
                DataRow myrow = mydt.NewRow();
                myrow["id"] = i;
                myrow[1]    = mystr[i, 0];
                myrow[2]    = mystr[i, 1];
                mydt.Rows.Add(myrow);
            }
            myds.AcceptChanges();   //保存提交

            Console.WriteLine("更改前的数据");
            outValues(myds);


            DataTable mydt002 = mydt.Clone();   //复制表结构但不复制数据 可与Merge搭配使用
            DataRow   mydrow  = mydt002.NewRow();

            mydt002.Rows.Add(new object[] { 4, "王小二", "测试部" });
            mydt002.Rows.Add(new object[] { 5, "张小四", "技术部" });

            myds.Merge(mydt002);    //将mydt002及其架构合并到myds中
            Console.WriteLine("\n合并后的数据集");
            outValues(myds);

            DataSet myds001 = myds.Copy();
            DataSet myds002 = myds.Clone();

            Console.WriteLine("copy结果: ");
            outValues(myds001);

            Console.WriteLine("clone结果");
            outValues(myds002);



            Console.ReadKey();
        }
Пример #15
0
        private void LoadCategoryParent()
        {
            try
            {
                var CatList = (
                    from t2 in DB.ESHOP_CATEGORies
                    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_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();
                }
                else
                {
                    DataTable dt = new DataTable("Newtable");

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

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

                    ddlCategory.DataTextField  = "CAT_NAME";
                    ddlCategory.DataValueField = "CAT_ID";
                    ddlCategory.DataSource     = dt;
                    ddlCategory.DataBind();
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Пример #16
0
        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);
            }
        }
Пример #17
0
        private void butin_Click(object sender, EventArgs e)
        {
            DataSet dsxml = new DataSet();

            dsxml = ds.Clone();
            int i = 0;

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                dsxml.Clear();
                if (dataGridView1["In", i].Value.ToString() == "1" || dataGridView1["In", i].Value.ToString() == "True")
                {
                    if (dataGridView1["cungtuyen", i].Value.ToString() == "1" || dataGridView1["cungtuyen", i].Value.ToString() == "True")//cung tuyen
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow r1 in ds.Tables[0].Select("mabn='" + dataGridView1["mabn", i].Value.ToString() + "'"))
                            {
                                dsxml.Tables[0].Rows.Add(r1.ItemArray);
                            }
                            dllReportM.frmReport f = new dllReportM.frmReport(m, dsxml, "GIẤY CHUYỂN VIỆN", "rptGiaycv.rpt", true);
                            f.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show(lan.Change_language_MessageText("Không có số liệu !"), LibMedi.AccessData.Msg);
                            //return;
                        }
                    }
                    else //khong cung tuyen
                    {
                        try
                        {
                            DataSet ds_duyet = m.get_data("select daduyet from " + user + ".chuyenvien where maql=" + l_maql + "");
                            if (ds_duyet.Tables[0].Rows[0]["daduyet"].ToString() == "1")
                            {
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    foreach (DataRow r2 in ds.Tables[0].Select("mabn='" + dataGridView1["mabn", i].Value.ToString() + "'"))
                                    {
                                        dsxml.Tables[0].Rows.Add(r2.ItemArray);
                                    }
                                    dllReportM.frmReport f = new dllReportM.frmReport(m, dsxml, "GIẤY CHUYỂN VIỆN", "rptGiaycv.rpt", true);
                                    f.ShowDialog();
                                }
                            }
                            else
                            {
                                MessageBox.Show(lan.Change_language_MessageText("Bệnh nhân chưa được duyệt chuyển viện !"), LibMedi.AccessData.Msg);
                                //return;
                            }
                        }
                        catch { }
                    }
                }
                dataGridView1["In", i].Value = 0;
                i++;
            }
        }
Пример #18
0
        private DataSet ReadScheme(DTO.LIST_QD_SCHEMAInfo inf)
        {
            DataSet ds = _data.Clone();

            if (inf.FIELD_TEXT == "")
            {
                StringReader strR = new StringReader(inf.FROM_TEXT);
                try
                {
                    ds.ReadXml(strR);
                }
                catch (Exception ex)
                {
                    if (MessageBox.Show("Schema structure is erro!\n Do you want to delete it?", "Message", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        btnDelete_Click(null, null);
                    }
                }
                strR.Close();
                return(ds);
            }
            else
            {
                XmlDocument xml     = new XmlDocument();
                string      content = inf.FROM_TEXT;
                if (content.Length > 0 && content[0] != '<')
                {
                    content = Form_QD.Base64ToString(content);
                }
                string strxml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><SUN_SCHEMA>{0}</SUN_SCHEMA>", content);
                xml.LoadXml(strxml);
                XmlElement doc    = xml.DocumentElement;
                DataTable  dtfrom = ds.Tables["fromcode"];
                foreach (XmlElement ele in doc.ChildNodes)
                {
                    DataRow newRow = dtfrom.NewRow();
                    newRow["fromcode"] = ele.GetAttribute("fromcode");
                    newRow["lookup"]   = ele.GetAttribute("lookup");

                    dtfrom.Rows.Add(newRow);
                }
                xml.LoadXml(inf.FIELD_TEXT);
                doc = xml.DocumentElement;
                DataTable dtfield = ds.Tables["_TableName"];
                foreach (XmlElement ele in doc.ChildNodes)
                {
                    DataRow newRow = dtfield.NewRow();
                    newRow["node"]     = ele.GetAttribute("node");
                    newRow["name"]     = ele.GetAttribute("name");
                    newRow["table"]    = ele.GetAttribute("table");
                    newRow["nodeDesc"] = ele.GetAttribute("nodeDesc");
                    newRow["type"]     = ele.GetAttribute("type");
                    dtfield.Rows.Add(newRow);
                }

                return(ds);
            }
        }
Пример #19
0
        public JsonResult GetRegionTypes()
        {
            DAL_Reports_CategoryWiseDrVisitAnalysis objDAL = new DAL_Reports_CategoryWiseDrVisitAnalysis();

            DataControl.CurrentInfo _objcurrentInfo = new DataControl.CurrentInfo();

            string companyCode = _objcurrentInfo.GetCompanyCode();

            dsRegionType = objDAL.GetRegionTypes(companyCode);

            DataRow[] rowFilter;

            rowFilter = dsRegionType.Tables[0].Select("Region_Type_Code = Under_Region_Type");

            if (rowFilter.Length > 0)
            {
                foreach (DataRow dr in rowFilter)
                {
                    regionTypeLevelNo = 1;

                    dr["Level_No"] = regionTypeLevelNo.ToString();

                    dsRegionType.Tables[0].AcceptChanges();
                }

                foreach (DataRow dr in rowFilter)
                {
                    GenerateRegionTypeLevel(dr["Region_Type_Code"].ToString());
                }
            }

            DataSet ds             = new DataSet();
            string  regionCode     = string.Empty;
            string  regionTypeCode = string.Empty;

            regionCode     = _objcurrentInfo.GetRegionCode();
            regionTypeCode = objDAL.GetRegionTypeCode(companyCode, regionCode);

            ds = dsRegionType.Clone();

            rowFilter = dsRegionType.Tables[0].Select("Region_Type_Code = '" + regionTypeCode + "'");

            if (rowFilter.Length > 0)
            {
                regionTypeLevelNo = Convert.ToInt16(rowFilter[0]["Level_No"].ToString());

                rowFilter = dsRegionType.Tables[0].Select("Level_No >= '" + regionTypeLevelNo + "'");

                foreach (DataRow dr in rowFilter)
                {
                    ds.Tables[0].ImportRow(dr);
                    ds.Tables[0].AcceptChanges();
                }
            }

            DataControl.JSONConverter json = new DataControl.JSONConverter();
            return(Json(json.Serialize(ds), JsonRequestBehavior.AllowGet));
        }
Пример #20
0
        private void LoadCategoryParent()
        {
            try
            {
                var CatList = (
                    from t2 in DB.VOTEs
                    select t2

                    );

                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["VOTE_OID"] };
                    relCat         = new DataRelation("Category_parent", ds.Tables[0].Columns["VOTE_OID"], ds.Tables[0].Columns["VOTE_PARENT_ID"], false);

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

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

                    ddlCategory.DataSource     = dsCat.Tables[0];
                    ddlCategory.DataTextField  = "VOTE_QUESTION";
                    ddlCategory.DataValueField = "VOTE_OID";
                    ddlCategory.DataBind();
                    ListItem l = new ListItem("---- Root ----", "0", true);
                    l.Selected = true;
                    ddlCategory.Items.Insert(0, l);
                }
                else
                {
                    DataTable dt = new DataTable("Newtable");

                    dt.Columns.Add(new DataColumn("VOTE_OID"));
                    dt.Columns.Add(new DataColumn("VOTE_QUESTION"));

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

                    ddlCategory.DataTextField  = "VOTE_QUESTION";
                    ddlCategory.DataValueField = "VOTE_OID";
                    ddlCategory.DataSource     = dt;
                    ddlCategory.DataBind();
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Пример #21
0
        private void SearchResult()
        {
            try
            {
                //string keyword = CpanelUtils.ClearUnicode(txtKeyword.Value);
                int lang    = Utils.CIntDef(ddlLang.SelectedValue);
                var AllList = (from g in DB.ESHOP_CATEGORies
                               where
                               (g.CAT_LANGUAGE == lang || lang == -1) &&
                               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)
                    //{
                    //    rptList.DataSource = AllList;
                    //    rptList.DataBind();
                    //}
                    //else
                    //{
                    rptList.DataSource = dsCat.Tables[0];
                    rptList.DataBind();
                    //}
                }
            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
        }
Пример #22
0
        /// <summary>
        /// 获取顶级作品类型
        /// </summary>
        /// <returns></returns>
        public static DataSet GetWorksTypeTopLevel()
        {
            DataSet ds = DAL.Works.GetWorksType();

            DataRow[] drs   = ds.Tables[0].Select("ParentID=0");
            DataSet   dsTmp = ds.Clone();

            dsTmp.Merge(drs);
            return(dsTmp);
        }
Пример #23
0
        /// <summary>
        /// 获取团队成员
        /// </summary>
        /// <param name="worksID"></param>
        /// <returns></returns>
        public static DataSet GetGroupMemberByWorksID(long worksID)
        {
            DataSet ds = DAL.User.GetUserByWorksID(worksID);

            DataRow[] drs   = ds.Tables[0].Select("Relationship=2");
            DataSet   dsTmp = ds.Clone();

            dsTmp.Merge(drs);
            return(dsTmp);
        }
Пример #24
0
 private void butchon_Click(object sender, EventArgs e)
 {
     tmp = ds.Clone();
     foreach (DataRow r in ds.Tables[0].Select("chon=true"))
     {
         tmp.Tables[0].Rows.Add(r.ItemArray);
     }
     tmp.AcceptChanges();
     this.Close();
 }
Пример #25
0
        private void btnSpesa_Click(object sender, EventArgs e)
        {
            string filter    = "";
            string filterreg = QHS.DoPar(QHS.AppOr(QHS.IsNull("idreg"), QHS.CmpEq("idreg", idpettycashreg)));

            int selectedfase = CfgFn.GetNoNullInt32(cmbFaseSpesa.SelectedValue);

            if (selectedfase > 0)
            {
                filter = QHS.AppAnd(filter, filterreg, QHS.CmpEq("nphase", selectedfase));
            }
            else
            {
                filter = QHS.AppAnd(filter, QHS.AppAnd(filterreg,
                                                       QHS.CmpNe("nphase", Conn.GetSys("maxexpensephase")),
                                                       QHS.CmpGe("nphase", Conn.GetSys("expensefinphase"))));
            }
            int     ymov             = CfgFn.GetNoNullInt32(txtEserc.Text.Trim());
            int     nmov             = CfgFn.GetNoNullInt32(txtNum.Text.Trim());
            decimal importoForFilter = CfgFn.GetNoNullDecimal(HelpForm.GetObjectFromString(typeof(Decimal), txtImporto.Text, "x.y.c"));

            if (importoForFilter == 0)
            {
                importoForFilter = importoRimasto;
            }

            if (importoForFilter > 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpGe("available", importoForFilter));
            }
            if (ymov != 0)
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("ymov", ymov));
            }

            if ((ymov != 0) && (nmov != 0))
            {
                filter = QHS.AppAnd(filter, QHS.CmpEq("nmov", nmov));
            }

            MetaData E = Disp.Get("expense");

            E.FilterLocked = true;
            E.DS           = D.Clone();
            DataRow Choosen = E.SelectOne("default", filter, "expense", null);

            if (Choosen == null)
            {
                return;
            }
            idexp         = Choosen["idexp"];
            txtEserc.Text = Choosen["ymov"].ToString();
            txtNum.Text   = Choosen["nmov"].ToString();
            cmbFaseSpesa.SelectedValue = Choosen["nphase"];
        }
Пример #26
0
    private void BindSchedule()
    {
        _iPrjRefID = WebUtility.GetIntByValueDropDownList(ddlPrjName);

        Biz_Prj_Schedule objSchedule = new Biz_Prj_Schedule();

        objSchedule.IPrj_Ref_Id = IPrjRefID;
        DataSet ds = objSchedule.GetUserAllList(objSchedule.IPrj_Ref_Id, 0, gUserInfo.Emp_Ref_ID);


        if (ds.Tables.Count == 0 && ds.Tables[0].Rows.Count == 0)
        {
            return;
        }

        DataSet tmpDs = ds.Clone();

        ds.Relations.Add("NodeRelation"
                         , ds.Tables[0].Columns["TASK_REF_ID"]
                         , ds.Tables[0].Columns["UP_TASK_REF_ID"]
                         , false);

        foreach (DataRow dbRow in ds.Tables[0].Rows)
        {
            if (DataTypeUtility.GetToInt32(dbRow["UP_TASK_REF_ID"]) == 0)
            {
                tmpDs.Tables[0].ImportRow(dbRow);
                PopulateScheduleTree(dbRow, tmpDs);
            }
        }

        _prjScheuldeDataProvider = new PrjScheuldeDataProvider(tmpDs.Tables[0]);
        _prjScheuldeDataProvider.WebScheduleInfo = this.WebScheduleInfo1;

        this.WebScheduleInfo1.AppointmentFormPath = "./PRJ0102M1.aspx?PRJ_REF_ID=" + _iPrjRefID + "&TASK_REF_ID=";
        this.WebScheduleInfo1.ReminderFormPath    = "./PRJ0102M1.aspx?PRJ_REF_ID=" + _iPrjRefID + "&TASK_REF_ID=" + _iTaskRefID;

        this.WebMonthView1.AppointmentFormatString        = "<SUBJECT>";
        this.WebMonthView1.AppointmentTooltipFormatString = "<DESCRIPTION><NEW_LINE><SUBJECT>";


        // 프로젝트 책임자 또는 사업구성원이 아닐경우
        Biz_Prj_Info     objPrj = new Biz_Prj_Info();
        Biz_Prj_Resource objRes = new Biz_Prj_Resource(this._iPrjRefID, gUserInfo.Emp_Ref_ID);

        if (!objPrj.IsOwnerEmpIDYN(gUserInfo.Emp_Ref_ID, this.IPrjRefID) ||
            (objRes == null))
        {
            _readOnlyYN = "Y";
        }
        else
        {
            _readOnlyYN = "N";
        }
    }
        //“浏览”按钮点击事件,浏览员工信息
        protected void btn_Browse_Click(object sender, EventArgs e)
        {
            string str = "";//查询字符串

            //清空Gridview数据
            GridView1.DataSource = null;
            GridView1.DataBind();

            if (employee_Ddl.SelectedIndex == 0)       //所有员工
            {
                if (department_Ddl.SelectedIndex == 0) //所有部门
                {
                    showEmp_Data();                    //查询所有员工信息
                    Label2.Text = "浏览成功!";
                    return;
                }
                else
                {
                    str = "departID = " + department_Ddl.SelectedIndex;
                }
            }
            else
            {
                str = "ename = '" + employee_Ddl.Text.Trim() + "'";
            }
            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = sqlconn;
                cn.Open();
                SqlDataAdapter adapter   = new SqlDataAdapter();
                SqlCommand     myCommand = new SqlCommand("select * from employee", cn);
                adapter.SelectCommand = myCommand;
                DataSet ds = new DataSet();
                adapter.Fill(ds, "employees");//填充数据集
                DataTable         myTable = ds.Tables["employees"];
                SqlCommandBuilder scb     = new SqlCommandBuilder(adapter);

                DataRow[] dr    = myTable.Select(str);//查询数据
                DataSet   newds = new DataSet();
                newds = ds.Clone();
                foreach (DataRow row in dr)
                {
                    newds.Tables["employees"].NewRow();                //创建与表具有相同架构的新DataRow
                    newds.Tables["employees"].Rows.Add(row.ItemArray); //ItemArray:获取或设置行中所有列的值。
                }
                ds.Tables["employees"].AcceptChanges();                //应用更改
                GridView1.DataSource = newds.Tables["employees"].DefaultView;
                GridView1.DataBind();

                Label2.Text = "浏览成功!";

                cn.Close();
                adapter.Dispose();
            }
        }
Пример #28
0
        public void ResetCondition()
        {
            _dtParam.Clear();

            //if (bsprParam.RowCount() > 0)
            //{
            DataSet ds = (DataSet)bsprParam.DataSet;

            bsprParam.DataSet = ds.Clone();
            //}
        }
Пример #29
0
        public DataSet GetDetailRpt(string yrmo, string plancode)
        {
            IPBA_DAL dobj  = new IPBA_DAL();
            int      count = 0;

            string[]  programs = { "Active", "Active Pilot", "COBRA", "COBRA Pilot" };
            string[]  tiercds  = { "E", "C", "S", "F" };
            DataSet   dsTemp   = new DataSet(); dsTemp.Clear();
            DataSet   dsDet    = new DataSet(); dsDet.Clear();
            DataTable tblDet;
            DataRow   row;

            DataRow[] rows;


            dsTemp = dobj.GetDetData(yrmo, plancode);
            dsDet  = dsTemp.Clone(); tblDet = dsDet.Tables[0];

            foreach (string program in programs)
            {
                foreach (string tiercd in tiercds)
                {
                    rows  = GetDetRows(program, tiercd, dsTemp); dsDet.Merge(rows);
                    count = GetDetEmpCount(program, tiercd, dsTemp);

                    if (count != 0)
                    {
                        row         = tblDet.NewRow();
                        row["Name"] = "***";
                        row["Tier"] = count;
                        row["Rate"] = GetDetTotalAmt(program, tiercd, dsTemp);
                        tblDet.Rows.Add(row);
                    }
                }
                count = GetEmpCount(program, dsTemp);
                if (count != 0)
                {
                    row          = tblDet.NewRow();
                    row["Class"] = "*** SUB TOTAL:";
                    row["Tier"]  = count;
                    row["Rate"]  = GetTotalAmt(program, dsTemp);
                    tblDet.Rows.Add(row);
                }
            }
            if (tblDet.Rows.Count > 0)
            {
                row          = tblDet.NewRow();
                row["Class"] = "*** GRAND TOTAL:";
                row["Rate"]  = GetTotalAmt(dsTemp);
                tblDet.Rows.Add(row);
            }

            return(dsDet);
        }
Пример #30
0
        private void ScegliFattura()
        {
            string filter = GetFilter();

            MetaData E = Disp.Get("invoiceview");

            E.FilterLocked = true;
            E.DS           = D.Clone();
            Selected       = E.SelectOne("default", filter, "invoiceview", null);

            riempiTextBox(Selected);
        }
Пример #31
0
        private void AddToCache(DataSet ds)
        {
            string tempPath = Path.GetTempFileName();
            long sizeOfDS = 0;
            try
            {
                string targetUri = String.Format("msds:csv?file={0}&openMode=create&appendMetadata=true", tempPath);
                ds.Clone(targetUri);

                string hash = null;

                if (ds.Metadata.ContainsKey(Namings.metadataNameHash))
                {
                    hash = (string)ds.Metadata[Namings.metadataNameHash];
                }
                else
                {
                    hash = DataSetDiskCache.ComputeHash(ds);
                }
                string targetPath = Path.Combine(cacheFolder, String.Format("{0}.csv", hash));

                if (File.Exists(targetPath))
                    File.Delete(targetPath);
                File.Move(tempPath, targetPath);
                tempPath = null;
                //File.SetAttributes(targetPath, FileAttributes.ReadOnly);
                sizeOfDS = (new FileInfo(targetPath)).Length;

            }
            catch (Exception ex)
            {
                Trace.WriteLineIf(Tracer.TraceError, "Failed to save cache. " + ex.ToString());
                return;
            }
            finally
            {
                if (tempPath != null)
                    File.Delete(tempPath);
            }

            ScheduleCacheClearCheck(sizeOfDS);
        }
Пример #32
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.Equal(1, ds1.Relations.Count);
            Assert.Equal(1, ds2.Relations.Count);

            Assert.Equal(0, ds1.Tables[0].Constraints.Count);
            Assert.Equal(0, ds1.Tables[1].Constraints.Count);

            Assert.Equal(0, ds2.Tables[0].Constraints.Count);
            Assert.Equal(0, ds2.Tables[1].Constraints.Count);
        }
Пример #33
0
        /// <summary>
        /// Receive the ensemble from the codec.
        /// Then set the ensemble size in bytes 
        /// so that the next ensemble can be found quicker.
        /// Set the flag that the ensemble was found.
        /// Then store the ensemble for playback.
        /// </summary>
        /// <param name="ensembleRaw">Ensemble binary data.</param>
        /// <param name="ensemble">Ensemble object.</param>
        private void _adcpCodec_ProcessDataEvent(byte[] ensembleRaw, DataSet.Ensemble ensemble)
        {
            // Set the length of an ensemble to find the next ensemble
            // quicker
            BytesPerEnsemble = ensembleRaw.Length;

            // Copy the data
            var ens = ensemble.Clone();
            byte[] raw = new byte[ensembleRaw.Length];
            Buffer.BlockCopy(ensembleRaw, 0, raw, 0, ensembleRaw.Length);

            // Create the velocity vectors for the ensemble
            DataSet.VelocityVectorHelper.CreateVelocityVector(ref ens);

            // Store the found ensemble
            _ensembleList.Add(new EnsembleData(raw, ens));

            // Set total number of ensembles
            // Subtract because 0 based
            TotalEnsembles = _ensembleList.Count() - 1;
        }
Пример #34
0
        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.Equal(ds.GetXmlSchema(), dsTarget.GetXmlSchema() );
            //use my function because GetXmlSchema not implemented in java
            Assert.Equal(DataProvider.GetDSSchema(ds), DataProvider.GetDSSchema(dsTarget));

            // Clone 2
            Assert.Equal(false, dsTarget.GetXml() == ds.GetXml());
        }
Пример #35
0
        /// <summary>
        /// Accumulate ensembles to average.  This will pass the ensemble to all the
        /// different averagers to accumulate the data.  When the NumSamples has been met,
        /// an event will be sent with the averaged ensemble.
        /// </summary>
        /// <param name="ensemble"></param>
        public void AddEnsemble(DataSet.Ensemble ensemble)
        {
            // Clone the ensemble
            var cloneEnsemble = ensemble.Clone();

            // Correlation averager
            if (IsCorrelationAveraging)
            {
                _correlationAverager.AddEnsemble(cloneEnsemble);
            }

            // Amplitude averager
            if (IsAmplitudeAveraging)
            {
                _amplitudeAverager.AddEnsemble(cloneEnsemble);
            }

            // Beam Velocity Averager
            if (IsBeamVelocityAveraging)
            {
                _beamVelAverager.AddEnsemble(cloneEnsemble);
            }

            // Instrument Velocity Averager
            if (IsInstrumentVelocityAveraging)
            {
                _instrumentVelAverager.AddEnsemble(cloneEnsemble);
            }

            // Earth Velocity Averager
            if (IsEarthVelocityAveraging)
            {
                _earthVelAverager.AddEnsemble(cloneEnsemble);
            }

            // Reference layer averaging
            if (IsReferenceLayerAveraging)
            {
                _refLayerAverager.AddEnsemble(cloneEnsemble);
            }

            // Bottom Track averaging
            if (IsBottomTrackAveraging)
            {
                _bottomTrackAverager.AddEnsemble(cloneEnsemble);
            }

            // Set the first ping time if it has not been set
            if (ensemble.IsAncillaryAvail && _firstPingTime == DEFAULT_FIRST_PING_TIME)
            {
                _firstPingTime = cloneEnsemble.AncillaryData.FirstPingTime;
            }

            // Set the previous ensemble
            _lastEnsemble = cloneEnsemble;

            // Increment the ensemble count
            _ensCount++;

            // Running average
            // This will continously average the incoming data
            if(IsAvgRunning)
            {
                // Publish the averaged data
                PublishAverage(cloneEnsemble);
            }
            // If we have met the number of samples
            // Publish the number of samples
            else if (IsAvgByNumSamples && _ensCount >= NumSamples)
            {
                // Publish the averaged data
                PublishAverage(cloneEnsemble);

                // If we are not doing a running average
                // Then clear the ensemble count so we
                // can start over counting
                if (!IsSampleRunningAverage)
                {
                    ClearCount();
                }
                else
                {
                    // Set the new first ping time for running average
                    _firstPingTime = cloneEnsemble.AncillaryData.FirstPingTime;

                    // Keep the _ensCount the same as the NumSamples so the
                    // number does not overflow
                    _ensCount = NumSamples;

                    // Remove the first ensemble
                    RemoveFirstEnsemble();
                }
            }
        }
Пример #36
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.Equal(1, ds.Tables["Directories"].Constraints.Count);
            Assert.Equal(1, ds.Tables["Files"].Constraints.Count);

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

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

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

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

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

            UniqueConstraint copyUc = (UniqueConstraint)copy_ds.Tables["Directories"].Constraints[0];
            origUc = (UniqueConstraint)ds.Tables["Directories"].Constraints[0];
            Assert.Equal(origUc.ConstraintName, copyUc.ConstraintName);
            Assert.Equal(1, copyUc.Columns.Length);
            Assert.Equal("UID", copyUc.Columns[0].ColumnName);
        }
Пример #37
0
 public void CloneCopy2()
 {
     var ds = new DataSet();
     ds.ReadXmlSchema(new StringReader(DataProvider.store));
     ds.Clone();
 }
Пример #38
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.Equal(set.CaseSensitive, copySet.CaseSensitive);
            Assert.Equal(set.DataSetName, copySet.DataSetName);
            Assert.Equal(set.EnforceConstraints, copySet.EnforceConstraints);
            Assert.Equal(set.HasErrors, copySet.HasErrors);
            Assert.Equal(set.Namespace, copySet.Namespace);
            Assert.Equal(set.Prefix, copySet.Prefix);
            Assert.Equal(set.Relations.Count, copySet.Relations.Count);
            Assert.Equal(set.Tables.Count, copySet.Tables.Count);
            Assert.Equal(set.ExtendedProperties["TimeStamp"], copySet.ExtendedProperties["TimeStamp"]);
            for (int i = 0; i < copySet.Tables.Count; i++)
            {
                Assert.Equal(set.Tables[i].Rows.Count, copySet.Tables[i].Rows.Count);
                Assert.Equal(set.Tables[i].Columns.Count, copySet.Tables[i].Columns.Count);
            }
            //Testing Clone ()
            copySet = set.Clone();
            Assert.Equal(set.CaseSensitive, copySet.CaseSensitive);
            Assert.Equal(set.DataSetName, copySet.DataSetName);
            Assert.Equal(set.EnforceConstraints, copySet.EnforceConstraints);
            Assert.False(copySet.HasErrors);
            Assert.Equal(set.Namespace, copySet.Namespace);
            Assert.Equal(set.Prefix, copySet.Prefix);
            Assert.Equal(set.Relations.Count, copySet.Relations.Count);
            Assert.Equal(set.Tables.Count, copySet.Tables.Count);
            Assert.Equal(set.ExtendedProperties["TimeStamp"], copySet.ExtendedProperties["TimeStamp"]);
            for (int i = 0; i < copySet.Tables.Count; i++)
            {
                Assert.Equal(0, copySet.Tables[i].Rows.Count);
                Assert.Equal(set.Tables[i].Columns.Count, copySet.Tables[i].Columns.Count);
            }
        }
Пример #39
0
        /// <summary>
        /// Take the last ensemble as the parameter.  Fill in 
        /// the averaged data to the ensemble.  Then publish
        /// it to all the subscribers.
        /// </summary>
        /// <param name="ensemble">Last ensemble that was accumulated.</param>
        private void PublishAverage(DataSet.Ensemble ensemble)
        {
            // Clone the ensemble
            DataSet.Ensemble avgEnsemble = ensemble.Clone();

            // Set the num of samples and the first ping time to the ensemble
            SetAveragedEnsembleParameters(ref avgEnsemble);

            // Correlation Averaging
            if (IsCorrelationAveraging)
            {
                _correlationAverager.SetAverage(ref avgEnsemble, _options.CorrelationScale);
            }

            // Amplitude averaging
            if (IsAmplitudeAveraging)
            {
                _amplitudeAverager.SetAverage(ref avgEnsemble, _options.AmplitudeScale);
            }

            // Beam Velocity Averging
            if (IsBeamVelocityAveraging)
            {
                _beamVelAverager.SetAverage(ref avgEnsemble, _options.BeamVelocityScale);
            }

            // Instrument Velocity Averging
            if (IsInstrumentVelocityAveraging)
            {
                _instrumentVelAverager.SetAverage(ref avgEnsemble, _options.InstrumentVelocityScale);
            }

            // Earth Velocity Averging
            if (IsEarthVelocityAveraging)
            {
                _earthVelAverager.SetAverage(ref avgEnsemble, _options.EarthVelocityScale);
            }

            // Bottom Track Averging
            if (IsBottomTrackAveraging)
            {
                _bottomTrackAverager.SetAverage(ref avgEnsemble, _options.BottomTrackRangeScale, _options.BottomTrackSnrScale,
                    _options.BottomTrackAmplitudeScale, _options.BottomTrackCorrelationScale,
                    _options.BottomTrackBeamVelocityScale, _options.BottomTrackInstrumentVelocityScale, _options.BottomTrackEarthVelocityScale);
            }

            // Reference Layer Averaging
            if (IsReferenceLayerAveraging)
            {
                _refLayerAverager.SetAverage(ref avgEnsemble, 1.0f);
            }

            // Publish the ensemble to all the subscribers
            PublishAveragedEnsemble(avgEnsemble);

            // Clear the accumulated data if not a running average
            if (!IsSampleRunningAverage)
            {
                // Clear the accumulated data
                ClearAccumulatedData();
            }
        }