protected void HandelFiles()
    {
        UserVM user = AuthServer.GetLoginUser();

        NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();

        foreach (CheckFieldVM cf in CheckFieldVMList)
        {
            try
            {   //fu_ID
                HttpPostedFile uploadedFile = Request.Files["fu_" + cf.ID];



                if (uploadedFile != null && uploadedFile.ContentLength > 0)
                {
                    BinaryReader b             = new BinaryReader(uploadedFile.InputStream);
                    int          OutFileInfoID = 0;

                    OutFileInfoID = WS.UploadFile(11, uploadedFile.ContentType, uploadedFile.FileName.Split('.').Last(), uploadedFile.FileName, user.ID, user.OrgID, b.ReadBytes(uploadedFile.ContentLength));

                    if (OutFileInfoID > 0)
                    {
                        cf.FileID = OutFileInfoID;
                    }
                }
            }
            catch (Exception ex)
            {
                // Response.Write(ex.Message + ex.StackTrace);
                Response.End();
            }
        }
    }
    public int NewFile( )
    {
        int OutFileInfoID = 0;

        NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
        try
        {
            if (fuRemark.HasFile)
            {
                OutFileInfoID = WS.UploadFile(11, fuRemark.PostedFile.ContentType, fuRemark.FileName.Split('.').Last(), fuRemark.FileName, AuthServer.GetLoginUser().ID, AuthServer.GetLoginUser().OrgID, fuRemark.FileBytes);
            }
        }
        catch (Exception ex)
        {
        }
        return(OutFileInfoID);
    }
  public void handlefile(int NewVisitID)
  {
      UserVM user = AuthServer.GetLoginUser();

      NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();

      try
      {
          if (fu_Visit.HasFile)
          {
              int OutFileInfoID = 0;

              OutFileInfoID = WS.UploadFile(11, fu_Visit.PostedFile.ContentType, fu_Visit.FileName.Split('.').Last(), fu_Visit.FileName, user.ID, user.OrgID, fu_Visit.FileBytes);

              DBUtil.DBOp("ConnDB", "INSERT INTO [C_CaseVisitFile] ([VisitID] ,[FileID],FileType)  VALUES  ({0} , {1},{2})", new string[] { NewVisitID.ToString(), OutFileInfoID.ToString(), ddlVisitFileType.SelectedValue }, NSDBUtil.CmdOpType.ExecuteNonQuery);
          }
      }
      catch (Exception ex)
      {
          //Response.Write(ex.Message + ex.StackTrace);
          //Response.End();
      }
  }
Beispiel #4
0
    protected void Save_Click(object sender, EventArgs e)
    {
        UserVM user    = AuthServer.GetLoginUser();
        string script  = "";
        string message = CheckNeeded();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
            return;
        }

        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;
        int  Success           = 0;

        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(2, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        string subject           = Subject.Text.Trim();
        string contents          = Contents.Text.Trim();
        string publishedStarDate = (Convert.ToInt32(PublishedStarDate.Text.Substring(0, 3)) + 1911).ToString() + "/" + PublishedStarDate.Text.Substring(3, 2) + "/" + PublishedStarDate.Text.Substring(5, 2);
        string publishedEndDate  = (Convert.ToInt32(PublishedEndDate.Text.Substring(0, 3)) + 1911).ToString() + "/" + PublishedEndDate.Text.Substring(3, 2) + "/" + PublishedEndDate.Text.Substring(5, 2);
        bool   emailCheck        = EmailCheck.Checked;
        string orgID             = "";
        int    orgType           = 0;

        if (emailCheck == true)
        {
            orgID = OrgID.Value;
            int.TryParse(OrgType.Value, out orgType);
        }

        if (UploadFileSuccess == true)
        {
            int ID = 0;

            int.TryParse(Request.QueryString["CheckID"], out ID);

            DataSet ds = new DataSet();
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_NewsPublished_xUpdateNewsPublished", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ID", ID);
                    cmd.Parameters.AddWithValue("@Subject", subject);
                    cmd.Parameters.AddWithValue("@Contents", contents);
                    cmd.Parameters.AddWithValue("@FileInfoIDs", OutFileInfoIDs);
                    cmd.Parameters.AddWithValue("@PublishedStarDate", publishedStarDate);
                    cmd.Parameters.AddWithValue("@PublishedEndDate", publishedEndDate);
                    cmd.Parameters.AddWithValue("@EmailCheck", emailCheck);
                    cmd.Parameters.AddWithValue("@EmailOrg", orgID);
                    cmd.Parameters.AddWithValue("@EmailOrgType", orgType);
                    cmd.Parameters.AddWithValue("@ModifyAccount", user.ID);
                    SqlParameter sp = cmd.Parameters.AddWithValue("@Success", Success);
                    sp.Direction = ParameterDirection.Output;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        sc.Open();
                        da.Fill(ds);
                        Success = (int)sp.Value;
                    }
                }
            }
        }

        if (UploadFileSuccess && Success > 0)
        {
            script = "<script>alert('儲存成功');location.href = '/System/ElectronBulletinM/NewsPublished/NewsPublished.aspx';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
    }
