Ejemplo n.º 1
0
        private void BindPin()
        {
            cNews   oNew        = new cNews();
            DataSet ds          = new DataSet();
            string  strMessage  = string.Empty;
            string  strCriteria = string.Empty;
            string  strActive   = string.Empty;

            strCriteria = strCriteria + "  And  c_active ='Y' And new_status = 'P'  Order by d_created_date desc";
            try
            {
                if (!oNew.SP_NEW_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    RpPin.DataSource = ds.Tables[0];
                    RpPin.DataBind();
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oNew.Dispose();
                ds.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void BindGridView(int nPageNo)
        {
            cNews   oNews       = new cNews();
            DataSet ds          = new DataSet();
            string  strMessage  = string.Empty;
            string  strCriteria = string.Empty;

            if (!txtCetreria.Equals(""))
            {
                strCriteria = strCriteria + "  And  (new_title like '%" + txtCetreria.Text.Trim() + "%') ";
            }


            try
            {
                if (!oNews.SP_NEW_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oNews.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
Ejemplo n.º 3
0
        private void BindData(int nNew_id)
        {
            cNews   oNews       = new cNews();
            DataSet ds          = new DataSet();
            string  strMessage  = string.Empty;
            string  strCriteria = string.Empty;

            strCriteria = strCriteria + "  And  (new_id =" + nNew_id + ") ";
            try
            {
                if (!oNews.SP_NEW_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    ltlNew_title.Text = ds.Tables[0].Rows[0]["new_title"].ToString();
                    ltlNew_date.Text  = ds.Tables[0].Rows[0]["d_created_date"].ToString();
                    //N = Normal , P = Pin , Q = Quick
                    if (ds.Tables[0].Rows[0]["new_status"].ToString() == "N")
                    {
                        ltlNew_status.Text = "ข่าวทั่วไป";
                    }
                    else if (ds.Tables[0].Rows[0]["new_status"].ToString() == "Q")
                    {
                        ltlNew_status.Text      = "ข่าวด่วน";
                        ltlNew_status.ForeColor = System.Drawing.Color.Red;
                    }
                    else if (ds.Tables[0].Rows[0]["new_status"].ToString() == "P")
                    {
                        ltlNew_status.Text = "ปักหมุด";
                    }

                    ltlNew_des.Text = ds.Tables[0].Rows[0]["new_des"].ToString();
                    if (ds.Tables[0].Rows[0]["new_des"].ToString() != "")
                    {
                        lblNew_file_name.Text        = ds.Tables[0].Rows[0]["new_file_name"].ToString();
                        lblNew_file_name.NavigateUrl = "";
                    }
                    lblNew_file_name.NavigateUrl = "~/new_attach/" + ds.Tables[0].Rows[0]["new_file_name"].ToString();;
                    ltlNew_by.Text = ds.Tables[0].Rows[0]["c_created_by"].ToString();
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oNews.Dispose();
                ds.Dispose();
            }
        }
Ejemplo n.º 4
0
        private void BindGridView(int nPageNo)
        {
            cNews   oNews          = new cNews();
            DataSet ds             = new DataSet();
            string  strMessage     = string.Empty;
            string  strCriteria    = string.Empty;
            string  strNews_title  = string.Empty;
            string  strNews_status = string.Empty;
            string  strNews_type   = string.Empty;
            string  strActive      = string.Empty;
            string  strnews_year   = string.Empty;

            strNews_title  = txtNew_title.Text;
            strNews_status = cboNew_status.SelectedValue;
            strNews_type   = cboNew_type.SelectedValue;

            if (!strNews_title.Equals(""))
            {
                strCriteria = strCriteria + "  And  (new_title like '%" + strNews_title + "%') ";
            }
            if (!strNews_type.Equals(""))
            {
                strCriteria = strCriteria + "  And  (new_type like '%" + strNews_type + "%')";
            }
            if (!strNews_status.Equals(""))
            {
                strCriteria = strCriteria + "  And  (new_status = '" + strNews_status + "') ";
            }

            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }

            try
            {
                if (!oNews.SP_NEW_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oNews.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
Ejemplo n.º 5
0
        private void setData()
        {
            cNews   oNews = new cNews();
            DataSet ds = new DataSet();
            string  strMessage = string.Empty, strCriteria = string.Empty;
            string  strnew_id         = string.Empty,
                    strnews_file_name = string.Empty,
                    strnews_title     = string.Empty,
                    strnews_des       = string.Empty,
                    strnews_type      = string.Empty,
                    strnews_status    = string.Empty,
                    strC_active       = string.Empty,
                    strCreatedBy      = string.Empty,
                    strUpdatedBy      = string.Empty,
                    strCreatedDate    = string.Empty,
                    strUpdatedDate    = string.Empty;

            try
            {
                strCriteria = " and new_id = " + ViewState["new_id"].ToString() + " ";
                if (!oNews.SP_NEW_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        #region get Data
                        strnew_id         = ds.Tables[0].Rows[0]["new_id"].ToString();
                        strnews_title     = ds.Tables[0].Rows[0]["new_title"].ToString();
                        strnews_des       = ds.Tables[0].Rows[0]["new_des"].ToString();
                        strnews_type      = ds.Tables[0].Rows[0]["new_type"].ToString();
                        strnews_status    = ds.Tables[0].Rows[0]["new_status"].ToString();
                        strnews_file_name = ds.Tables[0].Rows[0]["new_file_name"].ToString();
                        strC_active       = ds.Tables[0].Rows[0]["c_active"].ToString();
                        strCreatedBy      = ds.Tables[0].Rows[0]["c_created_by"].ToString();
                        strUpdatedBy      = ds.Tables[0].Rows[0]["c_updated_by"].ToString();
                        strCreatedDate    = ds.Tables[0].Rows[0]["d_created_date"].ToString();
                        strUpdatedDate    = ds.Tables[0].Rows[0]["d_updated_date"].ToString();
                        #endregion

                        #region set Control
                        ViewState["new_id"]         = strnew_id;
                        txtnew_title.Text           = strnews_title;
                        txtnew_des.Text             = strnews_title;
                        cboNew_type.SelectedValue   = strnews_type;
                        cboNew_status.SelectedValue = strnews_status;
                        txtnews_file_name.Text      = strnews_file_name;

                        if (strC_active.Equals("Y"))
                        {
                            chkStatus.Checked = true;
                        }
                        else
                        {
                            chkStatus.Checked = false;
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
Ejemplo n.º 6
0
        private bool saveData()
        {
            bool   blnResult          = false;
            bool   blnDup             = false;
            string strMessage         = string.Empty;
            string strActive          = string.Empty,
                   strCreatedBy       = string.Empty,
                   strUpdatedBy       = string.Empty;
            string  strScript         = string.Empty;
            string  strnews_id        = "0";
            string  strnews_file_name = string.Empty;
            cNews   oNews             = new cNews();
            DataSet ds = new DataSet();

            try
            {
                #region set Data
                if (txtnews_file_name.Text.Length > 0)
                {
                    strnews_file_name = txtnews_file_name.Text;
                }

                if (chkStatus.Checked == true)
                {
                    strActive = "Y";
                }
                else
                {
                    strActive = "N";
                }
                strCreatedBy = Session["username"].ToString();
                strUpdatedBy = Session["username"].ToString();
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    #region edit
                    if (!blnDup)
                    {
                        if (oNews.SP_NEW_UPD(ViewState["new_id"].ToString(), txtnew_title.Text, txtnew_des.Text, cboNew_type.SelectedValue, cboNew_status.SelectedValue, strnews_file_name, "", strActive, strUpdatedBy, ref strMessage))
                        {
                            blnResult = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true);
                    }
                    #endregion
                }
                else
                {
                    #region insert
                    if (!blnDup)
                    {
                        if (oNews.SP_NEW_INS(txtnew_title.Text, txtnew_des.Text, cboNew_type.SelectedValue, cboNew_status.SelectedValue, strnews_file_name, "", strActive, strCreatedBy, ref strMessage))
                        {
                            string strGetcode = " and new_title = '" + txtnew_title.Text + "' ";
                            if (!oNews.SP_NEW_SEL(strGetcode, ref ds, ref strMessage))
                            {
                                lblError.Text = strMessage;
                            }
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                strnews_id = ds.Tables[0].Rows[0]["new_id"].ToString();
                            }
                            ViewState["news_id"] = strnews_id;
                            blnResult            = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oNews.Dispose();
            }
            return(blnResult);
        }