C# (CSharp) Класс System.Data. DataSet Code Examples

C# (CSharp) System.Data.DataSet - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для класса System.Data.DataSet, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Наследование: System.ComponentModel.MarshalByValueComponent, IListSource, IXmlSerializable, ISupportInitializeNotification, ISupportInitialize, ISerializable
Пример #1
0
 public void BindData()
 {
     DataSet searchList = new DataSet();
     StringBuilder builder = new StringBuilder();
     if (this.txtKeyword.Text.Trim() != "")
     {
         builder.Append(" NickName like '%" + this.txtKeyword.Text + "%' ");
     }
     if (!string.IsNullOrEmpty(this.txtBeginTime.Text.Trim()))
     {
         if (builder.Length > 0)
         {
             builder.Append(" and ");
         }
         builder.Append("  convert(date,User_dateCreate)>='" + this.txtBeginTime.Text.Trim() + "' ");
     }
     if (Globals.SafeInt(this.dropType.SelectedValue, -1) > -1)
     {
         if (builder.Length > 0)
         {
             builder.Append(" and ");
         }
         builder.Append("  Activity=" + this.dropType.SelectedValue + " ");
     }
     if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
     {
         if (builder.Length > 0)
         {
             builder.Append(" and ");
         }
         builder.Append("  convert(date,User_dateCreate)<='" + this.txtEndTime.Text.Trim() + "' ");
     }
     searchList = this.user.GetSearchList("UU", builder.ToString());
     this.gridView.DataSetSource = searchList;
 }
Пример #2
0
        public static void LerUsuarios_Desconectado()
        {
            DataSet ds = new DataSet();

            using (var con = ObterConexao())
            {
                var cmd = con.CreateCommand();

                cmd.CommandText = "SELECT * FROM Usuario";

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(ds);
            }

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataColumn column in table.Columns)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Console.WriteLine("{0}: {1}", column.ColumnName, row[column.ColumnName]);
                    }
                }
            }

            Console.Read();
        }
Пример #3
0
 public void LoadData()
 {
     ds = BWorkstation.Retrieves();
     dgrWorkstation.AutoGenerateColumns = false;
     dgrWorkstation.DataSource = ds.Tables[0].DefaultView;
     GenSTT();
 }
        public IList<Models.Auto> GetAllAutos()
        {
            DataSet ds = new DataSet();

            myCommand = new SqlDataAdapter("Select * from Auto", myConnection);

            ds = new DataSet();

            myCommand.Fill(ds);

            IList<Models.Auto> AutoList = new List<Models.Auto>();

            foreach (DataRow item in ds.Tables[0].Rows)
            {
                AutoList.Add(new Auto
                {
                    AutoNumber = item["AutoNumber"].ToString(),
                    AutoName = item["AutoName"].ToString()
                });
            }

            ds.Dispose();
            ds = null;

            return AutoList;
        }
        public static int SaveRecord(string sql)
        {
            const int rv = 0;
            try
            {
                string connectionString = ConfigurationManager.ConnectionStrings["LA3Access"].ConnectionString;
                using (var conn = new OleDbConnection(connectionString))
                {
                    conn.Open();
                    var cmGetID = new OleDbCommand("SELECT @@IDENTITY", conn);
                    var comm = new OleDbCommand(sql, conn) { CommandType = CommandType.Text };
                    comm.ExecuteNonQuery();

                    var ds = new DataSet();
                    var adapt = new OleDbDataAdapter(cmGetID);
                    adapt.Fill(ds);
                    adapt.Dispose();
                    cmGetID.Dispose();

                    return int.Parse(ds.Tables[0].Rows[0][0].ToString());

                }
            }
            catch (Exception)
            {
            }
            return rv;
        }
 public DataSet GetAll(string empresaid, tb_co_tabla01_mediopago BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTabla01Mediopago_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 3).Value = BE.codigoid;
                 cmd.Parameters.Add("@descripcion", SqlDbType.VarChar, 100).Value = BE.descripcion;
                 cmd.Parameters.Add("@sigla", SqlDbType.Char, 3).Value = BE.sigla;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Пример #7
