Esempio n. 1
0
        public void SaveImagesAttachAll()
        {
            T_Tinbai_Anh _obj = new T_Tinbai_Anh();

            int _ID = 0;

            if (dgrListImages.Items.Count > 0)
            {
                _daltinanh.DeleteAllTinbai_AnhByMatinbai(_matinbai);
                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)
                    {
                        if (_matinbai != 0)
                        {
                            _obj.Ma_TinBai = _matinbai;
                            _obj.Ma_Anh    = _ID;
                            _obj.ChuThich  = "";
                            _daltinanh.InsertUpdateTin_Anh(_obj);
                        }
                        _objimg = _dalanh.GetOneFromT_AnhByID(_ID);
                        string _chuthich = "";
                        string _tacgia   = "";
                        int    _tacgiaID = 0;
                        if (txtChuthich.Text != "")
                        {
                            _chuthich = UltilFunc.RemoveEnterCode(txtChuthich.Text.Trim().Replace("'", "''"));
                        }
                        if (_objimg != null && _objimg.Ma_Nguoichup != 0)
                        {
                            _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                            _tacgiaID = _objimg.Ma_Nguoichup;
                        }
                        if (!String.IsNullOrEmpty(hdnValueTacGiaAnh.Text))
                        {
                            _tacgia   = txtTacgia.Text.Replace(" -- ", "|").Split('|')[0];
                            _tacgiaID = int.Parse(hdnValueTacGiaAnh.Text.ToString());
                        }


                        string SqlUpdate = "";
                        SqlUpdate = "update T_Anh set Chuthich=N'" + _chuthich + "',NguoiChup=N'" + _tacgia + "',Ma_Nguoichup=" + _tacgiaID + " where Ma_Anh=" + _ID;
                        Ulti.ExecSql(SqlUpdate);
                    }
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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;
            }
        }