Ejemplo n.º 1
0
        public void edit(int ID, float CF1, float CF2, float CF3, float CF4, float CF5, float CF6, float CF7, float CF8, float CF9)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[RW_CF_MASTER]" +
                         "SET [ID] = '" + ID + "'" +
                         ",[CF1] = '" + CF1 + "'" +
                         ",[CF2] = '" + CF2 + "'" +
                         ",[CF3] = '" + CF3 + "'" +
                         ",[CF4] = '" + CF4 + "'" +
                         ",[CF5] = '" + CF5 + "'" +
                         ",[CF6] = '" + CF6 + "'" +
                         ",[CF7] = '" + CF7 + "'" +
                         ",[CF8] = '" + CF8 + "'" +
                         ",[CF9] = '" + CF9 + "'" +

                         " WHERE [ID] = '" + ID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Ejemplo n.º 2
0
        public List <int[]> getCheckAddExcel_ID(int comID, int eqID)
        {
            List <int[]> temp = new List <int[]>();

            int[]         data = new int[2];
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "SELECT AddByExcel,ID FROM rbi.dbo.RW_ASSESSMENT WHERE EquipmentID = '" + eqID + "' AND ComponentID='" + comID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            data[0] = Convert.ToInt32(reader.GetBoolean(0));
                            data[1] = reader.GetInt32(1);
                            temp.Add(data);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(temp);
        }
Ejemplo n.º 3
0
        public List <int> getIDbyCoverageID(int CoverageID)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            List <int> list = new List <int>();
            int        ID   = 0;
            String     sql  = "Use [rbi]" +
                              "SELECT [ID]" +
                              "From [dbo].[INSPECTION_COVERAGE_DETAIL] where CoverageID = '" + CoverageID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            ID = (int)reader.GetInt64(0);
                        }
                        list.Add(ID);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(list);
        }
        public bool CheckExistID(int ID)
        {
            Boolean       IsExist = false;
            SqlConnection conn    = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "SELECT Hydraulic_Water FROM rbi.dbo.RW_CA_TANK WHERE ID = '" + ID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.IsDBNull(0))
                        {
                            IsExist = false;
                        }
                        else
                        {
                            IsExist = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(IsExist);
        }