0
 public SquadForm(DbConnect postgreConnect, DataSet globalDS, int squadID = -1)
 {
     InitializeComponent();
     cbColumn = new DataGridViewCheckBoxColumn();
     cbColumn.HeaderText = "Является сотрудником отряда";
     cbColumn.DataPropertyName = "is_in_squad";
     cbColumn.FillWeight = 40;
     cbColumn.ReadOnly = false;
     dataSet1 = globalDS;
     postgreConnection = postgreConnect;
     squadSelectBS.DataSource = dataSet1.Tables["squad"];
     listBox1.DataSource = dataSet1.Tables["squad"];
     listBox1.DisplayMember = "name";
     listBox1.ValueMember = "id";
     initEnd = true;
     if (listBox1.SelectedValue != null)
         ChangeSelectedSquad(int.Parse(listBox1.SelectedValue.ToString()));
     else
         DeactivateAllButtons();
     SetButtonPermissions();
     if (squadID != -1)
         listBox1.SelectedValue = squadID;
     bindingNavigator2.BindingSource = selectionsDataBS;
     bindingNavigator1.BindingSource = employeesAddBS;
     dataGridView1.DataSource = selectionsDataBS;
 }
Пример #8
0
        /// <summary>
        /// 处理数据
        /// </summary>
        /// <param name="ds"></param>
        public void HandleData(DataSet ds)
        {
            int count = ds.Tables[0].Rows.Count;
            int current = AspNetPager.PageSize * (AspNetPager.CurrentPageIndex - 1) + 1;

            dsPosts.Tables.Add("table");
            dsPosts.Tables[0].Columns.AddRange(new DataColumn[] {
                new DataColumn("ID"),
                new DataColumn("PostTitle"),
                new DataColumn("PosterID"),
                new DataColumn("PostContent"),
                new DataColumn("PostRecordTime"),
                new DataColumn("PostReplyCount"),
                new DataColumn("PosterType"),
                new DataColumn("PostPlateID"),
                new DataColumn("ViewTimes")
            });

            DataRow row;
            for (int i = current - 1; (i < current + AspNetPager.PageSize - 1) && (i < count); i++)
            {
                row = ds.Tables[0].Rows[i];

                dsPosts.Tables[0].Rows.Add(row["ID"], row["PostTitle"], row["PosterID"], row["PostContent"], row["PostRecordTime"],
                    row["PostReplyCount"], row["PosterType"], row["PostPlateID"], row["ViewTimes"]);
            }
        }
