Example #1
0
        public string CompatOldProjectRegion()
        {
            //获取所有子region的数据
            DataTable dtr         = _dao.GetRegionData("select Code, ParentRegionCode from JCHVRF_Region where ParentRegionCode is not null");
            Hashtable tbSubRegion = new Hashtable();

            foreach (DataRow dr in dtr.Rows)
            {
                tbSubRegion.Add(dr["Code"].ToString(), dr["ParentRegionCode"].ToString());
            }
            //轮询Project库中的UnitInfo表,变更Label数据
            string ConnectionString_Project = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\Project.mdb;Persist Security Info=False;Jet OLEDB:Database Password=YqJz2010Co04Ir15Kf;";

            using (OleDbConnection conn = new OleDbConnection(ConnectionString_Project))
            {
                OleDbDataAdapter da = new OleDbDataAdapter("select * from UnitInfo", ConnectionString_Project);
                //OleDbCommandBuilder cd = new OleDbCommandBuilder(da);
                DataTable dtp = new DataTable();
                da.Fill(dtp);
                string strLabel = "";
                bool   bUpdate  = false;
                foreach (DataRow dr in dtp.Rows)
                {
                    strLabel = dr["Label"].ToString();
                    if (tbSubRegion.ContainsKey(strLabel))
                    {
                        strLabel    = tbSubRegion[strLabel].ToString() + "/" + strLabel;
                        dr["Label"] = strLabel;
                        bUpdate     = true;
                    }
                }
                if (bUpdate)
                {
                    try
                    {
                        da.Update(dtp);
                        dtp.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        return(ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }

            return("");
        }
Example #2
0
        public MyRegion GetItem(string code)
        {
            //string sql = "select * from JCHVRF_Region where Code = '" + code + "'";

            string sql = "select t1.*,t2.RegistPassword,t2.PricePassword,t2.YorkPassword,t2.HitachiPassword from JCHVRF_Region t1 "
                         + "left join JCHVRF_Region_Password t2 on t1.code = t2.code "
                         + "where t1.Code = '" + code + "'";
            DataTable dt = _dao.GetRegionData(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];

                MyRegion reg = new MyRegion();
                reg.Code             = code;
                reg.Region           = (dr["Region"] is DBNull) ? "" : dr["Region"].ToString().Trim();
                reg.ParentRegionCode = (dr["ParentRegionCode"] is DBNull) ? "" : dr["ParentRegionCode"].ToString().Trim();
                reg.RegistPassword   = (dr["RegistPassword"] is DBNull) ? "" : dr["RegistPassword"].ToString().Trim();
                reg.PricePassword    = (dr["PricePassword"] is DBNull) ? "" : dr["PricePassword"].ToString().Trim();
                return(reg);
            }
            return(null);
        }