Ejemplo n.º 5
0
        public void Edit(int ID, float FLUID_HEIGHT, float SHELL_COURSE_HEIGHT, float TANK_DIAMETTER, int Prevention_Barrier, String Environ_Sensitivity, float P_lvdike, float P_onsite, float P_offsite, String Soil_Type, String TANK_FLUID, String API_FLUID, float SW, float ProductionCost)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi] " +
                         "UPDATE [dbo].[RW_INPUT_CA_TANK] " +
                         " SET [FLUID_HEIGHT] = '" + FLUID_HEIGHT + "' " +
                         ",[SHELL_COURSE_HEIGHT] = '" + SHELL_COURSE_HEIGHT + "' " +
                         ",[TANK_DIAMETTER] = '" + TANK_DIAMETTER + "' " +
                         ",[Prevention_Barrier] = '" + Prevention_Barrier + "' " +
                         ",[Environ_Sensitivity] = '" + Environ_Sensitivity + "' " +
                         ",[P_lvdike] = '" + P_lvdike + "' " +
                         ",[P_onsite] = '" + P_onsite + "' " +
                         ",[P_offsite] = '" + P_offsite + "' " +
                         ",[Soil_Type] = '" + Soil_Type + "' " +
                         ",[TANK_FLUID] = '" + TANK_FLUID + "' " +
                         ",[API_FLUID] = '" + API_FLUID + "' " +
                         ",[SW] = '" + SW + "' " +
                         ",[ProductionCost] = '" + ProductionCost + "' " +
                         " WHERE [ID] = '" + ID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("EDIT FAIL!", "ERROR!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Ejemplo n.º 6
0
        public Boolean checkExistAssessment(int ID)
        {
            Boolean       IsExist = false;
            SqlConnection conn    = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "select AssessmentDate from rbi.dbo.RW_ASSESSMENT where ID = '" + ID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.IsDBNull(0))
                        {
                            IsExist = false;
                        }
                        else
                        {
                            IsExist = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(IsExist);
        }
Ejemplo n.º 7
0
        public void edit(int ID, double FCoFValue, String FCoFCategory, int AIL, double envcost, double equipcost, double prodcost, double popdens, double injcost, double FCoFMatrixValue)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[RW_FULL_FCOF]" +
                         "SET [ID] = '" + ID + "'" +
                         ",[FCoFValue] = '" + FCoFValue + "'" +
                         ",[FCoFCategory] = '" + FCoFCategory + "'" +
                         ",[AIL] = '" + AIL + "'" +
                         ",[envcost] = '" + envcost + "'" +
                         ",[equipcost] = '" + equipcost + "'" +
                         ",[prodcost] = '" + prodcost + "'" +
                         ",[popdens] = '" + popdens + "'" +
                         ",[injcost] = '" + injcost + "'" +
                         ",[FCoFMatrixValue] = '" + FCoFMatrixValue + "'" +

                         " WHERE [ID] = '" + ID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
        public void add(int DMItemID, String DMDescription, int DMSeq, int DMCategoryID, String DMCode, int HasDF, String FailureMode)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi] " +
                         " INSERT INTO[dbo].[DM_ITEMS]" +
                         "([DMItemID]" +
                         ",[DMDescription]" +
                         ",[DMSeq]" +
                         ",[DMCategoryID]" +
                         ",[DMCode]" +
                         ",[HasDF]" +
                         ",[FailureMode])" +
                         "VALUES" +
                         "('" + DMItemID + "'" +
                         ",'" + DMDescription + "'" +
                         ",'" + DMSeq + "'" +
                         ",'" + DMCategoryID + "'" +
                         ",'" + DMCode + "'" +
                         ",'" + HasDF + "'" +
                         ",'" + FailureMode + "')";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "ADD FAIL!");
            }
            finally
            {
                conn.Close();
            }
        }
        public void add(String UserID, String Category, String Permission, int Allowed,
                        String Type, int Active)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         "INSERT INTO [dbo].[USER_PERMISSONS]" +
                         "([UserID]" +
                         ",[Category]" +
                         ",[Permission]" +
                         ",Allowed]" +
                         ",[Type]" +
                         ",[Active])" +
                         " VALUES" +
                         "( '" + UserID + "'" +
                         ", '" + Category + "'" +
                         ", '" + Permission + "'" +
                         ", '" + Allowed + "'" +
                         ", '" + Type + "'" +
                         ", '" + Active + "')";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = sql;
                cmd.Connection  = conn;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "ADD FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Ejemplo n.º 10
0
        // dung file get data
        // dung file get list( data source)
        public List <SITES> getDataSource()
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            List <SITES> list = new List <SITES>();
            SITES        obj  = null;
            String       sql  = "SELECT [SiteID],[SiteName] FROM [rbi].[dbo].[SITES]";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj          = new SITES();
                            obj.SiteID   = reader.GetInt32(0);
                            obj.SiteName = reader.GetString(1);
                            list.Add(obj);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(list);
        }
