Beispiel #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     CuaHang ch = new CuaHang();
     string path = Server.MapPath("../Upload/StoreImages");
     string randomString = "";
     string relativePath = "";
     if (fileStore.PostedFile.FileName != "")
     {
         try
         {
             if (fileStore.PostedFile.ContentLength <= 300000)
             {
                 int pos = fileStore.PostedFile.FileName.LastIndexOf('\\');
                 string absolutePath = path + "\\" + fileStore.PostedFile.FileName.Remove(0, pos + 1);
                 if (File.Exists(absolutePath))
                 {
                     randomString = DateTime.Now.Ticks + "_";
                     absolutePath = path + "\\" + randomString + fileStore.PostedFile.FileName.Remove(0, pos + 1);
                 }
                 //fileStore.PostedFile.SaveAs(absolutePath);
                 Common.ResizeFromStream(absolutePath, 320, fileStore.PostedFile.InputStream);
                 //File.Delete(Server.MapPath(imgAnhQuangCao.Src));
                 relativePath = "./Upload/StoreImages/" + randomString +
                                fileStore.PostedFile.FileName.Remove(0, pos + 1);
             }
             else
             {
                 Response.Redirect("../message.aspx?msg=File size is too big!");
                 return;
             }
         }
         catch (Exception ex)
         {
             Response.Redirect("../message.aspx?msg=" + ex.Message);
             return;
         }
     }
     if (relativePath != "")
     {
         ch.UpdateFields(sid, txtTen.Text, txtGioiThieu.Text, null, txtEmail.Text, relativePath, txtDiDong.Text,
                         txtCoDinh.Text,
                         txtLienHe.Text, txtDiaChi.Text, txtWebSite.Text, txtFax.Text, txtYahoo.Text, null, null,
                         null, null, null, null,
                         null, null, null, null, null, null, null, null);
     }
     else
     {
         ch.UpdateFields(sid, txtTen.Text, txtGioiThieu.Text, null, txtEmail.Text, null, txtDiDong.Text,
                         txtCoDinh.Text,
                         txtLienHe.Text, txtDiaChi.Text, txtWebSite.Text, txtFax.Text, txtYahoo.Text, null, null,
                         null, null, null,
                         null, null, null, null, null, null, null, null, null);
     }
     string strScript = "<script language='JavaScript'>" + "window.parent.RefreshStoreInfo();</script>";
     ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript);
 }
Beispiel #2
0
    protected void btnLuu_Click(object sender, EventArgs e)
    {
        try
        {
            CuaHang ch = new CuaHang();
            ch.UpdateFields(int.Parse(Request.QueryString["sid"]),
                            null, null, null, null, null, null,
                            null, null, null, null, null, null, null, null, null, null,
                            null, null, null, null, null, null, null,
                            short.Parse(ddlBaoDam.SelectedValue),null, short.Parse(ddlLoaiGianHang.SelectedValue));

            string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>";
            ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript);
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }