Ejemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ArrayList ar = new ArrayList();

            foreach (DataGridItem m_Item in dgrListAppro.Items)
            {
                CheckBox chk_Select = (CheckBox)m_Item.FindControl("optSelect");
                if (chk_Select != null && chk_Select.Checked)
                {
                    ar.Add(double.Parse(dgrListAppro.DataKeys[int.Parse(m_Item.ItemIndex.ToString())].ToString()));
                }
            }
            if (ar.Count > 0)
            {
                for (int i = 0; i < ar.Count; i++)
                {
                    int    _ID  = int.Parse(ar[i].ToString());
                    AnhDAL _DAL = new AnhDAL();
                    _DAL.DeleteFromT_Anh(_ID);
                }
            }
            else
            {
                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('Chưa chọn ảnh muốn xóa.!!')", true);
                return;
            }
            LoadDataApprovied();
        }
Ejemplo n.º 2
0
        public void LoadDataApprovied()
        {
            string where = " TieuDe IS NULL And NguoiTao =" + _user.UserID;
            if (!String.IsNullOrEmpty(this.txt_FromDate.Text.Trim()))
            {
                where += " AND " + string.Format(" NgayTao >='{0}'", UltilFunc.ToDate(this.txt_FromDate.Text.Trim(), "dd/MM/yyyy").ToShortDateString() + " 00:00:00 ");
            }
            if (!String.IsNullOrEmpty(this.txt_ToDate.Text.Trim()))
            {
                where += " AND " + string.Format(" NgayTao <='{0}'", UltilFunc.ToDate(this.txt_ToDate.Text.Trim(), "dd/MM/yyyy").ToShortDateString() + " 23:59:59 ");
            }
            where += " ORDER BY NgayTao DESC ";
            AnhDAL  _DAL = new AnhDAL();
            DataSet _ds;

            pageappro.PageSize = 5;
            _ds = _DAL.BindGridT_Anh(pageappro.PageIndex, pageappro.PageSize, where);
            int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);

            if (TotalRecord == 0)
            {
                _ds = _DAL.BindGridT_Anh(pageappro.PageIndex - 1, pageappro.PageSize, where);
            }
            dgrListAppro.DataSource = _ds;
            dgrListAppro.DataBind();
            pageappro.TotalRecords  = CurrentPage1.TotalRecords = TotalRecords;
            CurrentPage1.TotalPages = pageappro.CalculateTotalPages();
            CurrentPage1.PageIndex  = pageappro.PageIndex;
            Session["CurrentPage"]  = pageappro.PageIndex;
        }