Пример #9
0
        public bool InsertUpdateDelete(DataSet ds)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand commandInsert = db.GetStoredProcCommand("usp_TaxTypeInsert");

            db.AddInParameter(commandInsert, "@CompanyId", DbType.Int32, "CompanyId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@TaxTypeName", DbType.String, "TaxTypeName", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Note", DbType.String, "Note", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@TaxPercentage", DbType.Decimal, "TaxPercentage", DataRowVersion.Current);

            db.AddInParameter(commandInsert, "@CreatedUser", DbType.Int32, "CreatedUser", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandUpdate = db.GetStoredProcCommand("usp_TaxTypeUpdate");
            db.AddInParameter(commandUpdate, "@TaxTypeId", DbType.Int32, "TaxTypeId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@TaxTypeName", DbType.String, "TaxTypeName", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Note", DbType.String, "Note", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@TaxPercentage", DbType.Decimal, "TaxPercentage", DataRowVersion.Current);

            db.AddInParameter(commandUpdate, "@UpdatedUser", DbType.Int32, "UpdatedUser", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandDelete = db.GetStoredProcCommand("usp_TaxTypeDelete");
            db.AddInParameter(commandDelete, "@TaxTypeId", DbType.Int32, "TaxTypeId", DataRowVersion.Current);

            db.UpdateDataSet(ds, ds.Tables[0].TableName, commandInsert, commandUpdate, commandDelete, UpdateBehavior.Transactional);

            return true;
        }
Пример #10
0
 public static List<string> QueryAccessFomList(int userID, string conn)
 {
     try
     {
         List<string> list = new List<string>();
         DataSet ds = new DataSet();
         ds.Tables.Add();
         ds.Tables[0].Columns.Add("mode");
         ds.Tables[0].Columns.Add("id");
         ds.Tables[0].Rows.Add("2", userID);
         DataTable dt = DbUserRes.QueryFormAuth(ds, conn);
         if (dt != null && dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string formName = dt.Rows[i]["NAME"].ToString();
                 if (!list.Contains(formName))
                 {
                     list.Add(formName);
                 }
             }
         }
         return list;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            DataSet ds1 = new DataSet();
            ds.ReadXml(@"D:\Books.xml");

            bookgrd.DataSource = ds.Tables[0];
            bookgrd.DataBind();

            IEnumerable<DataRow> tbl1row = ds.Tables[0].AsEnumerable();
            ds1.ReadXml(@"D:\Books2.xml");

            IEnumerable<DataRow> tbl2row = ds1.Tables[0].AsEnumerable();
            GridView1.DataSource = ds1.Tables[0];
            GridView1.DataBind();

            var items = tbl2row.AsEnumerable().Select(r => r.Field<string>("id"))
            .Except(tbl1row.AsEnumerable().Select(r => r.Field<string>("id")));

            DataTable TableC = (from row in tbl2row.AsEnumerable()
                                join id in items
                                on row.Field<string>("id") equals id
                                select row).CopyToDataTable();

            GridView2.DataSource = TableC;
            GridView2.DataBind();
        }
Пример #12
0
        public DataSet FilterData(ArsonFilterModel filterData)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["UCR_DataEntities"];
            DataSet dsResult = new DataSet();
            using (SqlConnection conn = new SqlConnection(connectionString.ConnectionString))
            {
                try
                {
                    SqlCommand command = new SqlCommand();
                    command.Connection = conn;
                    command.CommandText = GenerateArsonORQuery(filterData);
                    command.CommandType = System.Data.CommandType.Text;
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = command;

                    conn.Open();
                    adapter.Fill(dsResult);
                    conn.Close();
                    adapter.Dispose();
                    command.Dispose();
                }
                catch (Exception ex)
                {
                    StorageClient.LogError(ex);
                }
            }
            return dsResult;
        }
Пример #13
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection con = new SqlConnection(constring);
            con.Open();

            int curRow = int.Parse(e.RowIndex.ToString());
            string currentrow;
            currentrow = dataGridView1.Rows[curRow].Cells[1].Value.ToString();

            SqlDataAdapter adp1 = new SqlDataAdapter("Select * from ResManagerToAdmin where ResID='" + currentrow + "'", con);
            DataSet ds1 = new DataSet();
            adp1.Fill(ds1);

            SqlCommand cmd = new SqlCommand("Update ResManagerToAdmin set RView='" + p2 + "' where ResID='" + currentrow + "'", con);
            cmd.ExecuteNonQuery();

            SqlCommand cmd1 = new SqlCommand("Update ResManagerToAdmin set RFinalView='" + p2 + "' where ResID='" + currentrow + "'", con);
            cmd1.ExecuteNonQuery();

            status = ds1.Tables[0].Rows[0]["RStatus"].ToString();

            if (status == "Success")
            {
                ViewAdminResponses var = new ViewAdminResponses();
                var.ShowDialog();
            }
            else
            {
                RecordNotFound rnf = new RecordNotFound();
                rnf.ShowDialog();
            }
        }
