Ejemplo n.º 1
0
    private void DataExport()
    {

        string SessionIDName = "IVM10_Error" + PageTimeStamp.Value;

        ParameterList.Clear();
        ParameterList.Add(this.txtRemoveNo.Text);
        ParameterList.Add(Session["UID"].ToString() + PageTimeStamp.Value);
        ParameterList.Add(this.SLP_User1.Text);

        IVMModel.MaintainRemoveImport bco = new IVMModel.MaintainRemoveImport(ConntionDB);

        DataTable dt = bco.GetErrorDataSheet(ParameterList);

        if (dt == null || (dt != null && dt.Rows.Count <= 0))
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", "alert('查無資料');", true);
        }

        Session[SessionIDName] = dt;

    }
Ejemplo n.º 2
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            UpdatePanel6.Update();

            int RemoveID = -1;

            string V_OK = "";

            int ErrorCnt = 0;

            string V_Msg = "";

            if (GridView1.Rows.Count > 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "alert('明細區有資料時不允許執行檔案匯入');", true);
                return;
            }

            string strUploadPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["UploadPath"]).Replace("IVM\\", "") + "\\IVM\\";

            string strUploadMessage = FileUpload(strUploadPath, this.FileUpload1, Session["UID"].ToString());

            string[] strMsg = strUploadMessage.Split('|');

            if (strMsg[0].ToString() == "1")
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "隨便寫", "alert('" + strMsg[1].ToString() + "');", true);
                return;
            }

            //將檔案資料讀取進TEMP_TABLE

            IVMModel.MaintainRemoveImport BCO = new IVMModel.MaintainRemoveImport(ConntionDB);

            ArrayList ErrorRows = new ArrayList();

            BCO.FileToTmp(Session["UID"].ToString() + PageTimeStamp.Value, DateTime.Now.ToString("yyyyMMddHHmmss"),
                Session["UID"].ToString(), strMsg[1].ToString(), this.SLP_CodeFile1.Text,
                null, out ErrorRows, out V_OK, out RemoveID, out ErrorCnt, out V_Msg);

            if (ErrorRows.Count > 0)
            {
                string strErrRow = "";

                for (int i = 0; i < ErrorRows.Count; i++)
                {
                    strErrRow += ErrorRows[i].ToString() + ",";
                }

                strErrRow = strErrRow.Substring(0, strErrRow.Length - 1);

                ErrorMsgLabel.Text = "第" + strErrRow + "筆資料格式錯誤";

                UpdatePanel6.Update();

                return;
            }

            if (V_Msg == "0")
            {
                if (V_OK == "0")
                {
                    ErrorMsgLabel.Text = "無可建單資料";
                    UpdatePanel6.Update();
                }
                else
                {
                    if (RemoveID != -1)
                    {
                        ArrayList IDList = new ArrayList();
                        IDList.Add(RemoveID);

                        Session["IVM10QueryID"] = IDList;
                        Response.Redirect(string.Format("IVM102.aspx?ID={0}&PageMode=1&Code=IVM10&ErrorCnt={1}", RemoveID, ErrorCnt));
                    }
                    else
                    {
                        ErrorMsgLabel.Text = V_Msg;
                        UpdatePanel6.Update();
                    }
                }

                if (ErrorCnt > 0)
                {
                    btnError.Visible = true;
                    UpdatePanel5.Update();
                }

            }
            else
            {
                ErrorMsgLabel.Text = V_Msg;
                UpdatePanel6.Update();
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
            UpdatePanel6.Update();
        }
    }