Ejemplo n.º 11
0
        public String getAPIComponentTypeName(int APIID)
        {
            String        APIName = "";
            SqlConnection con     = MSSQLDBUtils.GetDBConnection();

            con.Open();
            String sql = "SELECT APIComponentTypeName FROM [rbi].[dbo].[API_COMPONENT_TYPE] WHERE APIComponentTypeID = '" + APIID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = sql;
                cmd.Connection  = con;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            if (!reader.IsDBNull(0))
                            {
                                APIName = reader.GetString(0);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Get FMS Fail------->" + ex.ToString(), "Get Data Fail");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
            return(APIName);
        }
Ejemplo n.º 12
0
        public void edit(int PointID, String PointName, int ComponentID, float CorrosionRate, float NominalThickness, float MinReqThickness, float ThicknessCurrent, float ThicknessPrevious, DateTime DateCurrent, DateTime DatePrevious)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[POINTS]" +
                         "SET [PointName] = '" + PointName + "'" +
                         ",[ComponentID] = '" + ComponentID + "'" +
                         ",[CorrosionRate] = '" + CorrosionRate + "'" +
                         ",[NominalThickness] = '" + NominalThickness + "'" +
                         ",[MinReqThickness] = '" + MinReqThickness + "'" +
                         ",[ThicknessCurrent] = '" + ThicknessCurrent + "'" +
                         ",[ThicknessPrevious] = '" + ThicknessPrevious + "'" +
                         ",[DateCurrent] = '" + DateCurrent + "'" +
                         ",[DatePrevious] = '" + DatePrevious + "'" +

                         "WHERE [PointID] ='" + PointID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
        public void add(int ID, double CoFValue, String CoFCategory, double ProdCost, double CoFMatrixValue)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "INSERT INTO [dbo].[RW_FULL_COF_TANK]" +
                         "([ID]" +
                         ",[CoFValue]" +
                         ",[CoFCategory]" +
                         ",[ProdCost]" +
                         ",[CoFMatrixValue])" +
                         "VALUES" +
                         "('" + ID + "'" +
                         ",'" + CoFValue + "'" +
                         ",'" + CoFCategory + "'" +
                         ",'" + ProdCost + "'" +
                         ",'" + CoFMatrixValue + "')" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "ADD FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
        public int getIDbyName(String name)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            int    ID  = 0;
            String sql = "Use [rbi]" +
                         "SELECT [SiteID]" +
                         ",[SiteName]" +
                         "  FROM [rbi].[dbo].[SITES] WHERE [SiteName] = '" + name + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            ID = reader.GetInt32(0);
                        }
                    }
                }
            }
            catch
            {
                ID = 0;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(ID);
        }
        public void edit(int ID, double Minus12ToMinus8, double Minus8ToPlus6, double Plus6ToPlus32, double Plus32ToPlus71, double Plus71ToPlus107, double Plus107ToPlus121, double Plus121ToPlus135, double Plus135ToPlus162, double Plus162ToPlus176, double MoreThanPlus176)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[RW_EXTCOR_TEMPERATURE]" +
                         "SET [ID] = '" + ID + "'" +
                         ",[Minus12ToMinus8] = '" + Minus12ToMinus8 + "'" +
                         ",[Minus8ToPlus6] = '" + Minus8ToPlus6 + "'" +
                         ",[Plus6ToPlus32] = '" + Plus6ToPlus32 + "'" +
                         ",[Plus32ToPlus71] = '" + Plus32ToPlus71 + "'" +
                         ",[Plus71ToPlus107] = '" + Plus71ToPlus107 + "'" +
                         ",[Plus107ToPlus121] = '" + Plus107ToPlus121 + "'" +
                         ",[Plus121ToPlus135] = '" + Plus121ToPlus135 + "'" +
                         ",[Plus135ToPlus162] = '" + Plus135ToPlus162 + "'" +
                         ",[Plus162ToPlus176] = '" + Plus162ToPlus176 + "'" +
                         ",[MoreThanPlus176] = '" + MoreThanPlus176 + "'" +
                         " WHERE [ID] = '" + ID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
            }
        }
        public void edit(int TemplateID, String TemplateName, String TemplateDescription, String OriginalFile, String ReportIdentifier, String ReportID, String ReportType, String ReportVersion, int Predefined, byte[] TemplateBinary)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[REPORT_TEMPLATE]" +
                         "SET [TemplateName] = '" + TemplateName + "'" +
                         ",[TemplateDescription] = '" + TemplateDescription + "'" +
                         ",[OriginalFile] = '" + OriginalFile + "'" +
                         ",[ReportIdentifier] = '" + ReportIdentifier + "'" +
                         ",[ReportID] = '" + ReportID + "'" +
                         ",[ReportType] = '" + ReportType + "'" +
                         ",[ReportVersion] = '" + ReportVersion + "'" +
                         ",[Predefined] = '" + Predefined + "'" +
                         ",[TemplateBinary] = '" + TemplateBinary + "'" +

                         "WHERE [TemplateID] = '" + TemplateID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Ejemplo n.º 17
0
        public void edit(int ID, double CoFValue, String CoFCategory, double ProdCost, float EquipOutageMultiplier, float equipcost, float popdens, float injcost, double CoFMatrixValue)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " " +
                         "UPDATE [dbo].[RW_FULL_COF_TANK]" +
                         "SET [ID] = '" + ID + "'" +
                         ",[CoFValue] = '" + CoFValue + "'" +
                         ",[CoFCategory] = '" + CoFCategory + "'" +
                         ",[ProdCost] = '" + ProdCost + "'" +
                         ",[EquipOutageMultiplier] = '" + EquipOutageMultiplier + "'" +
                         ",[equipcost] = '" + equipcost + "'" +
                         ",[popdens] = '" + popdens + "'" +
                         ",[injcost] = '" + injcost + "'" +
                         ",[CoFMatrixValue] = '" + CoFMatrixValue + "'" +
                         " WHERE [ID] = '" + ID + "'" +
                         " ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
                //MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Ejemplo n.º 18