Пример #14
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            SqlConnection con1 = new SqlConnection(constring);
            con1.Open();
            SqlDataAdapter adp = new SqlDataAdapter("Select whoislogin from Registration", con1);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                SqlCommand cmd = new SqlCommand("Update Registration set whoislogin='" + whoislog + "'", con1);
                cmd.ExecuteNonQuery();
            }

            SqlDataAdapter adp2 = new SqlDataAdapter("Select * from ResManagerToAdmin", con1);
            DataSet ds2 = new DataSet();
            adp2.Fill(ds2);
            for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
            {
                //adminview = ds.Tables[0].Rows[j]["RView"].ToString();
                SqlCommand cmd = new SqlCommand("Update ResManagerToAdmin set RView='" + adminviewempty + "'", con1);
                cmd.ExecuteNonQuery();
            }

            con1.Close();
            this.Close();
        }
Пример #15
0
        /// <summary>
        /// 根据faterid 获取组织机构树
        /// </summary>
        /// <returns></returns>
        public DataSet GetORGTreeByID(Dbconn conn, String strType)
        {
            DataSet ds = new DataSet();
            String strSQL = "";

            //获取条件值
            string strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
            DataSet dsXML = Common.Common.GetDSByExcelXML(strXML);
            string strPage = dsXML.Tables["LIST"].Rows[0]["Page"].ToString();
            string strNum = dsXML.Tables["LIST"].Rows[0]["Num"].ToString();
            string strCons = dsXML.Tables["LIST"].Rows[0]["Cons"].ToString();
            string strOrderBy = dsXML.Tables["LIST"].Rows[0]["OrderBy"].ToString();
            string[] strParam = new string[] { };
            strSQL = @" SELECT [OZ1_OrgCode], [OZ1_OrgName], [OZ1_FatherId]
                        , [OZ1_OrgType], [OZ1_ID], [OZ1_CONO], [OZ1_DIVI], [OZ1_FatherId] As [OZ1_FatherIdT]
                        , [OZ1_CostCenterCode], [OZ1_DepartmentManager]
                        , [OZ1_MDeptCode], [OZ1_ShopCode], [OZ1_OrgEnable]
                        , [OZ1_CostCenterEnable], [OZ1_BusdepartmentEnable]
                        , [OZ1_ShopEnable], [OZ1_State], [OZ1_ModelType], [OZ1_BMMoney] 
                        , [OZ1_Brand], [OZ1_Com], [OZ1_CostCenterCode1], [OZ1_BMPer]
                        , OZ1_Com1, OZ1_ComCode1, OZ1_ISBranch, OZ1_CostCenterCode2
                        FROM [F01_CERT].[OZ1_Organization] 
                            WHERE 1=1  AND OZ1_OrgType <> '业务线' " + strCons + strOrderBy;
            ds = conn.GetDataSet(strSQL);
            return ds;
        }
