コード例 #1
0
ファイル: material.cs プロジェクト: liwg1995/wx_asp.net
        public List <materialData> GetList(string casestr)
        {
            List <materialData> listdata = new List <materialData>();
            DataTable           dt       = new DataTable();

            DataAccess.CommonDB objDB = new DataAccess.CommonDB();
            string sql = "select * from material where 1 = 1 ";

            sql += casestr;
            objDB.OpenConnection();
            dt = objDB.QueryDataTable(sql, "tabname");

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow tempRow in dt.Rows)
                {
                    materialData hd = new materialData();
                    hd.Id          = tempRow["Id"].ToString().Trim();
                    hd.materialtit = tempRow["materialtit"].ToString().Trim();
                    listdata.Add(hd);
                }
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            return(listdata);
        }
コード例 #2
0
ファイル: material.cs プロジェクト: liwg1995/wx_asp.net
        public bool Modify(materialData datmaterial)
        {
            int  iRel = -1;
            bool bRel = false;

            DataAccess.CommonDB objDB = new DataAccess.CommonDB();
            try
            {
                objDB.OpenConnection();
                string strSql = "update material set materialtype=@materialtype,materialtit=@materialtit,materialfile=@materialfile,materialtime=@materialtime where Id = @Id";
                objDB.Command.CommandType = System.Data.CommandType.Text;
                objDB.Command.CommandText = strSql;
                objDB.Command.Parameters.AddWithValue("@materialtype", datmaterial.materialtype);
                objDB.Command.Parameters.AddWithValue("@materialtit", datmaterial.materialtit);
                objDB.Command.Parameters.AddWithValue("@materialfile", datmaterial.materialfile);
                objDB.Command.Parameters.AddWithValue("@materialtime", datmaterial.materialtime);
                objDB.Command.Parameters.AddWithValue("@Id", datmaterial.Id);
                iRel = objDB.Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            { iRel = -1; }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            bRel  = (iRel.Equals(1) ? true : false); return(bRel);
        }
コード例 #3
0
ファイル: material.cs プロジェクト: liwg1995/wx_asp.net
        public materialData[] Select(string Id)
        {
            int iRel = -1;

            DataAccess.CommonDB objDB       = new DataAccess.CommonDB();
            materialData[]      datmaterial = new materialData[1];
            string sql = "select * from material where Id= " + Id + " ";

            try
            {
                objDB.OpenConnection();
                DataSet ds = objDB.QueryData(sql, "departmentinfo");
                if (ds.Tables.Count > 0)
                {
                    long nRow = ds.Tables[0].Rows.Count;
                    if (nRow > 0)
                    {
                        datmaterial = new materialData[nRow];
                        for (int i = 0; i < nRow; i++)
                        {
                            datmaterial[i] = new materialData();
                            datmaterial[i].materialtype = ds.Tables[0].Rows[i]["materialtype"].ToString();
                            datmaterial[i].materialtit  = ds.Tables[0].Rows[i]["materialtit"].ToString();
                            datmaterial[i].materialfile = ds.Tables[0].Rows[i]["materialfile"].ToString();
                            datmaterial[i].materialtime = ds.Tables[0].Rows[i]["materialtime"].ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                iRel = -1;
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            return(datmaterial);
        }