def InsertFromGrid(self):
     try:
         cell_value = []
         row_index = self.m_gridSource.GetSelectedRows()[0]
         for i in range(0,3):
             cell_value.append(self.m_gridSource.GetCellValue(row_index,i))
         
         xldb =  Unit()
         Id =  str(cell_value[0])
         Ma =  str(cell_value[1])
         Ten =  str(cell_value[2])
         if Ma == "":
             return 0
        
         self.m_gridSource.AppendRows(1)
         kq = xldb.Insert(Ma,Ten)
         if kq>0:
             return 1
         else: 
             return 0
     except :
         return 0
 def m_btnThemOnButtonClick( self, event):
     kq = 0
     if self.CheckValid()==False:
         kq = self.InsertFromGrid()
         if(kq == 0):
             wx.MessageBox("Please fill all required fields","Messages",wx.OK|wx.ICON_WARNING)
             self.m_textunit_code.SetFocus()
             return
     else :
         Ma = self.m_textunit_code.GetValue()
         Ten = self.m_textunit_name.GetValue()
         # if(self.GetCountRow()>14):
         self.m_gridSource.AppendRows(1)
         xldb =  Unit()
         kq = xldb.Insert(Ma,Ten)
     if kq>0:
         self.OnLoadData()
         wx.MessageBox("Record added successfully","Messages",wx.OK|wx.ICON_INFORMATION)
         self.m_textunit_code.SetValue("")
         self.m_textunit_name.SetValue("")
     else: 
         wx.MessageBox("Error when trying add record","Messages",wx.OK|wx.ICON_WARNING)