// select all Equipment data from ST_EQUIPMENT_DATA
        public DsPSMS.ST_EQUIPMENT_DATADataTable selectAllEquipData()
        {
            DsPSMS.ST_EQUIPMENT_DATADataTable stuEquipDataDt = new DsPSMS.ST_EQUIPMENT_DATADataTable();
            Open();
            query = "SELECT* FROM ST_EQUIPMENT_DATA WHERE DEL_FLG = " + 0;
            SqlCommand     cmd = new SqlCommand(query, conn);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);

            da.Fill(stuEquipDataDt);
            Close();
            return(stuEquipDataDt);
        }
        protected void BtnConfirm_Click(object sender, EventArgs e)
        {
            DsPSMS.ST_EQUIPMENT_DATARow equipDr = new DsPSMS.ST_EQUIPMENT_DATADataTable().NewST_EQUIPMENT_DATARow();
            if (CoboYear1.Text.Trim().Length != 0)
            {
                equipDr.EDU_YEAR = CoboYear1.Text;
                equipDr.ID       = Convert.ToInt32(EqpList.SelectedRow.Cells[1].Text);
                if (CoboEquipName.Text.Trim().Length != 0)
                {
                    equipDr.EQUIPMENT_ID = CoboEquipName.Text;
                    if (EqpDate.Text.Trim().Length != 0)
                    {
                        equipDr.DATE = Convert.ToDateTime(EqpDate.Text);
                        if (TxtQty.Text.Trim().Length != 0)
                        {
                            equipDr.QUANTITY    = TxtQty.Text;
                            equipDr.TYPE        = TxtType.Text;
                            equipDr.REMARK      = TxtRemark.Text;
                            equipDr.UPD_DT_TM   = DateTime.Now;
                            equipDr.UPD_USER_ID = this.userId;

                            equipService.editEquipmentData(equipDr, out msg);
                            showGd();

                            // CoboEquipName.Text = "";
                            CoboYear1.Text = "";
                            EqpDate.Text   = "";
                            TxtQty.Text    = "";
                            TxtType.Text   = "";
                            TxtRemark.Text = "";
                        }
                        else
                        {
                            errQty.Text = "Please Enter the quantity";
                        }
                    }
                    else
                    {
                        errDate.Text = "Please choose the date";
                    }
                }
                else
                {
                    errEqN.Text = "Please choose Equipment Name";
                }
            }
            else
            {
                errYear.Text = "Please choose the year";
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DsPSMS.ST_EQUIPMENT_DATADataTable equipDt = new DsPSMS.ST_EQUIPMENT_DATADataTable();
            DsPSMS.ST_EQUIPMENT_DATARow       equipDr = new DsPSMS.ST_EQUIPMENT_DATADataTable().NewST_EQUIPMENT_DATARow();

            if (CoboYear1.Text.Trim().Length != 0)
            {
                equipDr.EDU_YEAR = CoboYear1.Text;
                if (CoboEquipName.Text.Trim().Length != 0)
                {
                    equipDr.EQUIPMENT_ID = CoboEquipName.Text;
                    if (EqpDate.Text.Trim().Length != 0)
                    {
                        equipDr.DATE = Convert.ToDateTime(EqpDate.Text);
                        if (TxtQty.Text.Trim().Length != 0)
                        {
                            equipDr.QUANTITY    = TxtQty.Text;
                            equipDr.TYPE        = TxtType.Text;
                            equipDr.REMARK      = TxtRemark.Text;
                            equipDr.CRT_DT_TM   = DateTime.Now;
                            equipDr.CRT_USER_ID = this.userId;
                            equipDr.UPD_DT_TM   = DateTime.Now;
                            equipDr.UPD_USER_ID = "";

                            equipService.SaveEquipmentData(equipDr, out msg);
                            showGd();
                        }
                        else
                        {
                            errQty.Text = "Please Enter the quantity";
                        }
                    }
                    else
                    {
                        errDate.Text = "Please choose the date";
                    }
                }
                else
                {
                    errEqN.Text = "Please choose Equipment Name";
                }
            }
            else
            {
                errYear.Text = "Please choose the year";
            }
            // EqmMstEntPannel.Visible = true;
        }
 protected void showGd()
 {
     DsPSMS.ST_EQUIPMENT_DATADataTable equipDt = new DsPSMS.ST_EQUIPMENT_DATADataTable();
     //binding Equipment data to datagridview
     equipDt = equipService.getAllEquipData(out msg);
     if (equipDt != null && equipDt.Rows.Count != 0)
     {
         equipDt.Columns.Remove(equipDt.Columns[7]);
         equipDt.Columns.Remove(equipDt.Columns[7]);
         equipDt.Columns.Remove(equipDt.Columns[7]);
         equipDt.Columns.Remove(equipDt.Columns[7]);
         equipDt.Columns.Remove(equipDt.Columns[7]);
         EqpList.DataSource = equipDt;
         EqpList.DataBind();
     }
     // EqpList.Columns.[1].Visible = false;
 }
        protected void Delete_Click(object sender, EventArgs e)
        {
            DsPSMS.ST_EQUIPMENT_DATARow equipDr = new DsPSMS.ST_EQUIPMENT_DATADataTable().NewST_EQUIPMENT_DATARow();
            if (EqpList.SelectedIndex < 0)
            {
                errgrid.Text = "Please select the record that you want to delete";
            }
            else
            {
                equipDr.ID = Convert.ToInt32(EqpList.SelectedRow.Cells[1].Text);
                //to write for confirm message
                equipService.removeEquipmentData(equipDr, out msg);
                DataTable ds = new DataTable();
                ds = null;
                EqpList.DataSource = ds;
                EqpList.DataBind();

                showGd();
            }
        }
        public DataSet.DsPSMS.ST_EQUIPMENT_DATADataTable getAllEquipData(out string msg)
        {
            DsPSMS.ST_EQUIPMENT_DATADataTable EqDataDt = new DsPSMS.ST_EQUIPMENT_DATADataTable();

            try
            {
                Open();
                EqDataDt = equipDb.selectAllEquipData();
                msg      = "Have data";
            }
            catch
            {
                msg = "error occurs when selecting the all equipment data";
                return(null);
            }
            finally
            {
                Close();
            }

            return(EqDataDt);
        }