示例#1
0
        public static string[] Get_Information(string dbname, string PID)
        {
            string[] result        = new string[3];
            string   select_string = "select EWID, UpperWID, SortNum from EBudget_WBS where PID='" + PID + "' order by SortNum";

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result[0] += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(1))
                                {
                                    result[1] += "0,";
                                }
                                else
                                {
                                    result[1] += reader.GetInt32(1).ToString() + ",";
                                }
                                if (reader.IsDBNull(2))
                                {
                                    result[2] += "0,";
                                }
                                else
                                {
                                    result[2] += reader.GetInt32(2).ToString() + ",";
                                }
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
                //Log exception
                //Display Error message
            }
            if (result[0].Length > 0)
            {
                for (int i = 0; i < result.Length; i++)
                {
                    result[i] = result[i].Substring(0, result[i].Length - 1);
                }
            }

            return(result);
        }
示例#2
0
        //public static int getUpperWID_by_UID(string dbname,int nowUID, int[] UID, int[] UpperUID)
        public static string[] getUpperWID_by_UID(string dbname, int nowUID)
        {
            //string[] result1;
            string temp = "";
            //int[] result = 0;
            string Select_string = "Select EWID,PID,UpperWID from EBudget_WBS where UpperWID=" + nowUID;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(Select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                temp += reader.GetInt32(0).ToString() + ",";

                                //for (int i = 0; i < UID.Length; i++)
                                // {
                                //     if (nowUID == UID[i])
                                //     {
                                //         result = UpperUID[i];
                                //         break;
                                //     }
                                // }
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
            }

            if (temp.Length > 0)
            {
                temp = temp.Substring(0, temp.Length - 1);
            }
            else
            {
                temp = "";
            }
            string[] result1 = temp.Split(',');
            string[] nextresult;
            for (int i = 0; i < result1.Length; i++)
            {
                nextresult = getUpperWID_by_UID(dbname, int.Parse(result1[i]));
            }
            return(result1);
        }
示例#3
0
        public static string[] Get_Information(string dbname, string PID)
        {
            string[] result = new string[3];
            //string select_string = "Select a.ParentID,a.KidID,b.PriceID From Pro_Analysis a left join Pro_Resource b on a.KidID=b.PriceID where ParentID=" + wid;
            string select_string = "Select a.ParentID,a.KidID,b.PriceID From Pro_Analysis a left join Pro_Resource b on a.KidID=b.PriceID where PID=" + PID;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result[0] += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(1))
                                {
                                    result[1] += "0,";
                                }
                                else
                                {
                                    result[1] += reader.GetInt32(1).ToString() + ",";
                                }
                                result[2] += reader.GetInt32(2).ToString() + ",";
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
                //Log exception
                //Display Error message
            }
            if (result[0] != null)
            {
                if (result[0].Length > 0)
                {
                    for (int i = 0; i < result.Length; i++)
                    {
                        result[i] = result[i].Substring(0, result[i].Length - 1);
                    }
                }
            }

            return(result);
        }
示例#4
0
        public static string[] Get_EBudget_WBS_Information(string dbname, string Pid)
        {
            //string temp = "";
            string[] result = new string[4];
            //string[] temp_WID = input[0].Split(',');
            //int count = 0;
            int[]  UpperWID      = new int[3];
            string Select_string = "Select EWID,CWID,UpperWID from EBudget_WBS where Pid=" + Pid;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(Select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result[0] += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(1))
                                {
                                    result[1] += "0,";
                                }
                                else
                                {
                                    result[1] += reader.GetInt32(1).ToString() + ",";
                                }
                                if (reader.IsDBNull(2))
                                {
                                    result[2] += "0,";
                                }
                                else
                                {
                                    result[2] += reader.GetInt32(2).ToString() + ",";
                                }
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
            }

            return(result);
        }
示例#5
0
        public static string[] check_num(string dbname, int UID)
        {
            string temp = "";

            //string[] result;
            string[] input = getUpperWID_by_UID(dbname, UID);
            //string[] temp_WID = input[0].Split(',');
            //int count = 0;
            int[]  UpperWID      = new int[3];
            int    UpperID       = 0;
            string Select_string = "Select CWID,PID,UpperWID from CBudget_WBS where CWID=" + UID;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(Select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                temp += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(2))
                                {
                                    UpperID = 0;
                                }
                                else
                                {
                                    UpperID = reader.GetInt32(2);
                                }
                                string[] newupperID = getUpperWID_by_UID(dbname, UpperID);
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
            }

            return(input);
        }