Beispiel #5
0
    protected void Save_Click(object sender, EventArgs e)
    {
        UserVM user    = AuthServer.GetLoginUser();
        string script  = "";
        string message = CheckNeeded();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
            return;
        }

        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;

        List <int> OutFileInfoID_List = new List <int>();

        if (TempFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = TempFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(5, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        string num          = Num.Text.Trim();
        string tempHigh     = TempHigh.Text.Trim();
        int    froIdx       = int.Parse(FroIdx.SelectedValue);
        string tempLow      = TempLow.Text.Trim();
        int    oriFroIdx    = int.Parse(OriFroIdx.SelectedValue);
        int    monIdx       = int.Parse(MonIdx.SelectedValue);
        int    CheckStorage = 0;
        int    Success      = 0;

        int VaccOutBatchDataID;

        HttpUtility.HtmlEncode(int.TryParse(Request.QueryString["BI"], out VaccOutBatchDataID));

        if (UploadFileSuccess == true)
        {
            DataSet ds = new DataSet();
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_VaccineOut_xUpdateTempVaccineOutBatchData", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ID", VaccOutBatchDataID);
                    cmd.Parameters.AddWithValue("@Num", num);
                    cmd.Parameters.AddWithValue("@TempHigh", tempHigh);
                    cmd.Parameters.AddWithValue("@FroIdx", froIdx);
                    cmd.Parameters.AddWithValue("@TempLow", tempLow);
                    cmd.Parameters.AddWithValue("@OriFroIdx", oriFroIdx);
                    cmd.Parameters.AddWithValue("@MonIdx", monIdx);
                    cmd.Parameters.AddWithValue("@TempFile", OutFileInfoIDs);
                    cmd.Parameters.AddWithValue("@CreateAccount", user.ID);
                    SqlParameter sp  = cmd.Parameters.AddWithValue("@CheckStorage", CheckStorage);
                    SqlParameter sp1 = cmd.Parameters.AddWithValue("@Success", Success);
                    sp.Direction  = ParameterDirection.Output;
                    sp1.Direction = ParameterDirection.Output;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        sc.Open();
                        da.Fill(ds);
                        CheckStorage = (int)sp.Value;
                        Success      = (int)sp1.Value;
                    }
                }
            }
        }

        if (UploadFileSuccess && Success > 0)
        {
            int VaccineInID;
            HttpUtility.HtmlEncode(int.TryParse(Request.QueryString["I"], out VaccineInID));
            script = "<script>alert('儲存成功!');location.href = '/Vaccine/StockManagementM/VaccineOut/New_VaccineOutDataList.aspx?ID=" + VaccineInID + "';</script>";
        }
        else
        {
            if (CheckStorage > 0)
            {
                script = "<script>alert('庫存量不足!');</script>";
            }
            else
            {
                script = "<script>alert('儲存失敗!');</script>";
            }
        }

        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string checkScript = "";

        string message = CheckValid();

        if (message.Length > 0)
        {
            checkScript = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", checkScript, false);
            return;
        }

        string title       = PureString(tbTitle.Text);
        string description = PureString(tbDesp.Text);

        int         state    = 0;
        RadioButton selected = MyForm.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);

        if (selected != null)
        {
            switch (selected.ID)
            {
            case "rb1":
                state = 1;
                break;

            case "rb2":
                state = 2;
                break;
            }
        }

        UserVM user              = AuthServer.GetLoginUser();
        int    OutFileInfoID     = 0;
        bool   UploadFileSuccess = true;
        int    Chk = 0;

        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        if (UploadFileSuccess == true)
        {
            string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

            Dictionary <string, object> OutDict = new Dictionary <string, object>()
            {
                { "@Chk", Chk }
            };

            MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_DocumentM_xAddDocumentInfo"
                                 , ref OutDict
                                 , new Dictionary <string, object>()
            {
                { "@DocTitle", title },
                { "@PublishState", state },
                { "@DocDescription", description },
                { "@CreatedUserID", user.ID },
                { "@FileInfoIDs", OutFileInfoIDs }
            });

            Chk = (int)OutDict["@Chk"];
        }

        string script = "";

        if (UploadFileSuccess && Chk > 0)
        {
            script = string.Format("{0}<script>alert('儲存成功');location.href='{1}#{2}';</script>",
                                   "<style>body{display:none;}</style>"
                                   , "/System/DocumentM/DocumentMaintain.aspx"
                                   , HttpUtility.HtmlDecode(GetString("hash") ?? "")
                                   );
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string script  = "";
        string message = CheckNeeded();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
            return;
        }



        string title       = tbTitle.Text.Trim();
        string description = tbDesp.Text.Trim();

        int         state  = 0;
        RadioButton thisRb = null;

        thisRb = form1.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);
        if (thisRb != null)
        {
            switch (thisRb.ID)
            {
            case "rb1":
                state = 1;
                break;

            case "rb2":
                state = 2;
                break;
            }
        }


        UserVM user              = AuthServer.GetLoginUser();
        int    OutFileInfoID     = 0;
        bool   UploadFileSuccess = true;
        int    Chk = 0;

        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.RoleID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());


        if (UploadFileSuccess == true)
        {
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("dbo.usp_DocumentM_xUpdateDocumentInfo", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DocTitle", title);
                    cmd.Parameters.AddWithValue("@PublishState", state);
                    cmd.Parameters.AddWithValue("@DocDescription", description);
                    cmd.Parameters.AddWithValue("@DocumentInfoID", ID);
                    //cmd.Parameters.AddWithValue("@FileInfoID", OutFileInfoID);
                    cmd.Parameters.AddWithValue("@FileInfoIDs", OutFileInfoIDs);

                    SqlParameter sp = cmd.Parameters.AddWithValue("@Chk", Chk);
                    sp.Direction = ParameterDirection.Output;

                    sc.Open();
                    cmd.ExecuteNonQuery();

                    Chk = (int)sp.Value;
                }
            }
        }

        if (UploadFileSuccess && Chk > 0)
        {
            script = "<script>alert('儲存成功');location.href = '/System/DocumentM/DocumentMaintain.aspx';</script><style>body{display:none;}</style>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }



        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Beispiel #8
0
    protected void Save_Click(object sender, EventArgs e)
    {
        UserVM user = AuthServer.GetLoginUser();

        string script  = "";
        string message = CheckNeeded();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
            return;
        }

        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;

        List <int> OutFileInfoID_List = new List <int>();

        if (AccountFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = AccountFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(12, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        int    ID = 0;
        string accountFileDesc = AccountFileDesc.Text.Trim();

        int.TryParse(Request.QueryString["ID"], out ID);

        int Success = 0;

        if (UploadFileSuccess == true)
        {
            DataSet ds = new DataSet();
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_AccountSet_xUpdateFileData", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ID", ID);
                    cmd.Parameters.AddWithValue("@AccountFile", OutFileInfoIDs);
                    cmd.Parameters.AddWithValue("@AccountFileDesc", accountFileDesc);
                    cmd.Parameters.AddWithValue("@ModifyAccount", user.ID);
                    SqlParameter sp = cmd.Parameters.AddWithValue("@Success", Success);
                    sp.Direction = ParameterDirection.Output;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        sc.Open();
                        da.Fill(ds);
                        Success = (int)sp.Value;
                    }
                }
            }
        }

        if (UploadFileSuccess && Success > 0)
        {
            int OrgID = 0;

            int.TryParse(Request.QueryString["OrgID"], out OrgID);

            script = "<script>alert('儲存成功');window.opener.refresh(" + OrgID + ");window.close();</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }
        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int    CheckState       = PureNumber <int>(rbList.SelectedValue);
        bool   IsBusiness       = cbP.Checked;
        string UserName         = PureString(tbName.Text);
        string RocID            = PureString(tbRID.Text);
        string PhoneNumber      = PureString(tbPhone.Text);
        string Email            = PureString(tbEmail.Text);
        string Title            = PureString(tbTitle.Text);
        string ApplyReason      = PureString(tbReason.Text);
        string CheckDescription = PureString(tbDesp.Text);

        List <int> roleList = new List <int>();

        foreach (ListItem listItem in cbList.Items)
        {
            if (listItem.Selected)
            {
                int value = 0;
                int.TryParse(listItem.Value, out value);
                if (value > 0)
                {
                    roleList.Add(value);
                }
            }
        }

        UserVM user              = AuthServer.GetLoginUser();
        int    OutFileInfoID     = 0;
        bool   UploadFileSuccess = true;
        int    Chk = 0;

        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.RoleID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        if (UploadFileSuccess == true)
        {
            Dictionary <string, object> OutDict = new Dictionary <string, object>()
            {
                { "@Chk", Chk }
            };

            MSDB.ExecuteNonQuery("ConnUser", "dbo.usp_AccountM_xUpdateAccountInfo"
                                 , ref OutDict
                                 , new Dictionary <string, object>()
            {
                { "@UserID", ID },
                { "@UserName", UserName },
                { "@RocID", RocID },
                { "@PhoneNumber", PhoneNumber },
                { "@Email", Email },
                { "@Title", Title },
                { "@RoleIDs", string.Join(",", roleList.ConvertAll((item) => { return(item.ToString()); })) },
                { "@ApplyReason", ApplyReason },
                { "@CheckState", CheckState },
                { "@CheckDescription", CheckDescription },
                { "@IsBusiness", IsBusiness },
                { "@FileInfoIDs", OutFileInfoIDs }
            });

            Chk = (int)OutDict["@Chk"];
        }

        string script = "";

        if (Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');location.href = '/System/AccountM/AccountCheck.aspx?i=" + ID + "';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Beispiel #10
0
    protected void Save_Click(object sender, EventArgs e)
    {
        UserVM user    = AuthServer.GetLoginUser();
        string script  = "";
        string message = CheckNeeded();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
            return;
        }

        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;
        int  Success           = 0;

        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(3, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        int    questionType    = int.Parse(QuestionType.SelectedValue);
        string question        = Question.Text.Trim();
        string reply           = Reply.Text.Trim();
        int    publishedStatus = 0;

        if (PublishedStatus1.Checked == true)
        {
            publishedStatus = 1;
        }
        if (PublishedStatus2.Checked == true)
        {
            publishedStatus = 2;
        }

        if (UploadFileSuccess == true)
        {
            DataSet ds = new DataSet();

            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("usp_QnAData_xAddQnAData", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@QuestionType", questionType);
                    cmd.Parameters.AddWithValue("@Question", question);
                    cmd.Parameters.AddWithValue("@Answer", reply);
                    cmd.Parameters.AddWithValue("@FileInfoIDs", OutFileInfoIDs);
                    cmd.Parameters.AddWithValue("@QaStatus", publishedStatus);
                    cmd.Parameters.AddWithValue("@CreatAccount", user.ID);
                    SqlParameter sp = cmd.Parameters.AddWithValue("@Success", Success);
                    sp.Direction = ParameterDirection.Output;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        sc.Open();
                        cmd.ExecuteNonQuery();
                        Success = (int)sp.Value;
                    }
                }
            }
        }

        if (UploadFileSuccess && Success > 0)
        {
            script = "<script>alert('儲存成功');location.href = '/System/FrequentlyAskedQuestionM/QnAData/QnAData.aspx';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (IsValid == false)
        {
            return;
        }

        string script  = "";
        string message = CheckValid();

        if (message.Length > 0)
        {
            script = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
            return;
        }

        string title       = PureString(tbTitle.Text);
        string description = PureString(tbDesp.Text);

        int         state  = 0;
        RadioButton thisRb = null;

        thisRb = MyForm.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);
        if (thisRb != null)
        {
            switch (thisRb.ID)
            {
            case "rb1":
                state = 1;
                break;

            case "rb2":
                state = 2;
                break;
            }
        }

        UserVM user              = AuthServer.GetLoginUser();
        int    OutFileInfoID     = 0;
        bool   UploadFileSuccess = true;
        int    Chk = 0;

        List <int>    OutFileInfoID_List = new List <int>();
        StringBuilder errorSb            = new StringBuilder();
        string        errMsg             = "";

        if (tbFile.HasFile == true)
        {
            List <string> list = new List <string>()
            {
                "application/pdf",
                "application/msword",
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                "application/vnd.ms-excel",
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            };

            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                if (list.Contains(uploadedFile.ContentType) == false)
                {
                    errorSb.Append("alert('上傳格式限PDF、WORD、EXCEL');");
                }

                if (uploadedFile.ContentLength > 3 * 1024 * 1024)
                {
                    errorSb.Append("alert('大小限3M以內');");
                }
                errMsg = errorSb.ToString();
                if (errMsg.Length > 0)
                {
                    break;
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.RoleID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        if (errMsg.Length > 0)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", "<script>" + errMsg + "</script>", false);
            return;
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());


        if (UploadFileSuccess == true)
        {
            Dictionary <string, object> OutDict = new Dictionary <string, object>()
            {
                { "@Chk", Chk }
            };

            MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_DocumentM_xUpdateDocumentInfo"
                                 , ref OutDict
                                 , new Dictionary <string, object>()
            {
                { "@DocTitle", title },
                { "@PublishState", state },
                { "@DocDescription", description },
                { "@DocumentInfoID", ID },
                { "@FileInfoIDs", OutFileInfoIDs }
            });

            Chk = (int)OutDict["@Chk"];
        }

        if (UploadFileSuccess && Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');history.go(-1);</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string checkScript = "";
        string message     = CheckValid();

        if (message.Length > 0)
        {
            checkScript = "<script>alert('" + message + "');</script>";
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", checkScript, false);
            return;
        }


        string Account = PureString(tbAccount.Text);
        string Name    = PureString(tbName.Text);
        string Phone   = PureString(tbPhone.Text);
        string Email   = PureString(tbEmail.Text);
        string Title   = PureString(tbTitle.Text);
        string R1      = PureString(tbR1.Text);
        string R2      = PureString(tbR2.Text);
        string RID     = PureString(tbRID.Text);

        int  OutFileInfoID     = 0;
        bool UploadFileSuccess = true;
        int  Chk = 0;

        bool IsBusiness = false;

        if (cbP.Checked == true)
        {
            IsBusiness = true;
        }

        List <String> checkList = new List <string>();

        foreach (ListItem item in cbList.Items)
        {
            if (item.Selected)
            {
                checkList.Add(item.Value);
            }
        }

        List <int>    OutFileInfoID_List = new List <int>();
        StringBuilder errorSb            = new StringBuilder();
        string        errMsg             = "";

        if (tbFile.HasFile == true)
        {
            List <string> list = new List <string>()
            {
                "application/pdf",
                "application/msword",
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                //"application/vnd.ms-excel",
                //"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            };

            HttpFileCollection multipleFiles = Request.Files;

            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');

                if (ary.Length > 1)
                {
                    extension = ary.Last().ToLower();
                }

                if (list.Contains(uploadedFile.ContentType) == false)
                {
                    errorSb.Append("alert('上傳格式限PDF、WORD、EXCEL');");
                }

                if (uploadedFile.ContentLength > 3 * 1024 * 1024)
                {
                    errorSb.Append("alert('大小限3M以內');");
                }
                errMsg = errorSb.ToString();
                if (errMsg.Length > 0)
                {
                    break;
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        if (errMsg.Length > 0)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", "<script>" + errMsg + "</script>", false);
            return;
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        Dictionary <string, object> OutDict = new Dictionary <string, object>()
        {
            { "@Chk", Chk }
        };

        MSDB.ExecuteNonQuery("ConnUser", "dbo.usp_AccountM_xAddUserInfo"
                             , ref OutDict
                             , new Dictionary <string, object>()
        {
            { "@LoginName", Account },
            { "@UserName", Name },
            { "@RocID", RID },
            { "@PhoneNumber", Phone },
            { "@Email", Email },
            { "@OrgID", user.OrgID },
            { "@Title", Title },
            { "@ApplyReason", R1 },
            { "@ApplyRemark", R2 },
            { "@IsBusiness", IsBusiness },
            { "@CheckState", 1 },
            { "@SystemPowerString", 1023 },
            { "@EnableState", 1 },
            { "@CreatedUserID", user.ID },
            { "@ApplyDate", DateTime.Now },
            { "@RoleIDs", string.Join(",", checkList) },
            { "@FileInfoIDs", OutFileInfoIDs }
        });

        Chk = (int)OutDict["@Chk"];

        string script = "";

        if (Chk > 0)
        {
            script = "</script><style>body{display:none;}</style><script>alert('儲存成功');location.href = '/System/AccountM/AccountMaintain.aspx?i=" + ID + "';</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Beispiel #13
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (IsValid == false)
        {
            return;
        }
        string script = "";

        string CaseUserChName   = PureString(tbName.Text);
        string CaseUserEnName   = PureString(tbE.Text);
        string ApplyUserName    = PureString(tbA.Text);
        string UserRelationship = PureString(tbR.Text);
        var    user             = AuthServer.GetLoginUser();

        int           OutFileInfoID      = 0;
        bool          UploadFileSuccess  = true;
        List <int>    OutFileInfoID_List = new List <int>();
        StringBuilder errorSb            = new StringBuilder();
        string        errMsg             = "";

        if (tbFile.HasFile == true)
        {
            List <string> list = new List <string>()
            {
                //"application/pdf",
                "application/msword",
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                "application/vnd.ms-excel",
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            };

            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                if (list.Contains(uploadedFile.ContentType) == false)
                {
                    errorSb.Append("alert('上傳格式限WORD、EXCEL');");
                }

                if (uploadedFile.ContentLength > 3 * 1024 * 1024)
                {
                    errorSb.Append("alert('大小限3M以內');");
                }
                errMsg = errorSb.ToString();
                if (errMsg.Length > 0)
                {
                    break;
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        if (errMsg.Length > 0)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", "<script>" + errMsg + "</script>", false);
            return;
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        int         ApplyFormat = 0;
        RadioButton selected    = MyForm.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked);

        if (selected != null)
        {
            switch (selected.ID)
            {
            case "rb1":
                ApplyFormat = 1;
                break;

            case "rb2":
                ApplyFormat = 2;
                break;
            }
        }

        int Chk = 0;

        if (UploadFileSuccess == true)
        {
            Dictionary <string, object> OutDict = new Dictionary <string, object>()
            {
                { "@Chk", Chk }
            };

            MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_CertificateM_xAddApplyData"
                                 , ref OutDict
                                 , new Dictionary <string, object>()
            {
                { "@CaseUserID", CaseUserID },
                { "@CaseUserChName", CaseUserChName },
                { "@CaseUserEnName", CaseUserEnName },
                { "@ApplyUserName", ApplyUserName },
                { "@UserRelationship", UserRelationship },
                { "@CreatedUserID", user.ID },
                { "@OrgID", user.OrgID },
                { "@FileInfoIDs", OutFileInfoIDs },
                { "@ApplyFormat", ApplyFormat },
            });

            Chk = (int)OutDict["@Chk"];
        }

        if (UploadFileSuccess && Chk > 0)
        {
            script = "<style>body{display:none;}</style><script>alert('儲存成功');window.close();</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Beispiel #14
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (IsValid == false)
        {
            return;
        }
        int OrgID          = 0;
        int VaccineBatchID = 0;

        List <string> ReasonStringList = new List <string>();

        ReasonStringList.Add(PureString(tbReason1.Text));
        ReasonStringList.Add(PureString(tbReason2.Text));
        ReasonStringList.Add(PureString(tbReason3.Text));
        string ReasonString = string.Join(",", ReasonStringList);

        int ResignReason        = 0;
        int ReinoculationReason = 0;
        int EarlyLateReason     = 0;

        int.TryParse(ddlReason1.SelectedValue, out ResignReason);
        int.TryParse(ddlReason2.SelectedValue, out ReinoculationReason);
        int.TryParse(ddlReason3.SelectedValue, out EarlyLateReason);

        OrgID          = GetNumber <int>("hfAgencyID");
        VaccineBatchID = GetNumber <int>("SelectVacc");

        //int.TryParse(PureString(hfi.Value) ?? "0", out RecordDataID);
        //int.TryParse(PureString(hfc.Value) ?? "0", out CaseUserID);

        DateTime InoculationDate = DateTime.Now;

        //DateTime.TryParse(Request.Form["AD"], out AssessmentDate);
        DateTime.TryParseExact((PureString(tbDate.Text) ?? DateTime.Now.ToShortTaiwanDate()).RepublicToAD(),
                               "yyyyMMdd",
                               CultureInfo.InvariantCulture,
                               DateTimeStyles.None,
                               out InoculationDate);

        if (DateTime.Equals(InoculationDate, DateTime.MinValue) == true)
        {
            InoculationDate = DateTime.Now;
        }

        int        OutFileInfoID      = 0;
        bool       UploadFileSuccess  = true;
        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                //string fileName = Path.GetFileName(uploadedFile.FileName);
                //if (uploadedFile.ContentLength > 0)
                //{
                //    uploadedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
                //    Label1.Text += fileName + "Saved <BR>";
                //}

                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                //string[] ary = tbFile.FileName.Split('.');
                string[] ary = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string script    = "";
        bool   HasUpdate = false;
        int    Chk       = 0;

        if (UploadFileSuccess == true)
        {
            string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

            Dictionary <string, object> OutDict = new Dictionary <string, object>()
            {
                { "@HasUpdate", HasUpdate }, { "@Chk", Chk }
            };

            MSDB.ExecuteNonQuery("ConnDB", "dbo.usp_RecordM_xAddOrUpdateApplyRecord"
                                 , ref OutDict
                                 , new Dictionary <string, object>()
            {
                { "@ApplyRecordID", UpdateUID },
                { "@RecordDataID", RecordDataID },
                { "@CaseUserID", CaseUserID },
                { "@InoculationDate", InoculationDate },
                { "@OrgID", OrgID },
                { "@CreateType", 1 },
                { "@VaccineBatchID", VaccineBatchID },
                { "@CreatedUserID", user.ID },
                { "@ResignReason", ResignReason },
                { "@ReinoculationReason", ReinoculationReason },
                { "@EarlyLateReason", EarlyLateReason },
                { "@ReasonString", ReasonString },
                { "@FileInfoIDs", OutFileInfoIDs },
                { "@SpecialInoculation", cbSI.Checked },
                { "@SystemRecordVaccineID", SystemRecordVaccineID }
            });

            HasUpdate = (bool)OutDict["@HasUpdate"];
            Chk       = (int)OutDict["@Chk"];
        }

        if (UploadFileSuccess && Chk > 0)
        {
            string AddApplyRecord = " null ";
            if (HasUpdate == true)
            {
                Dictionary <string, object> dict = new Dictionary <string, object>();
                dict.Add("RID", RecordDataID);
                dict.Add("VB", VaccineBatchID);
                dict.Add("ID", InoculationDate);
                dict.Add("ON", user.OrgName);
                dict.Add("CD", DateTime.Now);
                AddApplyRecord = JsonConvert.SerializeObject(dict);
            }
            script = "<style>body{display:none;}</style><script>alert('儲存成功');window.opener.opener.AddApplyRecord(" + AddApplyRecord + ");window.close();</script>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }

        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }
Beispiel #15
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string script = "";


        string CaseUserChName   = tbName.Text.Trim();
        string CaseUserEnName   = tbE.Text.Trim();
        string ApplyUserName    = tbA.Text.Trim();
        string UserRelationship = tbR.Text.Trim();
        var    user             = AuthServer.GetLoginUser();



        int        OutFileInfoID      = 0;
        bool       UploadFileSuccess  = true;
        List <int> OutFileInfoID_List = new List <int>();

        if (tbFile.HasFile == true)
        {
            HttpFileCollection multipleFiles = Request.Files;
            for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++)
            {
                HttpPostedFile uploadedFile = multipleFiles[fileCount];
                string         extension    = "";
                string[]       ary          = uploadedFile.FileName.Split('.');
                if (ary.Length > 1)
                {
                    extension = ary.Last();
                }

                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(uploadedFile.InputStream))
                {
                    fileData = binaryReader.ReadBytes(uploadedFile.ContentLength);
                }

                NIIS_WS.WebServiceSoapClient WS = new NIIS_WS.WebServiceSoapClient();
                string contentType = tbFile.PostedFile.ContentType;
                OutFileInfoID = WS.UploadFile(1, contentType, extension, uploadedFile.FileName, user.ID, user.OrgID, fileData);

                if (OutFileInfoID < 1)
                {
                    UploadFileSuccess = false;
                    break;
                }
                else
                {
                    OutFileInfoID_List.Add(OutFileInfoID);
                }
            }
        }

        string OutFileInfoIDs = string.Join(",", OutFileInfoID_List.Select(x => x.ToString()).ToArray());

        int Chk = 0;

        if (UploadFileSuccess == true)
        {
            using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
            {
                using (SqlCommand cmd = new SqlCommand("dbo.usp_CertificateM_xAddApplyData", sc))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@CaseUserID", CaseUserID);
                    cmd.Parameters.AddWithValue("@CaseUserChName", CaseUserChName);
                    cmd.Parameters.AddWithValue("@CaseUserEnName", CaseUserEnName);
                    cmd.Parameters.AddWithValue("@ApplyUserName", ApplyUserName);
                    cmd.Parameters.AddWithValue("@UserRelationship", UserRelationship);
                    cmd.Parameters.AddWithValue("@CreatedUserID", user.ID);
                    cmd.Parameters.AddWithValue("@OrgID", user.OrgID);
                    cmd.Parameters.AddWithValue("@FileInfoIDs", OutFileInfoIDs);

                    SqlParameter sp = cmd.Parameters.AddWithValue("@Chk", Chk);
                    sp.Direction = ParameterDirection.Output;

                    sc.Open();
                    cmd.ExecuteNonQuery();

                    Chk = (int)sp.Value;
                }
            }
        }

        if (UploadFileSuccess && Chk > 0)
        {
            script = "<script>alert('儲存成功');location.href = '/System/DocumentM/DocumentMaintain.aspx';</script><style>body{display:none;}</style>";
        }
        else
        {
            script = "<script>alert('儲存失敗');</script>";
        }



        Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "alert", script, false);
    }