Пример #16
0
        public static string runDocno(string tablename, string fieldname, string doctype)
        {

            SqlConnection con = new SqlConnection(SysApp.DatabaseConfig.ServerConStr);

            string sql = " select ";
            sql += " case when max(substring(" + fieldname + ",4,6)) <> convert(varchar,getdate(),12) then ";
            sql += " '" + doctype + "' + convert(varchar,getdate(),12) + '-0001' ";
            sql += " when max(substring(" + fieldname + ",4,6)) = convert(varchar,getdate(),12) then ";
            sql += " case ";
            sql += " when (select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%') <10 then '" + doctype + "' + convert(varchar,getdate(),12) + '-000' + convert(varchar,(select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%')) ";
            sql += " when (select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%') <100 then '" + doctype + "' + convert(varchar,getdate(),12) + '-00' + convert(varchar,(select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%')) ";
            sql += " when (select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%') <1000 then '" + doctype + "' + convert(varchar,getdate(),12) + '-0' + convert(varchar,(select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%')) ";
            sql += " else ";
            sql += " '" + doctype + "' + convert(varchar,getdate(),12) + '-' + convert(varchar,(select max(substring(" + fieldname + ",11,4))+1 from " + tablename + " where substring(" + fieldname + ",4,6) = convert(varchar,getdate(),12) and " + fieldname + " like '" + doctype + "%')) ";
            sql += " end ";
            sql += " else ";
            sql += " '" + doctype + "' + convert(varchar,getdate(),12) + '-0001' ";
            sql += " end ";
            sql += " as " + fieldname;
            sql += " from " + tablename;
            sql += " where " + fieldname + " like '" + doctype + "%' ";

            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            da.Fill(ds, "runDocno");
            string docno = ds.Tables["runDocno"].Rows[0][fieldname].ToString();
            da = null;
            return docno;
        }
        protected void load_price()
        {
            string price_name = null;
            string article = null;
            price_name = Request.QueryString["price_name"];
            article = Request.QueryString["article"];

            if (article != null)
            {
                if (price_name != null)
                {

                    SqlConnection con = new SqlConnection(str);
                    string sql = "SELECT id, article, ROUND([price]*(SELECT course FROM Course_USD WHERE id = 1),2) AS [price] FROM " + price_name + " WHERE article=" + article + ";";
                    SqlDataAdapter da = new SqlDataAdapter(sql, con);
                    DataSet ds = new DataSet();
                    da.Fill(ds, price_name);
                    DataRow dr;
                    dr = ds.Tables[price_name].Rows[0];

                    //Заполняем стоимость товара:
                    lblprice.Text = dr["price"].ToString();
                }
                else {Response.Redirect("Error.aspx");}

            }
            else {Response.Redirect("Error.aspx"); }
        }
Пример #18
0
        private void BindData()
        {
            SqlDataSource1.DataBind();
            //string sqlquery = "SELECT * FROM [ISBEPI_DEV].[dbo].[HomeVisitorSiteVisitSurvey] WHERE Schd_ID = 16";
            DataTable dt = new DataTable();
            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView view = (DataView)SqlDataSource1.Select(args);
            dt = view.ToTable();
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            DataSet new_ds = FlipDataSet(ds); // Flip the DataSet
            DataView my_DataView = new_ds.Tables[0].DefaultView;
            this.DataGrid1.DataSource = my_DataView;
            this.DataGrid1.DataBind();

            DataTable dt2 = new DataTable();
            DataSourceSelectArguments args2 = new DataSourceSelectArguments();
            DataView view2 = (DataView)SqlDataSource2.Select(args2);
            dt2 = view2.ToTable();
            DataSet ds2 = new DataSet();
            ds2.Tables.Add(dt2);
            DataSet new_ds2 = FlipDataSet(ds2); // Flip the DataSet
            DataView my_DataView2 = new_ds2.Tables[0].DefaultView;
            this.DataGrid2.DataSource = my_DataView2;
            this.DataGrid2.DataBind();
        }
Пример #19
0
        private void cartelera_Load(object sender, EventArgs e)
        {
            //frmCiudad ciudad = new frmCiudad();
            String numeroSucursal = lblsucursal.Text;

            string query = string.Format("select TRHORA.idSucursal,MAPELI.iidpelicula, MAPELI.bimagen FROM TRHORARIO TRHORA, MAPELICULA MAPELI WHERE TRHORA.iidpelicula=MAPELI.iidpelicula and TRHORA.idSucursal = '"+ numeroSucursal +"'");
            MySqlCommand comando = new MySqlCommand(query, classCrearConexion.Conexion());
            MySqlDataAdapter da = new MySqlDataAdapter(comando);
            DataSet ds = new DataSet("MAPELICULA");
            da.Fill(ds, "MAPELICULA");
            byte[] datos = new byte[0];
            DataRow dr = ds.Tables["MAPELICULA"].Rows[0];
            datos = (byte[])dr["bimagen"];
            System.IO.MemoryStream ms = new System.IO.MemoryStream(datos);
            pb1.Image = System.Drawing.Bitmap.FromStream(ms);
            /*pb1.Image = Properties.Resources.El_Destino_de_Júpite;
            pb1.Refresh();
            pb2.Image = Properties.Resources.FF2;
            pb2.Refresh();
            pb3.Image = Properties.Resources.In_to_the_Woods_En_el_Bosqu;
            pb3.Refresh();
            pb4.Image = Properties.Resources.Ombis_Alien_Invasion__2015_;
            pb4.Refresh();
            pb5.Image = Properties.Resources.peliculas_2015_15_e1422754101215;
            pb5.Refresh();
            pb6.Image = Properties.Resources.peliculas_2015_rapido_furioso_4;
            pb6.Refresh();
            pb7.Image = Properties.Resources.images;
            pb7.Refresh();*/
        }