示例#6
0
        public static string[] Get_Pro_Resource_Information(string dbname, string Bid)
        {
            string[] result = new string[4];

            int[]  UpperWID      = new int[3];
            string Select_string = "Select PriceID,Temp_id from Pro_Resource where bid=" + Bid;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(Select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result[0] += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(1))
                                {
                                    result[1] += "0,";
                                }
                                else
                                {
                                    result[1] += reader.GetInt32(1).ToString() + ",";
                                }
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
            }

            return(result);
        }
示例#7
0
        public static bool checkPublicID(string dbname, string ID)
        {
            bool result = false;
            //decimal AnaNum = 1.000M;
            string SQLString = "select PublicID from UsualWord where PublicID=" + ID;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();
                    using (SqlCommand SelectList = new SqlCommand(SQLString, conn))
                    {
                        //conn.Open();
                        SqlDataReader SelectList_read = SelectList.ExecuteReader();
                        //DataTableBox = new DataTable();
                        //DataTableBox.Load(SelectList_read);
                        //for (int i = 0; i < DataTableBox.Columns.Count; i++)
                        //{
                        //    string temp2 = DataTableBox.Columns[i].ColumnName.ToString();
                        if (SelectList_read.HasRows)
                        {
                            result = false;
                        }
                        else
                        {
                            result = true;
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
                //Log exception
                //Display Error message
            }
            return(result);
        }
示例#8
0
        public static bool Update_order_num(string dbname, string PID)
        {
            bool result = false;

            int[]  input         = Sort_LayerCode(dbname, PID);
            int    count         = 0;
            string update_string = "Update EBudget_WBS SET order_Num = ";

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    for (int i = 0; i < input.Length; i++)
                    {
                        count++;
                        update_string = "Update EBudget_WBS SET order_Num ='" + count.ToString() + "' WHERE EWID='" + input[i].ToString() + "'";
                        using (SqlCommand cmd =
                                   new SqlCommand(update_string, conn))
                        {
                            int rows = cmd.ExecuteNonQuery();
                            if (rows > 0)
                            {
                                result = true;
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
                //Log exception
                //Display Error message
            }

            return(result);
        }
示例#9
0
        public static bool checkPublicID(string dbname, string ID)
        {
            bool result = false;
            //decimal AnaNum = 1.000M;
            string SQLString = "select PublicID from ConstructionElement where PublicID=" + ID;

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();
                    using (SqlCommand SelectList = new SqlCommand(SQLString, conn))
                    {
                        //conn.Open();
                        SqlDataReader SelectList_read = SelectList.ExecuteReader();

                        if (SelectList_read.HasRows)
                        {
                            result = false;
                        }
                        else
                        {
                            result = true;
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
                //Log exception
                //Display Error message
            }
            return(result);
        }
示例#10
0
        public static string[] Get_SubInformation(string dbname, string PID, int UID)
        {
            //string temp = "";
            string[] result = new string[5];
            //string[] temp_WID = input[0].Split(',');
            //int count = 0;
            int[]  UpperWID      = new int[5];
            string Select_string = "Select EWID,UpperWID,SortNum,ENumber,LastENumber from EBudget_WBS where pid=" + PID + " Order by order_Num";

            try
            {
                using (SqlConnection conn =
                           new SqlConnection(DBconnection.connect_string(dbname)))
                {
                    conn.Open();

                    using (SqlCommand cmd =
                               new SqlCommand(Select_string, conn))
                    {
                        using (var reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result[0] += reader.GetInt32(0).ToString() + ",";
                                if (reader.IsDBNull(1))
                                {
                                    result[1] += "0,";
                                }
                                else
                                {
                                    result[1] += reader.GetInt32(1).ToString() + ",";
                                }
                                if (reader.IsDBNull(2))
                                {
                                    result[2] += "0,";
                                }
                                else
                                {
                                    result[2] += reader.GetInt32(2).ToString() + ",";
                                }
                                if (reader.IsDBNull(3))
                                {
                                    result[3] += "0,";
                                }
                                else
                                {
                                    result[3] += reader.GetDecimal(3).ToString() + ",";
                                }
                                if (reader.IsDBNull(4))
                                {
                                    result[4] += "0,";
                                }
                                else
                                {
                                    result[4] += reader.GetDecimal(4).ToString() + ",";
                                }
                            }
                        }
                    }

                    conn.Close();
                }
            }
            catch (SqlException ex)
            {
                Console.Write(ex.ToString());
            }

            return(result);
        }