コード例 #1
0
        public COMPONENT_MASTER getDataComponentMaster()
        {
            //cac so ID chua gan
            COMPONENT_MASTER compMaster = new COMPONENT_MASTER();

            compMaster.ComponentName     = txtComponentName.Text;
            compMaster.ComponentNumber   = txtComponentNumber.Text;
            compMaster.ComponentDesc     = txtDescription.Text;
            compMaster.IsEquipmentLinked = Convert.ToInt32(chkLinks.Checked);
            foreach (EQUIPMENT_MASTER e in listEquipment)
            {
                if (e.EquipmentNumber == cbEquipmentNumber.Text)
                {
                    compMaster.EquipmentID = e.EquipmentID;
                }
            }

            foreach (API_COMPONENT_TYPE a in listAPIComponent)
            {
                if (a.APIComponentTypeName == cbAPIComponentType.Text)
                {
                    compMaster.APIComponentTypeID = a.APIComponentTypeID;
                }
            }
            foreach (COMPONENT_TYPE c in listComponent)
            {
                if (c.ComponentTypeName == cbComponentType.Text)
                {
                    compMaster.ComponentTypeID = c.ComponentTypeID;
                }
            }
            return(compMaster);
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtComponentNumber.Text == "" || cbComponentType.Text == "" || cbAPIComponentType.Text == "")
            {
                return;
            }
            List <string> comNum = componentMaster_Bus.getAllComponentNumber();

            Console.WriteLine("jshdjksdh " + doubleEditClicked);
            foreach (string s in comNum)
            {
                if (s == txtComponentNumber.Text && s != oldName)
                {
                    MessageBox.Show("Component Number already exist!", "Cortek RBI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            ButtonOKClicked = true;
            if (doubleEditClicked)
            {
                COMPONENT_MASTER obj = getDataComponentMaster();
                componentMaster_Bus.edit(obj);
            }
            else
            {
                COMPONENT_MASTER obj = getDataComponentMaster();
                componentMaster_Bus.add(getDataComponentMaster());
            }
            this.Close();
        }
コード例 #3
0
        public List <COMPONENT_MASTER> getDataSource()
        {
            SqlConnection conn = MSSQLDBUtils.GetDBConnection();

            conn.Open();
            List <COMPONENT_MASTER> list = new List <COMPONENT_MASTER>();
            COMPONENT_MASTER        obj  = null;
            String sql = "USE [rbi] SELECT [ComponentID]" +
                         ",[ComponentNumber]" +
                         ",[EquipmentID]" +
                         ",[ComponentTypeID]" +
                         ",[ComponentName]" +
                         ",[ComponentDesc]" +
                         ",[IsEquipment]" +
                         ",[IsEquipmentLinked]" +
                         ",[APIComponentTypeID]" +
                         "  FROM [rbi].[dbo].[COMPONENT_MASTER]";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj                    = new COMPONENT_MASTER();
                            obj.ComponentID        = reader.GetInt32(0);
                            obj.ComponentNumber    = reader.GetString(1);
                            obj.EquipmentID        = reader.GetInt32(2);
                            obj.ComponentTypeID    = reader.GetInt32(3);
                            obj.ComponentName      = reader.GetString(4);
                            obj.ComponentDesc      = reader.GetString(5);
                            obj.IsEquipment        = reader.GetOrdinal("IsEquipment");
                            obj.IsEquipmentLinked  = reader.GetOrdinal("IsEquipmentLinked");
                            obj.APIComponentTypeID = reader.GetInt32(8);
                            list.Add(obj);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "GET DATA FAIL!");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
            return(list);
        }
コード例 #4
0
        public void showDatatoControl(int ID)
        {
            EQUIPMENT_TYPE_BUS     eqTypeBus          = new EQUIPMENT_TYPE_BUS();
            EQUIPMENT_MASTER_BUS   equipmentMasterBus = new EQUIPMENT_MASTER_BUS();
            DESIGN_CODE_BUS        designCodeBus      = new DESIGN_CODE_BUS();
            SITES_BUS              siteBus            = new SITES_BUS();
            FACILITY_BUS           facilityBus        = new FACILITY_BUS();
            MANUFACTURER_BUS       manuBus            = new MANUFACTURER_BUS();
            RW_ASSESSMENT_BUS      rwAssBus           = new RW_ASSESSMENT_BUS();
            COMPONENT_MASTER_BUS   comMaBus           = new COMPONENT_MASTER_BUS();
            COMPONENT_TYPE__BUS    comTypeBus         = new COMPONENT_TYPE__BUS();
            API_COMPONENT_TYPE_BUS apiComponentBus    = new API_COMPONENT_TYPE_BUS();

            int[]            equipmentID_componentID = rwAssBus.getEquipmentID_ComponentID(ID);
            EQUIPMENT_MASTER eqMa  = equipmentMasterBus.getData(equipmentID_componentID[0]);
            COMPONENT_MASTER comMa = comMaBus.getData(equipmentID_componentID[1]);
            RW_ASSESSMENT    ass   = rwAssBus.getData(ID);

            txtAssessmentName.Text      = ass.ProposalName;
            dateAssessmentDate.DateTime = ass.AssessmentDate;
            txtRiskAnalysisPeriod.Text  = ass.RiskAnalysisPeriod.ToString();

            txtEquipmentNumber.Text    = eqMa.EquipmentNumber;
            txtEquipmentType.Text      = eqTypeBus.getEquipmentTypeName(eqMa.EquipmentTypeID);
            txtSites.Text              = siteBus.getSiteName(eqMa.SiteID);
            txtDesignCode.Text         = designCodeBus.getDesignCodeName(eqMa.DesignCodeID);
            txtFacility.Text           = facilityBus.getFacilityName(eqMa.FacilityID);
            txtManufacturer.Text       = manuBus.getManuName(eqMa.ManufacturerID);
            dateComissionDate.DateTime = eqMa.CommissionDate;
            txtEquipmentName.Text      = eqMa.EquipmentName;
            txtProcessDesciption.Text  = eqMa.ProcessDescription;

            txtComponentNumber.Text           = comMa.ComponentNumber;
            txtComponentType.Text             = comTypeBus.getComponentTypeName(comMa.ComponentTypeID);
            txtAPIComponentType.Text          = apiComponentBus.getAPIComponentTypeName(comMa.APIComponentTypeID);
            txtComponentName.Text             = comMa.ComponentName;
            chkRiskLinksEquipmentRisk.Checked = comMa.IsEquipmentLinked == 1 ? true : false;
            for (int i = 0; i < itemsAssessmentMethod.Length; i++)
            {
                if (ass.AssessmentMethod == i)
                {
                    cbAsessmentMethod.SelectedIndex = i + 1;
                    break;
                }
            }
        }
コード例 #5
0
        public COMPONENT_MASTER getDataComponentMaster()
        {
            COMPONENT_MASTER compMaster = new COMPONENT_MASTER();

            if (doubleEditClicked)
            {
                compMaster.ComponentID = this.componentID;
            }
            compMaster.ComponentName     = txtComponentName.Text;
            compMaster.ComponentNumber   = txtComponentNumber.Text;
            compMaster.ComponentDesc     = txtDescription.Text;
            compMaster.IsEquipmentLinked = Convert.ToInt32(chkLinks.Checked);

            listEquipment = equipmentBus.getDataSource();
            foreach (EQUIPMENT_MASTER e in listEquipment)
            {
                if (e.EquipmentNumber == cbEquipmentNumber.Text)
                {
                    compMaster.EquipmentID = e.EquipmentID;
                }
            }

            listAPIComponent = API_BUS.getDataSource();
            foreach (API_COMPONENT_TYPE a in listAPIComponent)
            {
                if (a.APIComponentTypeName == cbAPIComponentType.Text)
                {
                    compMaster.APIComponentTypeID = a.APIComponentTypeID;
                }
            }

            listComponent = componentBus.getDataSource();
            foreach (COMPONENT_TYPE c in listComponent)
            {
                if (c.ComponentTypeName == cbComponentType.Text)
                {
                    compMaster.ComponentTypeID = c.ComponentTypeID;
                }
            }
            return(compMaster);
        }
コード例 #6
0
        public COMPONENT_MASTER getData(int comID)
        {
            COMPONENT_MASTER obj = new COMPONENT_MASTER();
            SqlConnection    con = MSSQLDBUtils.GetDBConnection();

            con.Open();
            String sql = "select ComponentNumber,ComponentTypeID,ComponentName,ComponentDesc,IsEquipmentLinked,APIComponentTypeID from rbi.dbo.COMPONENT_MASTER where ComponentID = '" + comID + "'";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = sql;
                cmd.Connection  = con;
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        if (reader.HasRows)
                        {
                            obj.ComponentNumber    = reader.GetString(0);
                            obj.ComponentTypeID    = reader.GetInt32(1);
                            obj.ComponentName      = reader.GetString(2);
                            obj.ComponentDesc      = reader.GetString(3);
                            obj.IsEquipmentLinked  = Convert.ToInt32(reader.GetBoolean(4));
                            obj.APIComponentTypeID = reader.GetInt32(5);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Get FMS Fail------->" + ex.ToString(), "Get Data Fail");
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
            return(obj);
        }
コード例 #7
0
        private void ShowDataToControl(int ID)
        {
            COMPONENT_MASTER com = componentMaster_Bus.getData(ID);
            int eqID             = componentMaster_Bus.getEquipmentID(ID);
            //Equipment Number
            List <string> eqNum = equipmentBus.getListEquipmentNumber();

            cbEquipmentNumber.Properties.Items.Clear();
            cbEquipmentNumber.Properties.Items.Add("", -1, -1);
            for (int i = 0; i < eqNum.Count; i++)
            {
                cbEquipmentNumber.Properties.Items.Add(eqNum[i], i, i);
                if (eqNum[i] == equipmentBus.getEquipmentNumber(eqID))
                {
                    cbEquipmentNumber.SelectedIndex = i + 1;
                }
            }
            cbEquipmentNumber.Enabled = false;
            //Equipment Type
            EQUIPMENT_TYPE_BUS eqTypeBus = new EQUIPMENT_TYPE_BUS();

            txtEquipmentType.Text     = eqTypeBus.getEquipmentTypeName(equipmentBus.getEquipmentTypeID(eqID));
            txtEquipmentType.ReadOnly = true;
            txtEquipmentType.Enabled  = false;
            //Sites
            cbSites.Properties.Items.Add(siteBus.getSiteName(equipmentBus.getSiteID(eqID)), 0, 0);
            cbSites.SelectedIndex = 0;
            cbSites.Enabled       = false;
            //Facility
            int faciID = equipmentBus.getFacilityID(eqID);

            cbFacility.Properties.Items.Add(facilityBus.getFacilityName(faciID), 0, 0);
            cbFacility.SelectedIndex = 0;
            cbFacility.Enabled       = false;
            //Component Number
            txtComponentNumber.Text = componentMaster_Bus.getComponentNumber(ID);

            //<lọc dữ liệu cho trường hợp tank>
            int _equipmentTypeID = equipmentBus.getEqTypeID(ID);

            if (_equipmentTypeID == 11)
            {
                string[] componentTypeName = { "Fixed Roof", "Floating Roof", "Shell", "Tank Bottom" };
                string[] APIcomp           = { "COURSE-1", "COURSE-10", "COURSE-2", "COURSE-3", "COURSE-4", "COURSE-5", "COURSE-6", "COURSE-7", "COURSE-8", "COURSE-9", "TANKBOTTOM" };
                cbComponentType.Properties.Items.Clear();
                cbComponentType.Properties.Items.Add("", -1, -1);
                for (int i = 0; i < componentTypeName.Length; i++)
                {
                    cbComponentType.Properties.Items.Add(componentTypeName[i], i, i);
                    if (componentTypeName[i] == componentBus.getComponentTypeName(componentMaster_Bus.getComponentTypeID(ID)))
                    {
                        cbComponentType.SelectedIndex = i + 1;
                    }
                }
                cbAPIComponentType.Properties.Items.Clear();
                cbAPIComponentType.Properties.Items.Add("", -1, -1);
                for (int i = 0; i < APIcomp.Length; i++)
                {
                    cbAPIComponentType.Properties.Items.Add(APIcomp[i], i, i);
                    if (APIcomp[i] == API_BUS.getAPIComponentTypeName(componentMaster_Bus.getAPIComponentTypeID(eqID)))
                    {
                        cbAPIComponentType.SelectedIndex = i + 1;
                    }
                }
            }
            else
            {
                //get data for API component
                listAPIComponent = API_BUS.getDataSource();
                cbAPIComponentType.Properties.Items.Clear();
                cbAPIComponentType.Properties.Items.Add("", -1, -1);
                for (int i = 0; i < listAPIComponent.Count; i++)
                {
                    cbAPIComponentType.Properties.Items.Add(listAPIComponent[i].APIComponentTypeName, i, i);
                    if (listAPIComponent[i].APIComponentTypeName == API_BUS.getAPIComponentTypeName(componentMaster_Bus.getAPIComponentTypeID(eqID)))
                    {
                        cbAPIComponentType.SelectedIndex = i + 1;
                    }
                }
                //get data for component type
                listComponent = componentBus.getDataSource();
                cbComponentType.Properties.Items.Clear();
                cbComponentType.Properties.Items.Add("", -1, -1);
                for (int i = 0; i < listComponent.Count; i++)
                {
                    cbComponentType.Properties.Items.Add(listComponent[i].ComponentTypeName, i, i);
                    if (listComponent[i].ComponentTypeName == componentBus.getComponentTypeName(componentMaster_Bus.getComponentTypeID(ID)))
                    {
                        cbComponentType.SelectedIndex = i + 1;
                    }
                }
            }
            //</lọc data cho tank>
            txtComponentName.Text = componentMaster_Bus.getComponentName(ID);
            chkLinks.Checked      = com.IsEquipmentLinked == 1 ? true : false;
            txtDescription.Text   = com.ComponentDesc;
        }
コード例 #8
0
 public void delete(COMPONENT_MASTER obj)
 {
     DAL.delete(obj.ComponentID);
 }
コード例 #9
0
 public void edit(COMPONENT_MASTER obj)
 {
     DAL.edit(obj.ComponentID, obj.ComponentNumber, obj.EquipmentID, obj.ComponentTypeID, obj.ComponentName, obj.ComponentDesc, obj.IsEquipment, obj.IsEquipmentLinked, obj.APIComponentTypeID);
 }
コード例 #10
0
        public void showDatatoControl(int ID)
        {
            EQUIPMENT_TYPE_BUS     eqTypeBus          = new EQUIPMENT_TYPE_BUS();
            EQUIPMENT_MASTER_BUS   equipmentMasterBus = new EQUIPMENT_MASTER_BUS();
            DESIGN_CODE_BUS        designCodeBus      = new DESIGN_CODE_BUS();
            SITES_BUS              siteBus            = new SITES_BUS();
            FACILITY_BUS           facilityBus        = new FACILITY_BUS();
            MANUFACTURER_BUS       manuBus            = new MANUFACTURER_BUS();
            RW_ASSESSMENT_BUS      rwAssBus           = new RW_ASSESSMENT_BUS();
            COMPONENT_MASTER_BUS   comMaBus           = new COMPONENT_MASTER_BUS();
            COMPONENT_TYPE__BUS    comTypeBus         = new COMPONENT_TYPE__BUS();
            API_COMPONENT_TYPE_BUS apiComponentBus    = new API_COMPONENT_TYPE_BUS();

            int[]            equipmentID_componentID = rwAssBus.getEquipmentID_ComponentID(ID);
            EQUIPMENT_MASTER eqMa  = equipmentMasterBus.getData(equipmentID_componentID[0]);
            COMPONENT_MASTER comMa = comMaBus.getData(equipmentID_componentID[1]);
            RW_ASSESSMENT    ass   = rwAssBus.getData(ID);

            txtAssessmentName.Text      = ass.ProposalName;
            dateAssessmentDate.DateTime = ass.AssessmentDate;
            txtRiskAnalysisPeriod.Text  = ass.RiskAnalysisPeriod.ToString();

            txtEquipmentNumber.Text    = eqMa.EquipmentNumber;
            txtEquipmentType.Text      = eqTypeBus.getEquipmentTypeName(eqMa.EquipmentTypeID);
            txtSites.Text              = siteBus.getSiteName(eqMa.SiteID);
            txtDesignCode.Text         = designCodeBus.getDesignCodeName(eqMa.DesignCodeID);
            txtFacility.Text           = facilityBus.getFacilityName(eqMa.FacilityID);
            txtManufacturer.Text       = manuBus.getManuName(eqMa.ManufacturerID);
            dateComissionDate.DateTime = eqMa.CommissionDate;
            txtEquipmentName.Text      = eqMa.EquipmentName;
            txtProcessDesciption.Text  = eqMa.ProcessDescription;

            txtComponentNumber.Text           = comMa.ComponentNumber;
            txtComponentType.Text             = comTypeBus.getComponentTypeName(comMa.ComponentTypeID);
            txtAPIComponentType.Text          = apiComponentBus.getAPIComponentTypeName(comMa.APIComponentTypeID);
            txtComponentName.Text             = comMa.ComponentName;
            chkRiskLinksEquipmentRisk.Checked = comMa.IsEquipmentLinked == 1 ? true : false;
            //foreach(RW_ASSESSMENT a in listAssessment)
            //{
            //    if(a.ID == ID)
            //    {
            //        txtAssessmentName.Text = a.ProposalName;
            //        ProposalName = a.ProposalName;
            //        dateAssessmentDate.DateTime = a.AssessmentDate;
            //        txtRiskAnalysisPeriod.Text = a.RiskAnalysisPeriod.ToString();
            //        foreach (EQUIPMENT_MASTER e in listEquipmentMaster)
            //        {
            //            if (e.EquipmentID == a.EquipmentID)
            //            {
            //                txtEquipmentNumber.Text = e.EquipmentNumber;
            //                dateComissionDate.DateTime = e.CommissionDate;
            //                txtEquipmentName.Text = e.EquipmentName;
            //                foreach (EQUIPMENT_TYPE t in listEquipmentType)
            //                {
            //                    if (t.EquipmentTypeID == e.EquipmentTypeID)
            //                        txtEquipmentType.Text = t.EquipmentTypeName;
            //                }
            //                foreach (DESIGN_CODE d in listDesignCode)
            //                {
            //                    if (d.DesignCodeID == e.DesignCodeID)
            //                        txtDesignCode.Text = d.DesignCode;
            //                }
            //                foreach (FACILITY f in listFacility)
            //                {
            //                    if (e.FacilityID == f.FacilityID)
            //                        txtFacility.Text = f.FacilityName;
            //                }
            //                foreach (SITES s in listSite)
            //                {
            //                    if (s.SiteID == e.SiteID)
            //                        txtSites.Text = s.SiteName;
            //                }
            //                foreach (MANUFACTURER m in listManu)
            //                {
            //                    if (m.ManufacturerID == e.ManufacturerID)
            //                        txtManufacturer.Text = m.ManufacturerName;
            //                }
            //            }
            //            break;
            //        }
            //        foreach (COMPONENT_MASTER c in listComMa)
            //        {
            //            if (c.ComponentID == a.ComponentID)
            //            {
            //                txtComponentNumber.Text = c.ComponentNumber;
            //                foreach (COMPONENT_TYPE t in listComponentType)
            //                {
            //                    if (c.ComponentTypeID == t.ComponentTypeID)
            //                    {
            //                        txtComponentType.Text = t.ComponentTypeName;
            //                    }
            //                }
            //                txtComponentName.Text = c.ComponentName;
            //                foreach (API_COMPONENT_TYPE a1 in listAPICom)
            //                {
            //                    if (a1.APIComponentTypeID == c.APIComponentTypeID)
            //                    {
            //                        txtAPIComponentType.Text = a1.APIComponentTypeName;
            //                    }
            //                }
            //            }
            //            break;
            //        }

            //}
            //foreach (RW_ASSESSMENT a in listAssessment)
            //{
            //    if (a.ID == assID)
            //    {
            //        txtAssessmentName.Text = a.ProposalName;
            //    }
            //}
            //đổ dữ liệu lên control cho Equipment
        }