Пример #20
0
        public DataSet FlipDataSet(DataSet my_DataSet)
        {
            DataSet ds = new DataSet();
            DataTable table = new DataTable();

            foreach (DataTable dt in my_DataSet.Tables)
            {

                for (int i = 0; i <= dt.Rows.Count; i++)
                {
                    table.Columns.Add(Convert.ToString(i));
                }

                for (int k = 0; k < dt.Columns.Count; k++)
                {
                    r = table.NewRow();
                    r[0] = dt.Columns[k].ToString();
                    for (int j = 1; j <= dt.Rows.Count; j++)
                        r[j] = dt.Rows[j - 1][k];
                    table.Rows.Add(r);
                }

                ds.Tables.Add(table);
            }

            return ds;
        }
        public void challanout()
        {
            DataTable dt = new DataTable("challandt");
            dt = (DataTable)Session["challanout_dt"];

            DataSet ds = new DataSet();
            Viewer.Report.ChallanOutrpt crystalReport = new Report.ChallanOutrpt();
            string st = HttpContext.Current.Server.MapPath("~/ChallanOutCrpt1.rpt");

            //  Label1.Text = st;
            //   Response.Write(string.Format("<script language='javascript' type='text/javascript'>alert( "+st+") </script>"));

            crystalReport.Load(st);
            if (ds.Tables.Contains("challandt") == true)
            {
                ds.Tables.Remove("challandt");
            }
            ds.Tables.Add(dt);

            ds.WriteXmlSchema(HttpContext.Current.Server.MapPath("~/App_Data/Challanout.xml"));

            crystalReport.SetDataSource(dt);
            CrystalReportViewer1.ReportSource = crystalReport;

            crystalReport.ExportToHttpResponse
               (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "CHALLANOUTSHEET");
        }
	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;

		DataSet ds = new DataSet();
		DataTable dtParent = GHTUtils.DataProvider.CreateParentDataTable();
		DataTable dtChild = GHTUtils.DataProvider.CreateChildDataTable();
		ds.Tables.Add(dtParent);
		ds.Tables.Add(dtChild);
		
		ForeignKeyConstraint fc = null;
		fc = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]);

		try
		{
			BeginCase("default ");
			Compare(fc.ConstraintName ,string.Empty );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		fc.ConstraintName  = "myConstraint";

		try
		{
			BeginCase("set/get ");
			Compare(fc.ConstraintName ,"myConstraint" );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
	}
 public DataSet GetAll(string empresaid, tb_tipimpto BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbTipimpto_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tipimptoid", SqlDbType.Char, 1).Value = BE.tipimptoid;
                 cmd.Parameters.Add("@status", SqlDbType.Bit).Value = BE.status;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Пример #24
0
 private void  button1_Click(object sender, EventArgs e)
 {
     
     bool check;
     Control.Control control= new Control.Control();
     Entity.Entity entity = new Entity.Entity();
     entity.setUsername(this.textBox1.Text);
     entity.setPassword(this.textBox2.Text);
     check = control.checkUsers(entity.getUsername(), entity.getPassword());
     dt = control.getCustomer(entity.getUsername());
     if (check)
     {
         check1 = true;
         mainForm main = new mainForm();
         main.ShowDialog();
         this.textBox1.Text = "";
         this.textBox2.Text = "";
     }
     else {
         this.textBox1.Text = "";
         this.textBox2.Text = "";
         MessageBox.Show("密码错误或用户名不存在");
     }
     
 }
Пример #25
0
        public static DataTable GetHandoverLogByHandoverLogId(int handoverLogId)
        {
            string connectionString = ConnectionStringFactory.GetNXJCConnectionString();
            DataSet ds = new DataSet();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = connection.CreateCommand();
                command.CommandText = @"SELECT  WorkingTeamShiftLog.*,
                                                StaffInfo.Name AS ChargeManName, ProductLine.Name AS ProductLineName,
                                                WorkingTeam.Name AS WorkingTeamName
                                        FROM    WorkingTeam INNER JOIN
                                                StaffInfo INNER JOIN
                                                WorkingTeamShiftLog ON StaffInfo.ID = WorkingTeamShiftLog.ChargeManID INNER JOIN
                                                ProductLine ON WorkingTeamShiftLog.ProductLineID = ProductLine.ID ON
                                                WorkingTeam.ID = WorkingTeamShiftLog.WorkingTeamID
                                        WHERE   (WorkingTeamShiftLog.ID = @workingTeamShiftLogID)";

                command.Parameters.Add(new SqlParameter("workingTeamShiftLogID", handoverLogId));
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                adapter.Fill(ds);
            }

            return ds.Tables[0];
        }
Пример #26
0
        public void process(ServiceRequest request, ServiceResponse response)
        {
            List<Category> list = new List<Category>();

            string sqlStr = "select * from category";

            MySqlConnection conn = ConnectionManager.getInstance().getConnection();

            conn.Open();

            MySqlDataAdapter mda = new MySqlDataAdapter(sqlStr, conn);
            DataSet ds = new DataSet();
            mda.Fill(ds,"table1");

            conn.Close();

            int count = ds.Tables["table1"].Rows.Count;
            for (int i = 0; i < count; i++)
            {
                Category c = new Category();
                c.categoryId = (int)ds.Tables["table1"].Rows[i][0];
                c.categoryName = (string)ds.Tables["table1"].Rows[i][1];
                list.Add(c);
            }

            GetCategoryResponse serviceResponse = new GetCategoryResponse();
            serviceResponse.categories = list;
            response.responseObj = serviceResponse;
            response.returnCode = 0;
        }
Пример #27
0
        private void ArrayBinding_Load(object sender, System.EventArgs e)
        {
            // Access database
            System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm)this.ParentForm;

            // The XML document
            string fileNameString = mainForm.applicationPath + "\\data\\data.xml";
            string fileNameSchema = mainForm.applicationPath + "\\data\\data.xsd";

            // Initializes a new instance of the DataSet class
            DataSet custDS = new DataSet();

            // Reads an XML schema into the DataSet.
            custDS.ReadXmlSchema( fileNameSchema );

            // Reads XML schema and data into the DataSet.
            custDS.ReadXml( fileNameString );

            // Initializes a new instance of the DataView class
            DataView firstView = new DataView(custDS.Tables[0]);

            Chart1.Series.Clear();
            // Since the DataView implements and IEnumerable, pass the reader directly into
            // the DataBindTable method with the name of the column used for the X value.
            Chart1.DataBindTable(firstView, "Name");

            // Set series appearance
            Chart1.Series[0].ChartType = SeriesChartType.Bar;
            Chart1.Series[0].Font = new Font("Trebuchet MS", 8);
            Chart1.Series[0].Color = System.Drawing.Color.FromArgb(220, 224,64,10);
            Chart1.Series[0].BorderWidth = 0;
        }
