public newsupdate SelectById(Int64 newsupdateid)
        {
            SqlDataAdapter da;
            DataSet        ds            = new DataSet();
            newsupdate     objnewsupdate = new newsupdate();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "newsupdate_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@newsupdateid", newsupdateid);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    objnewsupdate.newsupdateid = Convert.ToInt64(ds.Tables[0].Rows[0]["newsupdateid"]);
                                    objnewsupdate.title        = Convert.ToString(ds.Tables[0].Rows[0]["title"]);
                                    objnewsupdate.imagename    = Convert.ToString(ds.Tables[0].Rows[0]["imagename"]);
                                    objnewsupdate.shortdescp   = Convert.ToString(ds.Tables[0].Rows[0]["shortdescp"]);
                                    objnewsupdate.longdescp    = Convert.ToString(ds.Tables[0].Rows[0]["longdescp"]);
                                    objnewsupdate.newsdate     = Convert.ToString(ds.Tables[0].Rows[0]["newsdate"]);
                                    objnewsupdate.imagename2   = Convert.ToString(ds.Tables[0].Rows[0]["imagename2"]);
                                    objnewsupdate.imagename3   = Convert.ToString(ds.Tables[0].Rows[0]["imagename3"]);
                                    objnewsupdate.imagename4   = Convert.ToString(ds.Tables[0].Rows[0]["imagename4"]);
                                    objnewsupdate.imagename5   = Convert.ToString(ds.Tables[0].Rows[0]["imagename5"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objnewsupdate);
        }
        public Int64 Update(newsupdate objnewsupdate)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "newsupdate_Update";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@newsupdateid";
                param.Value         = objnewsupdate.newsupdateid;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@title", objnewsupdate.title);
                cmd.Parameters.AddWithValue("@imagename", objnewsupdate.imagename);
                cmd.Parameters.AddWithValue("@shortdescp", objnewsupdate.shortdescp);
                cmd.Parameters.AddWithValue("@longdescp", objnewsupdate.longdescp);
                cmd.Parameters.AddWithValue("@newsdate", objnewsupdate.newsdate);
                cmd.Parameters.AddWithValue("@imagename2", objnewsupdate.imagename2);
                cmd.Parameters.AddWithValue("@imagename3", objnewsupdate.imagename3);
                cmd.Parameters.AddWithValue("@imagename4", objnewsupdate.imagename4);
                cmd.Parameters.AddWithValue("@imagename5", objnewsupdate.imagename5);

                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
Beispiel #3
0
    protected void btnAddEditNews_Click(object sender, EventArgs e)
    {
        Int64      Result        = 0;
        newsupdate objnewsupdate = new newsupdate();

        objnewsupdate.title      = txtNewsTitle.Text;
        objnewsupdate.shortdescp = txtShortDescp.Text;
        objnewsupdate.longdescp  = txtDescription.Text;
        objnewsupdate.newsdate   = txtNewsDate.Text;
        if (ViewState["fileName"] != null)
        {
            objnewsupdate.imagename = ViewState["fileName"].ToString();
        }
        if (ViewState["fileName2"] != null)
        {
            objnewsupdate.imagename2 = ViewState["fileName2"].ToString();
        }
        if (ViewState["fileName3"] != null)
        {
            objnewsupdate.imagename3 = ViewState["fileName3"].ToString();
        }
        if (ViewState["fileName4"] != null)
        {
            objnewsupdate.imagename4 = ViewState["fileName4"].ToString();
        }
        if (ViewState["fileName5"] != null)
        {
            objnewsupdate.imagename5 = ViewState["fileName5"].ToString();
        }
        if (Request.QueryString["id"] != null)
        {
            objnewsupdate.newsupdateid = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result = (new Cls_newsupdate_b().Update(objnewsupdate));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managenews.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "News Not Updated";
                BindNews(ocommon.Decrypt(Convert.ToString(Request.QueryString["id"]), true));
            }
        }
        else
        {
            Result = (new Cls_newsupdate_b().Insert(objnewsupdate));
            if (Result > 0)
            {
                SendNotification(objnewsupdate.title, "http://moryaapp.moryatools.com/uploads/news/front/" + objnewsupdate.imagename + " , " + "http://moryaapp.moryatools.com/uploads/news/front/" + objnewsupdate.imagename2 + " , " + "http://moryaapp.moryatools.com/uploads/news/front/" + objnewsupdate.imagename3 + " , " + "http://moryaapp.moryatools.com/uploads/news/front/" + objnewsupdate.imagename4 + " , " + "http://moryaapp.moryatools.com/uploads/news/front/" + objnewsupdate.imagename5, objnewsupdate.shortdescp, objnewsupdate.newsdate);
                Response.Redirect(Page.ResolveUrl("~/managenews.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "News Not Inserted";
            }
        }
    }
Beispiel #4
0
    private void BindNews(string Id)
    {
        newsupdate objnewsupdate = (new Cls_newsupdate_b().SelectById(Convert.ToInt64(Id)));

        if (objnewsupdate != null)
        {
            txtNewsTitle.Text   = objnewsupdate.title;
            txtShortDescp.Text  = objnewsupdate.shortdescp;
            txtDescription.Text = objnewsupdate.longdescp;
            txtNewsDate.Text    = objnewsupdate.newsdate;
            if (!string.IsNullOrEmpty(objnewsupdate.imagename))
            {
                imgNews.Visible       = true;
                ViewState["fileName"] = objnewsupdate.imagename;
                imgNews.ImageUrl      = newsFrontPath + objnewsupdate.imagename;
                btnUpload.Visible     = false;
                btnRemove.Visible     = true;
            }
            else
            {
                btnUpload.Visible = true;
            }
            if (!string.IsNullOrEmpty(objnewsupdate.imagename2))
            {
                imgNews2.Visible       = true;
                ViewState["fileName2"] = objnewsupdate.imagename2;
                imgNews2.ImageUrl      = newsFrontPath + objnewsupdate.imagename2;
                btnUpload2.Visible     = false;
                btnRemove2.Visible     = true;
            }
            else
            {
                btnUpload2.Visible = true;
            }
            if (!string.IsNullOrEmpty(objnewsupdate.imagename3))
            {
                imgNews3.Visible       = true;
                ViewState["fileName3"] = objnewsupdate.imagename3;
                imgNews3.ImageUrl      = newsFrontPath + objnewsupdate.imagename3;
                btnUpload3.Visible     = false;
                btnRemove3.Visible     = true;
            }
            else
            {
                btnUpload3.Visible = true;
            }
            if (!string.IsNullOrEmpty(objnewsupdate.imagename4))
            {
                imgNews4.Visible       = true;
                ViewState["fileName4"] = objnewsupdate.imagename4;
                imgNews4.ImageUrl      = newsFrontPath + objnewsupdate.imagename4;
                btnUpload4.Visible     = false;
                btnRemove4.Visible     = true;
            }
            else
            {
                btnUpload4.Visible = true;
            }
            if (!string.IsNullOrEmpty(objnewsupdate.imagename5))
            {
                imgNews5.Visible       = true;
                ViewState["fileName5"] = objnewsupdate.imagename5;
                imgNews5.ImageUrl      = newsFrontPath + objnewsupdate.imagename5;
                btnUpload5.Visible     = false;
                btnRemove5.Visible     = true;
            }
            else
            {
                btnUpload5.Visible = true;
            }
        }
    }