Ejemplo n.º 3
0
        protected void btnXoaAnh_Click(object sender, EventArgs e)
        {
            AnhDAL _dalanh   = new AnhDAL();
            string SqlUpdate = string.Empty;

            foreach (DataListItem m_Item in dgrListImages.Items)
            {
                int _ID = int.Parse(this.dgrListImages.DataKeys[m_Item.ItemIndex].ToString());

                CheckBox chk_Select   = (CheckBox)m_Item.FindControl("optSelect");
                Label    lbFileAttach = m_Item.FindControl("lbFileAttach") as Label;
                if (chk_Select != null && chk_Select.Checked)
                {
                    _dalanh.DeleteFromT_Anh(_ID);
                    string             path = HttpContext.Current.Server.MapPath("/" + System.Configuration.ConfigurationManager.AppSettings["viewimg"].ToString() + lbFileAttach.Text);
                    System.IO.FileInfo fi   = new System.IO.FileInfo(path);
                    try
                    {
                        if (File.Exists(path))
                        {
                            fi.Delete();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            LoadDataImage();
        }
Ejemplo n.º 4
0
        public bool SaveImagesAttachAll()
        {
            T_Anh  objimage = new T_Anh();
            AnhDAL _dalanh  = new AnhDAL();
            int    _ID      = 0;

            if (dgrListImages.Items.Count > 0)
            {
                foreach (DataListItem m_Item in dgrListImages.Items)
                {
                    _ID = Convert.ToInt32(dgrListImages.DataKeys[m_Item.ItemIndex].ToString());
                    TextBox txtTacgia         = m_Item.FindControl("txtTacgia") as TextBox;
                    TextBox hdnValueTacGiaAnh = m_Item.FindControl("hdnValueTacGiaAnh") as TextBox;
                    TextBox txtChuthich       = m_Item.FindControl("txtChuthich") as TextBox;
                    if (_ID != 0)
                    {
                        objimage = _dalanh.GetOneFromT_AnhByID(_ID);
                        string _chuthich = "";
                        string _tacgia   = "";
                        int    _tacgiaID = 0;
                        if (txtChuthich.Text != Global.RM.GetString("Nhapchuthichanh"))
                        {
                            _chuthich = UltilFunc.RemoveEnterCode(txtChuthich.Text.Trim().Replace("'", "''"));
                        }
                        if (objimage != null && objimage.Ma_Nguoichup != 0)
                        {
                            _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                            _tacgiaID = objimage.Ma_Nguoichup;
                        }
                        if (!String.IsNullOrEmpty(hdnValueTacGiaAnh.Text))
                        {
                            _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                            _tacgiaID = int.Parse(hdnValueTacGiaAnh.Text.ToString());
                        }
                        if (txtChuthich.Text == Global.RM.GetString("Nhapchuthichanh"))
                        {
                            FuncAlert.AlertJS(this, "bạn chưa nhập chú thích ảnh");
                            return(false);
                        }

                        if (_tacgiaID == 0)
                        {
                            FuncAlert.AlertJS(this, "bạn chưa nhập tác giả ảnh");
                            return(false);
                        }

                        string SqlUpdate = "";
                        SqlUpdate = "update T_Anh set Chuthich=N'" + _chuthich + "',NguoiChup=N'" + _tacgia + "',Ma_Nguoichup=" + _tacgiaID + " where Ma_Anh=" + _ID;
                        Ulti.ExecSql(SqlUpdate);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 5
0
 public void dgrListAppro_EditCommand(object source, DataGridCommandEventArgs e)
 {
     if (e.CommandArgument.ToString().ToLower() == "edit")
     {
         dgrListAppro.EditItemIndex = e.Item.ItemIndex;
         LoadDataApprovied();
     }
     if (e.CommandArgument.ToString().ToLower() == "delete")
     {
         AnhDAL _DAL = new AnhDAL();
         int    _ID  = Convert.ToInt32(dgrListAppro.DataKeys[e.Item.ItemIndex].ToString());
         _DAL.DeleteFromT_Anh(_ID);
         LoadDataApprovied();
     }
 }
Ejemplo n.º 6
0
        public void dgrListAppro_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            T_Anh   objimage    = new T_Anh();
            AnhDAL  _DAL        = new AnhDAL();
            int     _ID         = Convert.ToInt32(dgrListAppro.DataKeys[e.Item.ItemIndex].ToString());
            TextBox txtTieude   = e.Item.FindControl("txtTieude") as TextBox;
            TextBox txtChuthich = e.Item.FindControl("txtChuthich") as TextBox;
            TextBox txtTacgia   = e.Item.FindControl("txtTacgia") as TextBox;
            string  _tieude     = "";
            string  _chuthich   = "";
            string  _tacgia     = "";
            int     _tacgiaID   = 0;

            if (txtTieude != null)
            {
                if (!String.IsNullOrEmpty(txtTieude.Text.Trim()))
                {
                    _tieude = txtTieude.Text.Trim();
                }
            }
            if (txtChuthich != null)
            {
                if (!String.IsNullOrEmpty(txtChuthich.Text.Trim()))
                {
                    _chuthich = txtChuthich.Text.Trim();
                }
            }
            if (txtTacgia != null)
            {
                if (!String.IsNullOrEmpty(txtTacgia.Text.Trim()))
                {
                    _tacgia   = txtTacgia.Text;
                    _tacgiaID = Convert.ToInt32(UltilFunc.GetTacgiaID(_tacgia).ToString());
                }
            }
            objimage.Ma_Anh       = _ID;
            objimage.TieuDe       = _tieude;
            objimage.Chuthich     = _chuthich;
            objimage.NguoiChup    = _tacgia;
            objimage.Ma_Nguoichup = _tacgiaID;
            _DAL.InsertUpdateT_Anh(objimage);
            //_DAL.UpdateinfoT_Anh("TieuDe=N'" + _tieude + "',Chuthich=N'" + _chuthich + "',NguoiChup=N'" + _tacgia + "',Ma_Nguoichup=" + _tacgiaID + " WHERE Ma_Anh=" + _ID);

            dgrListAppro_CancelCommand(source, e);
        }
Ejemplo n.º 7
0
        public void LoadDataApprovied()
        {
            string where = " TieuDe IS NOT NULL ";
            if (!String.IsNullOrEmpty(txtSearchName.Text.Trim()))
            {
                where += " AND " + string.Format(" TieuDe  like N'%{0}%' OR dbo.ClearVNMark(TieuDe)  Like N'%{0}%'", UltilFunc.SqlFormatText(this.txtSearchName.Text.Trim()));
            }
            if (!String.IsNullOrEmpty(this.txt_FromDate.Text.Trim()))
            {
                where += " AND " + string.Format(" NgayTao >='{0}'", UltilFunc.ToDate(this.txt_FromDate.Text.Trim(), "dd/MM/yyyy").ToShortDateString() + " 00:00:00 ");
            }
            if (!String.IsNullOrEmpty(this.txt_ToDate.Text.Trim()))
            {
                where += " AND " + string.Format(" NgayTao <='{0}'", UltilFunc.ToDate(this.txt_ToDate.Text.Trim(), "dd/MM/yyyy").ToShortDateString() + " 23:59:59 ");
            }
            where += " ORDER BY NgayTao DESC ";
            AnhDAL  _DAL = new AnhDAL();
            DataSet _ds;

            pageappro.PageSize = 5;
            _ds = _DAL.BindGridT_Anh(pageappro.PageIndex, pageappro.PageSize, where);
            if (_ds.Tables[0].Rows.Count > 0)
            {
                int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
                int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);
                if (TotalRecord == 0)
                {
                    _ds = _DAL.BindGridT_Anh(pageappro.PageIndex - 1, pageappro.PageSize, where);
                }
                dgrListAppro.DataSource = _ds;
                dgrListAppro.DataBind();
                pageappro.TotalRecords  = CurrentPage1.TotalRecords = TotalRecords;
                CurrentPage1.TotalPages = pageappro.CalculateTotalPages();
                CurrentPage1.PageIndex  = pageappro.PageIndex;
                Session["CurrentPage"]  = pageappro.PageIndex;
                panelReport.Visible     = false;
                panelContent.Visible    = true;
            }
            else
            {
                panelReport.Visible    = true;
                panelContent.Visible   = false;
                Session["CurrentPage"] = null;
            }
        }
Ejemplo n.º 8
0
        public void dgrListImages_EditCommand(object source, DataListCommandEventArgs e)
        {
            T_Anh       objimage          = new T_Anh();
            AnhDAL      _dalanh           = new AnhDAL();
            ImageButton btnAdd            = e.Item.FindControl("btnAdd") as ImageButton;
            ImageButton btnUpdate         = e.Item.FindControl("btnUpdate") as ImageButton;
            ImageButton btnCancel         = e.Item.FindControl("btnCancel") as ImageButton;
            ImageButton btndelete         = e.Item.FindControl("Imagebuttondelete") as ImageButton;
            TextBox     hdnValueTacGiaAnh = e.Item.FindControl("hdnValueTacGiaAnh") as TextBox;
            TextBox     txtTacgia         = e.Item.FindControl("txtTacgia") as TextBox;
            TextBox     txtChuthich       = e.Item.FindControl("txtChuthich") as TextBox;
            Label       lbdesc            = e.Item.FindControl("lbdesc") as Label;
            Label       lbtacgia          = e.Item.FindControl("lbtacgia") as Label;

            int _ID = Convert.ToInt32(dgrListImages.DataKeys[e.Item.ItemIndex].ToString());

            objimage = _dalanh.GetOneFromT_AnhByID(_ID);
            if (e.CommandArgument.ToString().ToLower() == "delete")
            {
                Label              lbFileAttach = e.Item.FindControl("lbFileAttach") as Label;
                string             path         = HttpContext.Current.Server.MapPath("~" + lbFileAttach.Text);
                System.IO.FileInfo fi           = new System.IO.FileInfo(path);
                try
                {
                    if (File.Exists(path))
                    {
                        fi.Delete();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                _dalanh.DeleteFromT_Anh(_ID);
                string thaotac = "Thao tác xóa ảnh đính kèm: " + objimage.Duongdan_Anh + " tại " + Request["MaDoiTuong"].ToString() + "  thuộc tin bài: " + Txt_tieude.Text.Trim();
                UltilFunc.Log_Action(_user.UserID, _user.UserName, DateTime.Now, int.Parse(Request["Menu_ID"].ToString()), thaotac);
                LoadDataImage();
            }
            if (e.CommandArgument.ToString().ToLower() == "editinfo")
            {
                btndelete.Visible   = false;
                btnAdd.Visible      = false;
                btnUpdate.Visible   = true;
                btnCancel.Visible   = true;
                lbdesc.Visible      = false;
                lbtacgia.Visible    = false;
                txtTacgia.Visible   = true;
                txtChuthich.Visible = true;

                if (objimage != null && objimage.Ma_Nguoichup != 0)
                {
                    hdnValueTacGiaAnh.Text = objimage.Ma_Nguoichup.ToString();
                }
                else
                {
                    hdnValueTacGiaAnh.Text = "";
                }
                if (objimage.NguoiChup != "")
                {
                    txtTacgia.Text = objimage.NguoiChup;
                }
                else
                {
                    txtTacgia.Text = Global.RM.GetString("Nhaptacgiaanh");
                }
                if (objimage.Chuthich.Length > 0)
                {
                    txtChuthich.Text = objimage.Chuthich;
                }
                else
                {
                    txtChuthich.Text = Global.RM.GetString("Nhapchuthichanh");
                }
            }
            if (e.CommandArgument.ToString().ToLower() == "update")
            {
                string _chuthich = "";
                string _tacgia   = "";
                int    _tacgiaID = 0;
                if (txtChuthich.Text != Global.RM.GetString("Nhapchuthichanh"))
                {
                    _chuthich = UltilFunc.RemoveEnterCode(txtChuthich.Text.Trim().Replace("'", "''"));
                }
                if (objimage != null && objimage.Ma_Nguoichup != 0)
                {
                    _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                    _tacgiaID = objimage.Ma_Nguoichup;
                }
                if (!String.IsNullOrEmpty(hdnValueTacGiaAnh.Text))
                {
                    _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                    _tacgiaID = int.Parse(hdnValueTacGiaAnh.Text.ToString());
                }
                if (txtChuthich.Text == Global.RM.GetString("Nhapchuthichanh"))
                {
                    FuncAlert.AlertJS(this, "bạn chưa nhập chú thích ảnh");
                    return;
                }

                if (_tacgiaID == 0)
                {
                    FuncAlert.AlertJS(this, "bạn chưa nhập tác giả ảnh");
                    return;
                }

                string SqlUpdate = "";
                SqlUpdate = "update T_Anh set Chuthich=N'" + _chuthich + "',NguoiChup=N'" + _tacgia + "',Ma_Nguoichup=" + _tacgiaID + " where Ma_Anh=" + _ID;
                Ulti.ExecSql(SqlUpdate);
                LoadDataImage();
                lbdesc.Text         = txtChuthich.Text;
                lbtacgia.Text       = txtTacgia.Text;
                btnAdd.Visible      = true;
                btnUpdate.Visible   = false;
                btnCancel.Visible   = false;
                lbdesc.Visible      = true;
                lbtacgia.Visible    = true;
                txtChuthich.Visible = false;
                txtTacgia.Visible   = false;
            }
            if (e.CommandArgument.ToString().ToLower() == "cancel")
            {
                btndelete.Visible   = true;
                btnAdd.Visible      = true;
                btnUpdate.Visible   = false;
                btnCancel.Visible   = false;
                lbdesc.Visible      = true;
                lbtacgia.Visible    = true;
                txtTacgia.Visible   = false;
                txtChuthich.Visible = false;
            }
        }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");

            try
            {
                string[] sArrProdID = null;
                char[]   sep        = { '?' };
                string[] sArrVkey   = null;
                string   strUserID  = "";
                char[]   sep2       = { ',' };
                sArrProdID = context.Request.QueryString["user"].ToString().Trim().Split(sep);
                sArrVkey   = sArrProdID[0].ToString().Trim().Split(sep2);
                user       = DAL.GetUserByUserName(sArrVkey[0].ToString());
                strUserID  = user.UserID.ToString();
                int matinbai = 0;
                if (sArrVkey[1].ToString() != "")
                {
                    matinbai = int.Parse(sArrVkey[1].ToString());
                }
                HttpPostedFile postedFile = context.Request.Files["Filedata"];

                string tempPath = System.Configuration.ConfigurationManager.AppSettings["UploadPath"].ToString() + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/";

                //Create forder
                CreateFolderByUserName(tempPath);

                string   savepath    = context.Server.MapPath("/" + tempPath);
                string   filename    = postedFile.FileName;
                string[] sArrTenfile = null;
                char[]   cat         = { '.' };
                sArrTenfile = filename.ToString().Trim().Split(cat);
                string _extenfile  = GetDateTimeStringUnique() + "." + sArrTenfile[1].ToString();
                string _tenfilegoc = UltilFunc.RemoveSign4VietnameseString(Path.GetFileNameWithoutExtension(filename)) + "." + _extenfile.ToString();

                _tenfilegoc = _tenfilegoc.Replace(" ", "");
                postedFile.SaveAs(savepath + @"\" + _tenfilegoc);

                int startchar = tempPath.Substring(1, tempPath.Length - 1).IndexOf("/");
                startchar += 1;
                string _PathFile = tempPath.Substring(startchar, tempPath.Length - startchar);
                string _savePath = _PathFile + "" + _tenfilegoc;

                AnhDAL _DAL = new AnhDAL();
                T_Anh  _obj = new T_Anh();
                _obj = SetItem(_savePath, _tenfilegoc, _tenfilegoc);
                int _MaAnhReturn = _DAL.InsertUpdateT_Anh(_obj);
                if (matinbai > 0 && _MaAnhReturn > 0)
                {
                    TinBaiAnhDAL _daltinanh = new TinBaiAnhDAL();
                    T_Tinbai_Anh _objTA     = new T_Tinbai_Anh();
                    _objTA.ID        = 0;
                    _objTA.Ma_Anh    = _MaAnhReturn;
                    _objTA.Ma_TinBai = matinbai;
                    _objTA.ChuThich  = "";
                    _daltinanh.InsertUpdateTin_Anh(_objTA);
                }

                context.Response.Write(tempPath + "/" + filename);
                context.Response.StatusCode = 200;
            }
            catch (Exception ex)
            {
                context.Response.Write("Error: " + ex.Message);
            }
        }