Пример #28
0
        public void resetData()
        {
            DataSet dstmp = new DataSet();
            //创建虚拟数据表
            DataTable table = new DataTable("TAB_NM");
            //获取列集合,添加列
            DataColumnCollection columns = table.Columns;
            columns.Add("教工号", typeof(String));
            columns.Add("姓名", typeof(String));
            columns.Add("基本工资", typeof(float));
            columns.Add("津贴", typeof(float));
            columns.Add("公积金", typeof(float));
            columns.Add("生活费", typeof(float));
            columns.Add("所得税", typeof(float));

            List<Teacher> list = new TeacherDB().selectAll();
            //Teacher mTeacher = new Teacher();
            foreach (Teacher mTeacher in list)
            {
                //添加一行记录
                DataRow row = table.NewRow();
                row["教工号"] = mTeacher.Id;
                row["姓名"] = mTeacher.Name;
                row["基本工资"] = mTeacher.BaseSalary;
                row["津贴"] = mTeacher.Allowance;
                row["公积金"] = mTeacher.Fund;
                row["生活费"] = mTeacher.Sanitary;
                row["所得税"] = mTeacher.IncomeTax;
                table.Rows.Add(row);

            }
            dstmp.Tables.Add(table); //把信息表放入DataSet中

            dataGridView1.DataSource = dstmp.Tables["TAB_NM"];
        }