0
        public int getIDbyName(String EquipmentTypeName)
        {
            int           ID   = 0;
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         "SELECT [EquipmentTypeID]" +
                         ",[EquipmentTypeCode]" +
                         ",[EquipmentTypeName]" +
                         "FROM [rbi].[dbo].[EQUIPMENT_TYPE] WHERE [EquipmentTypeName] ='" + EquipmentTypeName + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            ID = reader.GetInt32(0);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("GET DATA SOURCE FAIL!");
            }
            finally
            {
                conn.Close();
            }
            return(ID);
        }
Ejemplo n.º 19
0
        public Boolean checkExistDamageMechanism(int ID, int DM_ID)
        {
            Boolean       IsExist = false;
            SqlConnection conn    = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "select IsActive from rbi.dbo.RW_DAMAGE_MECHANISM where ID = '" + ID + "' and DMItemID = '" + DM_ID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.IsDBNull(0))
                        {
                            IsExist = false;
                        }
                        else
                        {
                            IsExist = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
            }
            return(IsExist);
        }
Ejemplo n.º 20
0
        // lay ra maxInspec Eff
        public String getMaxInspEffec(int CompID, int DMItemID)
        {
            String        eff = "E";
            SqlConnection con = MSSQLDBUtils.GetDBConnection();

            con.Open();
            String sql = "SELECT MIN([EffectivenessCode]) FROM [rbi].[dbo].[RW_INSPECTION_DETAIL] WHERE [ComponentID] = '" + CompID + "' and [DMItemID] = '" + DMItemID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = sql;
                cmd.Connection  = con;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            if (!reader.IsDBNull(0))
                            {
                                eff = reader.GetString(0);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("get Data inspection fail" + ex.ToString(), "Cortek");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
            return(eff);
        }
        public void edit(int ID, float LF1Factor, float LF4Factor, float LF5Factor, float LF6Factor, float LF7Factor, float LF1, float LF4, float LF5, float LF6, float LF7)

        {
            {
                SqlConnection conn = MSSQLDBUtils.GetDBConnection();
                conn.Open();
                String sql = "USE [rbi]" +
                             "UPDATE [dbo].[RW_LF_MASTER] " +
                             "SET[ID] = '" + ID + "'" +
                             ",[LF1Factor] = '" + LF1Factor + "'" +
                             ",[LF4Factor] = '" + LF4Factor + "'" +
                             ",[LF5Factor] = '" + LF5Factor + "'" +
                             ",[LF6Factor] = '" + LF6Factor + "'" +
                             ",[LF7Factor] = '" + LF7Factor + "'" +
                             ",[LF1] = '" + LF1 + "'" +
                             ",[LF4] = '" + LF4 + "'" +
                             ",[LF5] = '" + LF5 + "'" +
                             ",[LF6] = '" + LF6 + "'" +
                             ",[LF7] = '" + LF7 + "'" +
                             " WHERE [ID] = '" + ID + "'";
                try
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandText = sql;
                    cmd.Connection  = conn;
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "EDIT FAIL!");
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Ejemplo n.º 22
0
        public void add(int PlanID, int EquipmentID, int ComponentID, String Remarks, String Findings, String FindingRTF)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         "INSERT INTO [dbo].[INSPECTION_COVERAGE]" +
                         "([PlanID]" +
                         ",[EquipmentID]" +
                         ",[ComponentID]" +
                         ",[Remarks]" +
                         ",[Findings]" +
                         ",[FindingRTF])" +
                         "VALUES" +
                         "('" + PlanID + "'" +
                         ",'" + EquipmentID + "'" +
                         ",'" + ComponentID + "'" +
                         ",'" + Remarks + "'" +
                         ",'" + Findings + "'" +
                         ",'" + FindingRTF + "')";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "ADD FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
        public List <String> getDMDescription()
        {
            string        obj     = null;
            List <string> listobj = new List <string>();
            SqlConnection conn    = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = " Use [rbi] Select [DMDescription]" +
                         "From [rbi].[dbo].[DM_ITEMS]";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj = reader.GetString(0);
                            listobj.Add(obj);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(listobj);
        }
Ejemplo n.º 24
0
        public int getIDbyName(String name)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            int    ID  = 0;
            String sql = " Use [rbi] Select [ComponentTypeID]" +
                         ",[ComponentTypeName]" +
                         ",[ComponentTypeCode]" +
                         "From [rbi].[dbo].[COMPONENT_TYPE] WHERE [ComponentTypeName] = '" + name + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            ID = reader.GetInt32(0);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(ID);
        }
Ejemplo n.º 25
0
        public int getIDbyName(String name)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            int    ID  = 0;
            String sql = " Use [rbi] Select [DesignCodeID]" +
                         ",[DesignCode]" +
                         ",[DesignCodeApp]" +
                         "From [rbi].[dbo].[DESIGN_CODE] WHERE [DesignCode] ='" + name + "' ";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            ID = reader.GetInt32(0);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ID = 0;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(ID);
        }
