예제 #1
0
        public static string GetPHGG(string wlh)
        {
            AdoHelper oracleHelp = new OracleHelp();
            DataSet   ds         = null;

            try
            {
                ds = oracleHelp.ExecuteDataset(Common.NCDATASTRING, CommandType.Text, "select invtype,invspec from bd_invbasdoc where invcode='" + wlh + "'");
            }
            catch
            {
                return("");//NC数据库联接失败
            }

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                return(ds.Tables[0].Rows[0][0].ToString() + "," + ds.Tables[0].Rows[0][1].ToString());
            }
            return("");
        }
예제 #2
0
        /// <summary>
        /// 导入物料基础数据
        /// </summary>
        /// <returns>-1:NC服务器连接错误 1:本地服务器错误 0:成功</returns>
        public static int InportWLFromNC()
        {
            string strSele = Common.GetWLSql();

            if (string.IsNullOrEmpty(strSele))
            {
                return(-1);//无配置信息
            }
            AdoHelper oracleHelp = new OracleHelp();
            DataSet   ds         = null;

            try
            {
                ds = oracleHelp.ExecuteDataset(Common.NCDATASTRING, CommandType.Text, strSele);
            }
            catch
            {
                return(-1);//NC数据库联接失败
            }
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                AdoHelper     sqlHelp = new SqlHelp();
                StringBuilder strDel  = new StringBuilder();
                strDel.Append("delete from wms_bms_wl_sx");

                SqlConnection con = new SqlConnection(Common.GetConnectString());
                con.Open();
                SqlTransaction tra = con.BeginTransaction();
                try
                {
                    sqlHelp.ExecuteNonQuery(tra, CommandType.Text, strDel.ToString());
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("INSERT INTO WMS_BMS_WL_SX (wlh,sx) VALUES (@WLH,@SX)");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@WLH", SqlDbType.VarChar),
                            new SqlParameter("@SX",  SqlDbType.VarChar)
                        };
                        parameters[0].Value = row["invcode"].ToString();
                        parameters[1].Value = row["docname"].ToString();
                        sqlHelp.ExecuteNonQuery(tra, CommandType.Text, strSql.ToString(), parameters);
                    }
                    tra.Commit();
                    con.Close();
                }
                catch
                {
                    tra.Rollback();
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    return(1);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            return(0);
        }
예제 #3
0
        /// <summary>
        /// 导入客户数据
        /// </summary>
        /// <returns>-1:NC服务器连接错误 1:本地服务器错误 0:成功</returns>
        public static int InportKHFromNC()
        {
            string    strSelectNC = "select pk_cubasdoc,custcode,custname, saleaddr from bd_cubasdoc";
            AdoHelper oracleHelp  = new OracleHelp();
            DataSet   ds          = null;

            try
            {
                ds = oracleHelp.ExecuteDataset(Common.NCDATASTRING, CommandType.Text, strSelectNC);
            }
            catch
            {
                return(-1);//NC数据库联接失败
            }
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                AdoHelper     sqlHelp = new SqlHelp();
                StringBuilder strDel  = new StringBuilder();
                strDel.Append("DELETE FROM WMS_Pub_Customer");

                SqlConnection con = new SqlConnection(Common.GetConnectString());
                con.Open();
                SqlTransaction tra = con.BeginTransaction();
                try
                {
                    sqlHelp.ExecuteNonQuery(tra, CommandType.Text, strDel.ToString());
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into WMS_Pub_Customer(");
                        strSql.Append("KHID,KHName,KHAdress,KHLB)");
                        strSql.Append(" values (");
                        strSql.Append("@KHID,@KHName,@KHAdress,@KHLB)");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@KHID",     SqlDbType.VarChar),
                            new SqlParameter("@KHName",   SqlDbType.VarChar),
                            new SqlParameter("@KHAdress", SqlDbType.VarChar),
                            new SqlParameter("@KHLB",     SqlDbType.VarChar)
                        };
                        parameters[0].Value = row["custcode"].ToString();
                        parameters[1].Value = row["custname"].ToString();
                        parameters[2].Value = row["saleaddr"].ToString();
                        parameters[3].Value = "1";
                        sqlHelp.ExecuteNonQuery(tra, CommandType.Text, strSql.ToString(), parameters);
                    }
                    tra.Commit();
                    con.Close();
                }
                catch
                {
                    tra.Rollback();
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    return(1);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            return(0);
        }