Пример #29
0
        public UserAction GetUserDetails(string UserName)
        {
            try
            {
                oDatabaseHandler = new DatabaseHandler();
                DataSet oDataSet = new DataSet();
                oDataSet = oDatabaseHandler.FillData("select U.UserId,U.RoleId,R.[Role] RoleName,R.[Create],R.Edit,R.[View],R.Assign,R.Finish from Users as U "
                                                     + " inner join Roles R on R.RoleId=U.RoleId"
                                                     + " where U.UserName='" + UserName + "'");

                if (oDataSet != null && oDataSet.Tables != null && oDataSet.Tables.Count > 0 && oDataSet.Tables[0].Rows != null && oDataSet.Tables[0].Rows.Count > 0)
                {
                    UserAction oUserDetails = new UserAction();
                    //oUserDetails.Cus = int.Parse(oDataSet.Tables[0].Rows[0]["UserId"].ToString());
                    oUserDetails.UserName = UserName;// oDataSet.Tables[0].Rows[0]["UserId"].ToString();
                    oUserDetails.RoleID = int.Parse(oDataSet.Tables[0].Rows[0]["RoleId"].ToString());

                    oUserDetails.RoleName = oDataSet.Tables[0].Rows[0]["RoleName"].ToString();
                    oUserDetails.Create = bool.Parse(oDataSet.Tables[0].Rows[0]["Create"].ToString());
                    oUserDetails.Edit = bool.Parse(oDataSet.Tables[0].Rows[0]["Edit"].ToString());
                    oUserDetails.View = bool.Parse(oDataSet.Tables[0].Rows[0]["View"].ToString());
                    oUserDetails.Assign = bool.Parse(oDataSet.Tables[0].Rows[0]["Assign"].ToString());
                    oUserDetails.Finish = bool.Parse(oDataSet.Tables[0].Rows[0]["Finish"].ToString());

                    return oUserDetails;
                }
                return null;
            }
            catch (Exception ex)
            {

            }
            return null;
        }
Пример #30
0
        public static DataSet ExecuteDataSet(CommandType cmdType, string strProcedureName, SqlParameter[] objParameters)
        {
            DataSet dset = new DataSet();
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["db1ConnectionString"].ToString());
            con.Open();
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandType = cmdType;
                cmd.CommandText = strProcedureName;

                AttachParameters(cmd, objParameters);

                SqlDataAdapter ad = new SqlDataAdapter(cmd);
                ad.Fill(dset);

                return dset;

            }
            catch (Exception ex)
            {
                return dset;
            }
            finally
            {
                con.Close();
            }
        }