Ejemplo n.º 26
0
        public void edit(int RevisionID, int CoverageDetailID, String ComponentNumber, int CoverageID, int DMItemID,
                         int IMTypeID, DateTime InspectionDate, String EffectivenessCode, int CarriedOut, DateTime CarriedOutDate)

        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi]" +
                         " UPDATE[dbo].[EQUIPMENT_REVISION_INSPECTION]" +
                         "SET[RevisionID] ='" + RevisionID + "'" +
                         ",[CoverageDetailID] ='" + CoverageDetailID + "'" +
                         ",[ComponentNumber] = '" + CoverageID + "'" +
                         ",[DMItemID] = '" + DMItemID + "'" +
                         ",[IMTypeID] = '" + IMTypeID + "'" +
                         ",[CoverageID] = '" + CoverageID + "'" +
                         ",[InspectionDate] = '" + InspectionDate + "'" +
                         ",[EffectivenessCode] = '" + EffectivenessCode + "'" +
                         ",[CarriedOut] = '" + CarriedOut + "'" +
                         ",[CarriedOutDate] = '" + CarriedOutDate + "'" +
                         "WHERE [RevisionID] ='" + RevisionID + "'" +
                         "AND [CoverageDetailID] ='" + CoverageDetailID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "EDIT FAIL!");
            }
            finally
            {
                conn.Close();
            }
        }
        public Boolean checkExist(String name)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            Boolean check = false;
            String  sql   = "Use [rbi]" +
                            "SELECT [SiteID]" +
                            ",[SiteName]" +
                            "  FROM [rbi].[dbo].[SITES] WHERE [SiteName] = '" + name + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            check = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(check);
        }
        public void edit(int ID, String FluidName, float NBP, float MW, float Density, int ChemicalFactor, int HealthDegree, int Flammability, int Reactivity)

        {
            {
                SqlConnection conn = MSSQLDBUtils.GetDBConnection();
                conn.Open();
                String sql = "USE [rbi]" +
                             "UPDATE [dbo].[RW_PRIMARY_FLUID] " +
                             "SET[ID] = '" + ID + "'" +
                             ",[FluidName] = '" + FluidName + "'" +
                             ",[NBP] = '" + NBP + "'" +
                             ",[MW] = '" + MW + "'" +
                             ",[Density] = '" + Density + "'" +
                             ",[ChemicalFactor] = '" + ChemicalFactor + "'" +
                             ",[HealthDegree] = '" + HealthDegree + "'" +
                             ",[Flammability] = '" + Flammability + "'" +
                             ",[Reactivity] = '" + Reactivity + "'" +


                             " WHERE [ID] = '" + ID + "'";
                try
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandText = sql;
                    cmd.Connection  = conn;
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "EDIT FAIL!");
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Ejemplo n.º 29
0
        public void delete(int ExtraFieldID)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi] DELETE FROM [dbo].[EXTRA_FIELDS_SETTING_COMPONENT] where [ExtraFieldID]='" + ExtraFieldID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "DELETE FAIL!");
            }
            finally
            {
                conn.Close();
            }
        }
        public void delete(int FileID)
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            String sql = "USE [rbi] DELETE FROM [dbo].[FILE_EQUIPMENT] WHERE [FileID] = '" + FileID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "DELETE FAIL!");
            }
            finally
            {
                conn.Close();
            }
        }