public bool Refresh(ref List <Web_page_FAQ> lstResult)
        {
            bool result = false;

            try
            {
                DataTable dt;
                if ((dt = DBHandler.selectDataBase(ref conn,
                                                   "`web_page_FAQ`",
                                                   "*",
                                                   string.Empty)) != null)
                {
                    lstResult = new List <Web_page_FAQ>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Web_page_FAQ item = new Web_page_FAQ()
                        {
                            id       = (long)dt.Rows[i]["id"],
                            question = (string)dt.Rows[i]["question"],
                            answer   = (string)dt.Rows[i]["answer"]
                        };
                        lstResult.Add(item);
                    }
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }
            return(result);
        }
示例#2
0
 private void Dv_SelectionChanged(object sender, EventArgs e)
 {
     if (dv.SelectedRows.Count == 1)
     {
         long id = (long)dv.SelectedRows[0].Cells["ID"].Value;
         selectedItem = result.Where(s => s.id == id).FirstOrDefault();
     }
 }
 public FAQActionView(FAQAction Action, ref FAQController Controller, Web_page_FAQ obj)
 {
     InitializeComponent();
     action     = Action;
     controller = Controller;
     Obj        = obj;
     this.Load += FAQActionView_Load;
 }
示例#4
0
 private void Dv_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         try
         {
             long id = (long)dv.Rows[e.RowIndex].Cells["ID"].Value;
             selectedItem = result.Where(s => s.id == id).FirstOrDefault();
         }
         catch { }
     }
 }
        public bool Update(Web_page_FAQ Obj)
        {
            bool result = false;

            try
            {
                if (DBHandler.updateDataBase(ref conn, "`web_page_FAQ`", "`question` = '" + Obj.question + "', `answer` = '" + Obj.answer + "'", "`id` = '" + Obj.id + "'"))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }

            return(result);
        }
示例#6
0
 private void Btn_Refresh_Click(object sender, EventArgs e)
 {
     result = null;
     if (controller.Refresh(ref result))
     {
         dv.Rows.Clear();
         dp.setObjCount(result.Count, 10);
         if (result.Count == 0)
         {
             Functions.ShowMessgeInfo("Không có dữ liệu nào phù hợp");
         }
         Functions.ShowMaiQuynhAnh();
     }
     else
     {
         Functions.ShowMessgeInfo("Search thất bại");
     }
     selectedItem = null;
 }
        public bool Delete(Web_page_FAQ Obj)
        {
            bool result = false;

            try
            {
                if (DBHandler.deleteDataBase(ref conn,
                                             "`web_page_FAQ`",
                                             "`id` = " + Obj.id))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }

            return(result);
        }
        public bool Add(Web_page_FAQ Obj)
        {
            bool result = false;

            try
            {
                if (DBHandler.insertDataBase(ref conn,
                                             "`web_page_FAQ`",
                                             "(`question`, `answer`)",
                                             "('" + Obj.question + "'," +
                                             "'" + Obj.answer + "')"))
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message);
            }
            return(result);
        }