Beispiel #1
0
    /// <summary>
    /// 新增個案出境紀錄
    /// </summary>
    /// <param name="FileData"></param>
    /// <returns></returns>
    protected int AddEmiData(string[] FileData)
    {
        int    Status   = 0;
        string birthday = TaiwanYear.ToDateString(FileData[2]);
        string EmiDate  = TaiwanYear.ToDateString(FileData[3]);

        if (birthday.Equals("") || EmiDate.Equals(""))
        {
            return(0);
        }

        DataSet ds = new DataSet();

        using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
        {
            DataTable dt = new DataTable();
            //寫入入境資料
            using (SqlCommand cmd = new SqlCommand("usp_CaseUser_xAddImmiData", sc))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdNo", FileData[1]);
                cmd.Parameters.AddWithValue("@ImmiStatus", 1);
                cmd.Parameters.AddWithValue("@ImmiDate", EmiDate.Replace("/", ""));
                cmd.Parameters.AddWithValue("@FlightNo", "");
                cmd.Parameters.AddWithValue("@ArrivalLoc", "");
                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                {
                    sc.Open();
                    da.Fill(dt);
                }
            }
            if (dt != null && dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["bSuccess"].ToString().Equals("1"))
                {
                    Status = 1;
                }
            }
        }
        return(Status);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //base.AllowHttpMethod("POST");

        string BirthDateS;
        string BirthDateE;
        int    SearchKind = 1;
        int    OrgID      = 0;

        BirthDateS = Request.Form["BirthDateS"] ?? "";
        BirthDateE = Request.Form["BirthDateE"] ?? "";
        if (BirthDateS != "")
        {
            BirthDateS = TaiwanYear.ToDateString(BirthDateS);
        }
        if (BirthDateE != "")
        {
            BirthDateE = TaiwanYear.ToDateString(BirthDateE);
        }

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

        DataTable dt = (DataTable)DBUtil.DBOp("ConnDB", "  exec dbo.usp_CaseUser_xGetMergeUserListToExport {0},{1},{2},{3} "
                                              , new string[] {
            BirthDateS, BirthDateE, OrgID.ToString(), SearchKind.ToString()
        }, NSDBUtil.CmdOpType.ExecuteReaderReturnDataTable);


        //DataTableToCSV.DownloadCSV(dt, "MyCsv.csv");
        ExcelToolT t = new ExcelToolT();

        Response.Clear();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/download";
        Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode("99未歸戶個案維護.csv"));
        Response.BinaryWrite(((MemoryStream)t.RenderDataTableToExcel(dt)).ToArray());
        Response.End();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //base.AllowHttpMethod("POST");
        //base.DisableTop(true);
        int    pgNow = 1, pgSize = 10;
        int    OrderCol = 0, OrderAsc = 1;//0出生日期1身份證號    //1ASC 0 DESC
        int    OrgID = 0;
        int    AddrKind = 0, CountyID = 0, TownID = 0;
        int    SearchNumberType = 0;
        string BirthDateS = "", BirthDateE = "";
        string CaseName = "", CaseIdNo = "", HouseNo = "";
        string ContactName = "", ContactIdNo = "", ContactBirthDate = "";

        #region QS()
        BirthDateS       = Request.Form["BirthDateS"] ?? "";
        BirthDateE       = Request.Form["BirthDateE"] ?? "";
        ContactBirthDate = Request.Form["ContactBirthDate"] ?? "";
        if (BirthDateS != "")
        {
            BirthDateS = TaiwanYear.ToDateString(BirthDateS);
        }
        if (BirthDateE != "")
        {
            BirthDateE = TaiwanYear.ToDateString(BirthDateE);
        }
        if (ContactBirthDate != "")
        {
            ContactBirthDate = TaiwanYear.ToDateString(ContactBirthDate);
        }

        CaseName    = Request.Form["CaseName"] ?? "";
        CaseIdNo    = Request.Form["CaseIdNo"] ?? "";
        HouseNo     = Request.Form["HouseNo"] ?? "";
        ContactName = Request.Form["ContactName"] ?? "";
        ContactIdNo = Request.Form["ContactIdNo"] ?? "";

        int.TryParse(Request.Form["pgNow"], out pgNow);
        int.TryParse(Request.Form["pgSize"], out pgSize);
        int.TryParse(Request.Form["AddrKind"], out AddrKind);
        int.TryParse(Request.Form["OrgID"], out OrgID);
        int.TryParse(Request.Form["CountyID"], out CountyID);
        int.TryParse(Request.Form["TownID"], out TownID);
        int.TryParse(Request.Form["NumberType"], out SearchNumberType);

        int.TryParse(Request.Form["OrderCol"], out OrderCol);
        int.TryParse(Request.Form["OrderAsc"], out OrderAsc);


        #endregion

        OrgID = AuthServer.GetLoginUser().OrgID;


        DataTableCollection dtc = (DataTableCollection)DBUtil.DBOp("ConnDB"
                                                                   , "exec dbo.usp_CaseUser_xGetUserList {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}"
                                                                   , new string[] { pgNow.ToString()
                                                                                    , pgSize.ToString()
                                                                                    , OrderCol.ToString()
                                                                                    , OrderAsc.ToString()
                                                                                    , CaseName
                                                                                    , CaseIdNo
                                                                                    , BirthDateS
                                                                                    , BirthDateE
                                                                                    , HouseNo
                                                                                    , AddrKind.ToString()
                                                                                    , ContactName
                                                                                    , ContactIdNo
                                                                                    , ContactBirthDate
                                                                                    , OrgID.ToString() //請帶入想查看的ORG   //若沒得選 請帶入目前登入user.org
                                                                                    , CountyID.ToString()
                                                                                    , TownID.ToString()
                                                                                    , SearchNumberType.ToString() }, NSDBUtil.CmdOpType.ExecuteReaderReturnDataTableCollection);



        List <UserProfileListVM> list = new List <UserProfileListVM>();
        PageVM rtn = new PageVM();

        EntityS.FillModel(list, dtc[0]);
        EntityS.FillModel(rtn, dtc[1]);
        rtn.message = list;

        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn));
        Response.End();
    }
  protected void btnSave_Click(object sender, EventArgs e)
  {
      List <string> RequestKeys = Request.Form.AllKeys.Where(key => key.Contains("ddlVaccineCode_") || key.Contains("ddlNotNeedOrRejectReason_") || key.Contains("tbPrDate_")).ToList();

      UserVM user   = AuthServer.GetLoginUser();
      string VacIDs = hdVac.Value ?? "";

      string[] Vac         = VacIDs.Split(',');
      string   VisitResult = ddlVisitResult.SelectedValue;
      string   spName      = (VisitID != 0 ? "usp_CaseVisit_xEdit" : "usp_CaseVisit_xAdd");

      DataTable dt = (DataTable)DBUtil.DBOp("ConnDB",
                                            "exec  [dbo].[" + spName + "]  {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}   "
                                            , new string[] {
            TaiwanYear.ToDateString(tbVisitDate.Text)
            , (VisitID != 0 ? VisitID.ToString() : CaseID.ToString())
            , ddlVisitMan.SelectedValue
            , ddlVisitType.SelectedValue
            , ddlVisitReason.SelectedValue
            , VisitResult
            , tbVisitComment.Text
            , user.ID.ToString()
            , user.OrgID.ToString()
            , TaiwanYear.ToDateString(tbPreBackDate.Text)
            , ddlCountry.SelectedValue
        }, NSDBUtil.CmdOpType.ExecuteReaderReturnDataTable);



      int NewVisitID = 0;

      if (dt.Rows.Count > 0)
      {
          NewVisitID = Convert.ToInt32(dt.Rows[0][0]);
          CaseID     = Convert.ToInt32(dt.Rows[0][1]);
          handlefile(NewVisitID);
      }


      DBUtil.DBOp("ConnDB", "  UPDATE [dbo].[C_CaseVisitDetail] SET  [LogicDel] = 1 where VisitID={0} "
                  , new string[] { NewVisitID.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery);

      //Response.Write(VacIDs);
      //Response.End();
      foreach (string v in Vac)
      {
          string VacIDSeq = "", VisitResultDetailID = "0", PrejectDate = "", VacID = "", Seq = "";

          VacIDSeq            = Request.Form [RequestKeys.Find(r => r.Contains("ddlVaccineCode_" + v))] ?? "";
          VacID               = (VacIDSeq == "" ?v: VacIDSeq.Split('-')[0]);
          Seq                 = (VacIDSeq.Split('-').Length > 1 ? VacIDSeq.Split('-')[1] :"");
          VisitResultDetailID = Request.Form [RequestKeys.Find(r => r.Contains("ddlNotNeedOrRejectReason_" + v))] ?? "";
          PrejectDate         = TaiwanYear.ToDateString(Request.Form[RequestKeys.Find(r => r.Contains("tbPrDate_" + v))] ?? "");

          DBUtil.DBOp("ConnDB", " exec [dbo].[usp_CaseVisit_xAddDetail]   {0},{1},{2} ,{3},{4}   "
                      , new string[] { NewVisitID.ToString(), VacID, Seq, VisitResultDetailID, PrejectDate }, NSDBUtil.CmdOpType.ExecuteNonQuery);
      }

      //更新個人紀錄
      DBUtil.DBOp("ConnDB", " exec [dbo].[usp_CaseVisit_xUpdateRecordData]  {0} "
                  , new string[] { NewVisitID.ToString() }, NSDBUtil.CmdOpType.ExecuteNonQuery);



      Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('成功!');location.href='VisitCaseList.aspx?i=" + CaseID.ToString() + "';", true);
  }