예제 #1
0
        protected void btnSaveNoiDung_Click(object sender, EventArgs e)
        {
            try
            {
                NhanHieuController cont   = new NhanHieuController();
                string             tieude = "";
                if (lblCurrentFileName.Text != "")
                {
                    tieude = lblCurrentFileName.Text.Substring(0, lblCurrentFileName.Text.LastIndexOf('.'));
                }
                string fullFileName = lblCurrentFileName.Text;
                if (txtFile.PostedFile.FileName != "")
                {
                    tieude = SaveFile(FolderUpload, out fullFileName);
                    imgCurrentFile.ImageUrl = PortalSettings.HomeDirectory + FolderUpload + fullFileName;
                }
                if (hdImage.Value == "0")
                {
                    Page.ClientScript.RegisterStartupScript(typeof(string), "insertupdatefail", "<script language=javascript>alert('Bạn chưa chọn file hoặc file không hợp lệ!');</script>", false);
                    return;
                }

                string lv = "";
                for (int i = 0; i < lstLinhVuc.Items.Count; i++)
                {
                    ListItem li = lstLinhVuc.Items[i];
                    if (li.Selected)
                    {
                        lv += "@" + li.Value + "@";
                    }
                }
                DateTime dt         = DateTime.Now;
                int      BienDongID = 0;
                if (hdIsReferenced.Value == "1")
                {
                    cont.NhanHieu_BienDong_Insert(int.Parse(hdNhanHieuID.Value), int.Parse(hdImage.Value), txtMoTa.Text, txtMauSac.Text, int.Parse(ddlLoaiNhanHieu.SelectedValue), lv, txtGhiChuThayDoi.Text, dt, UserId, website, out BienDongID);
                    if (BienDongID == -1)
                    {
                        BienDongID = 0;
                    }
                    hdBienDongID.Value   = BienDongID.ToString();
                    hdIsReferenced.Value = "0";
                }
                else
                {
                    if (hdBienDongID.Value != "0")
                    {
                        cont.NhanHieu_BienDong_Update(int.Parse(hdBienDongID.Value), int.Parse(hdNhanHieuID.Value), int.Parse(hdImage.Value), txtMoTa.Text, txtMauSac.Text, int.Parse(ddlLoaiNhanHieu.SelectedValue), lv, txtGhiChuThayDoi.Text, dt, UserId, website);
                        hdBienDongID.Value   = BienDongID.ToString();
                        hdIsReferenced.Value = "0";
                    }
                    else
                    {
                        cont.NhanHieu_BienDong_Insert(int.Parse(hdNhanHieuID.Value), int.Parse(hdImage.Value), txtMoTa.Text, txtMauSac.Text, int.Parse(ddlLoaiNhanHieu.SelectedValue), lv, txtGhiChuThayDoi.Text, dt, UserId, website, out BienDongID);
                        if (BienDongID == -1)
                        {
                            BienDongID = 0;
                        }
                        hdBienDongID.Value   = BienDongID.ToString();
                        hdIsReferenced.Value = "0";
                    }
                }
                SetButtonStatus();
                SetStatus("", "");
                udpNoiDung.Update();
            }
            catch (Exception ex)
            {
            }
        }