2024年8月19日 星期一

V80202M –Finding處置匯入 –[挑選檔案]元件 –自訂畫面 –格式下載 - transaction - file - get_cmp_file1()

 目的: V80202M –Finding處置匯入  挑選檔案  自訂畫面 格式下載 - transaction

處理說明:   1>[挑選檔案]元件  - get_cmp_file1()
                        var cmp_SelFile = get_cmp_file1("sub_File");                                               
                    2>取得檔案名稱
                        Tmp_FName = Ext.getCmp("sub_File").getValue();                
                    3>後端讀取檔案內容
                        Stream Tmp_in_Stream = Request.Files[cur_FName].InputStream;     
                        wk.LoadFromStream(Tmp_in_Stream);
                        Worksheet sheet1 = wk.Worksheets[0];                
                        Tmp_SAPNO = sheet1.Range[myfunc.GetExcelPos(0, 0)].Value; 
                    4>取得 Cookie 的內容(後端傳回訊息)
                         Tmp_Str = "Finding處置匯入完成!!(" + Tmp_rowcnt.ToString() + "筆)<br>"
                                          + "匯入檔案名稱(" + Tmp_FName + ")";
                         MyCookie.Value = HttpUtility.UrlEncode(Tmp_Str);
                         HttpContext.Current.Response.Cookies.Add(MyCookie);
                         HttpContext.Current.Response.End(); 
    


1>*.js
   //1>> [挑選檔案]元件
   var cmp_SelFile = get_cmp_file1("sub_File");
// [工作中心報工匯出]鈕  - 子畫面欄位
    var J_formFields_Sub3 = [
        {
            bodyStyle: "background-color:transparent;", xtype: 'panel', border: 0, layout: { type: 'vbox', align: 'stretch' }, padding: "5", flex: 1,
            items: [cmp_SelFile,],
       },  // end of  檔案來源 2
                {  // space 空間                   
                    bodyStyle: "background-color:transparent;", xtype: 'panel', border: 0, layout: "vbox", padding: "0", flex: 1, width: 300, items: [],
                        }           
    ];  

//2>>取得 [檔案上傳].檔名
    var Tmp_FName = Ext.getCmp('sub_File').getValue();
    var np = {};
    np["sub_FName"] = Tmp_FName;

//3>>取得後端傳回值  []
var timer = setInterval(function () {
        var cookie_token = Ext.util.Cookies.get("Rtn_Msg");
        if (cookie_token != null) {
            clearInterval(timer);
            timer = null;
            //mask.hide();            
            var rtn_msg = r_cookies("Rtn_Msg");
            //mysuccessalert("[件號報工匯出]匯出完成");
            mysuccessalert(rtn_msg);
            me.up("window").close();
            me.up("window").destroy();
        }
    }, 2000);  //等待 2000ms =1se


2>*.cs  - 讀取前端檔案內容
      HttpRequest Request = HttpContext.Current.Request;
      var response = this.Request.CreateResponse();

1>>讀取前端檔案內容
foreach (string cur_FName in Request.Files)
{
    Stream Tmp_in_Stream = Request.Files[cur_FName].InputStream;
    wk = new Workbook();
    wk.LoadFromStream(Tmp_in_Stream);
    Worksheet sheet1 = wk.Worksheets[0];                
    Tmp_SAPNO = sheet1.Range[myfunc.GetExcelPos(0, 0)].Value; 


2>>transaction 
// Transaction SQL List - 存放  Transaction 的 SQL 
List<string> SQL_List_A = new List<string>();

Tmp_Sql = " UPDATE   AMM_SRO  "
                + "  SET          QDRWKTP=" + myfunc.AA(Tmp_QDRWKTP.Trim())
                + "  WHERE   SAPNO=" + myfunc.AA(Tmp_SAPNO.Trim());
SQL_List_A.Add(Tmp_Sql);

excuteSQLTran(SQL_List_A);


3>>設定 Cookie 內容
HttpCookie MyCookie = new HttpCookie("Rtn_Msg");
Tmp_Str = "Finding處置匯入完成!!(" + Tmp_rowcnt.ToString() + "筆)<br>"
                            + "匯入檔案名稱(" + Tmp_FName + ")";
MyCookie.Value = HttpUtility.UrlEncode(Tmp_Str);
HttpContext.Current.Response.Cookies.Add(MyCookie);
HttpContext.Current.Response.End();


4>[匯入格式下載]
 {
   xtype: 'button', text: '匯入格式下載', id: 'DnFileBtn_Sub3',
   listeners: {
   click: function () {
       document.location = "../api/VUTLAPI/dnloadSS_File?FNAME=V80202_Finding處置匯入格式.xlsx";    
                }
            }
        },

沒有留言:

張貼留言