2024年7月29日 星期一

V80404 - 挑選資料 - Cache 是否最新資料的機制 - 若非最新資料,則需重抓資料 - setupPickDs - getPickDsbyCondi

目的: V80404 - 挑選資料 - Cache 是否最新資料的機制 - 若非最新資料,則需重抓資料

處理說明: 1>建立 Cache DataSet
                      DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "CSM_AF" });
// //public DataSet setupPickDs(string pickKey, string sql, string[] tables, bool paging = true, bool realTime = false)

                  2>由 Cache DataSet 過濾資料
                      ds = getPickDsbyCondi(n, "GONOAF='" + GONOAF + "'");   





1>*.js
[HttpPost]
        public dynamic get_s_GONOAFPick(string GONOAF = "", int isComplete = 0)
        {
            DBLINK = "TLSEU";
            string Tmp_Sql = " SELECT DISTINCT GONOAF   "
                                       + "  from     CSM_AF "
                                       + " ORDER  BY  GONOAF ";
            string n = funId + "s_GONOAF";
             // TableName 有@會Error , 所以先設定 DBLink 
             //public DataSet setupPickDs(string pickKey, string sql, string[] tables, bool paging = true, bool realTime = false)
             //建立 PickDs , 若已存在,則直接取用目前 Cache DataSet
            //DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "CSM_AF@TLS_245" });  
            DataSet ds = setupPickDs(n, Tmp_Sql, new string[] { "CSM_AF" });
            if (GONOAF != null && !GONOAF.Equals(""))
            {
                if (isComplete == 1)
                {
                     ////由 Cache DataSet 過濾資料  
                     ds = getPickDsbyCondi(n, "GONOAF='" + GONOAF + "'");
                }
                else
                {
                    ds = getPickDsbyCondi(n, "GONOAF  LIKE '%" + GONOAF + "%'");
                }
            }
            return ds;
        }  // end of  get_s_GONOAFPick

2024年7月17日 星期三

V20304A –sub_Grid –[需求工時]欄位,為數字欄位且允許編輯

 目的: V20304A –sub_Grid –[需求工時]欄位,為數字欄位且允許編輯

處理說明:1>Grid 設定為每行編輯模式
                     var sub_Grid = Ext.create('TMGrid', {
                                                  plugins: [
                                                       Ext.create('Ext.grid.plugin.RowEditing', {
                                                       clicksToEdit: 1,
                                                       clicksToMoveEditor: 2,
                                                       autoCancel: false
                                                     })],
                                                    });
                   2>Grid.[需求時數][備註] 欄位設定可編輯   
{
header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float",
renderer: Ext.util.Format.numberRenderer('000.00'),
editor: { xtype: 'numberfield', allowBlank: true }, //允許空白
 },
{
header: "備註", dataIndex: "REMARK", width: 250, sortable: false, TMType: "string",
editor: { xtype: 'textfield', allowBlank: true }, //允許空白
},


1>*.js  - V20304A.js

var sub_Grid = Ext.create('TMGrid', {
grid_id: 'sub_Grid',
columns: sub_Columns,
flex: 1,
store: Ext.create('gridstore', { model: sub_model }),
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1,
clicksToMoveEditor: 2,
autoCancel: false
})],

});


2>V20304A_JSON.js
var sub_Columns = [
{ header: "", xtype: "rownumberer", width: 40, align: "center", sortable: false },
{ header: "AMM項次", dataIndex: "AMINO", width: 80, sortable: false, TMType: "string" },
{ header: "項次", dataIndex: "ITMNO", width: 70, sortable: false, TMType: "string" },
{ header: "工作項目", dataIndex: "WKDESC", width: 150, sortable: false, TMType: "string" },
{
header: "標準工時", dataIndex: "STDHR", width: 70, sortable: false, align: "right", TMType: "float",
renderer: Ext.util.Format.numberRenderer('0,000.00')
},
{
header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float",
renderer: Ext.util.Format.numberRenderer('000.00'),
editor: { xtype: 'numberfield', allowBlank: true }, //允許空白
 },
{
header: "備註", dataIndex: "REMARK", width: 250, sortable: false, TMType: "string",
editor: { xtype: 'textfield', allowBlank: true }, //允許空白
},
//{ header: "件號專用表單編號", dataIndex: "PNSHTNO", width: 500, sortable: false, TMType: "string" }
];






V20304A – 工時提列 –編輯完[需求工時]欄位後,維持在原本的行號,不自動跳至第1筆

 目的: V20304A – 工時提列 編輯完[需求工時]欄位後,維持在原本的行號,不自動跳至第1

處理說明 : 1>






var sub_Grid = Ext.create('TMGrid', {
            grid_id: 'sub_Grid',
            columns: sub_Columns,
            //autoScroll: true,
            flex: 1,
            store: Ext.create('gridstore', { model: sub_model }),
            plugins: [
                //Ext.create('Ext.grid.plugin.CellEditing', {   // 編輯後,會跳至第1筆,若要編輯下一筆,要重新 Scroll
                //    clicksToEdit: 1,                           // 按一下進行編輯,預設為按兩下
                //    clicksToMoveEditor: 1,            //在編輯模式下切換編輯另一行的行為1表示點選一就切換;2表示點2下才切換。
                //})],
            Ext.create('Ext.grid.plugin.RowEditing', { //編輯後,停留在目前行號,不跳至第一筆
                clicksToEdit: 1,
                clicksToMoveEditor: 1,
                autoCancel: false
            })],
        });

var sub_Columns = [
    { header: "", xtype: "rownumberer", width: 40, align: "center", sortable: false },
    //{ header: "系統件單號", dataIndex: "FMNO", width: 130, sortable: false, TMType: "string" },
    { header: "AMM項次", dataIndex: "AMINO", width: 80, sortable: false, TMType: "string" },
    //{ header: "流水序號", dataIndex: "ITM", width: 50, sortable: false, TMType: "string" },
    { header: "項次", dataIndex: "ITMNO", width: 70, sortable: false, TMType: "string" },
    { header: "工作項目", dataIndex: "WKDESC", width: 150, sortable: false, TMType: "string" },
    { header: "標準工時", dataIndex: "STDHR", width: 70, sortable: false, align: "right", TMType: "float", renderer: Ext.util.Format.numberRenderer('0,000.00') },
    {
        header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float",
        renderer: Ext.util.Format.numberRenderer('0,000.00'),
        editor: { xtype: 'textfield', allowBlank: true }, //允許空白
        //editor: 'textfield',
    },
    {
        header: "備註", dataIndex: "REMARK", width: 250, sortable: false, TMType: "string",
        editor: { xtype: 'textfield', allowBlank: true }, //允許空白
        },
    //{ header: "件號專用表單編號", dataIndex: "PNSHTNO", width: 500, sortable: false, TMType: "string" }
];

V20304D1 –執行成功後,顯示執行完成訊息, 按[確定]後,才重新顯示資料 – mysucessalert(Tmp_str,func);

 目的:V20304D1 –執行成功後,顯示執行完成訊息, [確定],才重新顯示資料 
            – mysucessalert(Tmp_str,func);

處理說明:  1> mysuccessalert(Tmp_Str, function () {
                              Ext.getCmp("btn_Show").fireHandler();
                     })






1>*.js
 Ext.Ajax.request({
        method: 'POST',
        params: np,
        async: false, //將非同步功能關閉
        url: '../../api/V20304D1API/sendmail6',
        success: function (response, opts) {
            Tmp_Str = "已Email 通知相關品保人員<br>"
                             +"執行品保工時維護( V2030A) !!";
            mysuccessalert(Tmp_Str, function () {
                Ext.getCmp("btn_Show").fireHandler();
            })
            //var id = confirm(Tmp_Str);
            //if (id) {
            //    Ext.getCmp("btn_Show").fireHandler();
            //}
            
            //關閉視窗
            Ext.getCmp("sub_ShowEmail_OkBtn").up("window").close();
            Ext.getCmp("sub_ShowEmail_OkBtn").up("window").destroy();            
        },
        failure: function (response, opts) {
            mywarnalert('Email  通知相關人員失敗, 請檢查:' + response.status);
        }
    });  // end of  Ext.Ajax.Request  for Email

2024年7月15日 星期一

C# AND OR 用法 - && || - 不可直接寫 AND OR

 目的: C#   AND  OR 用法  - &&   ||   - 不可直接寫 AND   OR 

處理說明:  1> C#   AND   - &&   
                                OR   =  ||


  if ((Tmp_IRESAK == "3") || (Tmp_IRESAK == "4"))
                    {
                        Tmp_RDRNAL = "VR-RDR";
                        Tmp_NEXT_RJCN = get_NEXT_RJCN();
                        Tmp_Sql = " INSERT   INTO   CSM_RDR  "
                                       + "(  RDRNAL,RJCN,"
                                          + " RPNOAF,DAYRDR,RPN,RNSN,RSN,RBTHAF,"
                                          + " RQTY,C_UNIT,CAGE ) "
                                       + " VALUES  "
                                       + "(" + myfunc.AA(Tmp_RDRNAL) + "," + myfunc.AA(Tmp_NEXT_RJCN.ToString()) + ","
                                              + myfunc.AA(Tmp_RPNOAF) + "," + myfunc.AA("180") + "," + myfunc.AA(Tmp_PN) + "," + myfunc.AA(Tmp_NSN) + "," + myfunc.AA(Tmp_SEQOAF) + "," + myfunc.AA(Tmp_RBTHAF) + ","
                                              + myfunc.AA("1") + "," + myfunc.AA("EA") + "," + myfunc.AA(Tmp_CAGE) + ")";
                        myfunc.SqlExec(Tmp_Sql);
                    }  //end of     if ((Tmp_IRESAK=="3") OR(Tmp_IRESAK == "4")){

2024年7月12日 星期五

V20304D – 確認轉TLS – 將所勾選的資料,存入StringList , 再轉成字串 -List

 目的: V20304D – 確認轉TLS – 將所勾選的資料,存入StringList , 再轉成字串

處理說明:    1>>宣告 List<string> 儲存 string List
                                                  List<String> List_OGONOAF = new List<string>();
                    2>加入 string List 
                          for (var i = 0; i < dt1.Rows.Count; i++)
                         {
                               if (List_OGONOAF.IndexOf(Tmp_OGONOAF) == -1)
                                 {  List_OGONOAF.Add(Tmp_OGONOAF); }
                     3> StringList 轉成字串
           //將勾選的[提領編號][件號][交修件號存入 cookie V20304D_content6
            string Tmp_List_OGONOAF= String.Join(", ", List_OGONOAF.ToArray());


1>*.cs

//1>>宣告 List<string> 儲存 string List
    List<String> List_OGONOAF = new List<string>();
    List<String> List_PN = new List<string>();
    List<String> List_RPNOAF = new List<string>();
 
//2>加入 string List 
for (var i = 0; i < dt1.Rows.Count; i++)
    {
  if (List_OGONOAF.IndexOf(Tmp_OGONOAF) == -1)
      {  List_OGONOAF.Add(Tmp_OGONOAF); }
      if (List_RPNOAF.IndexOf(Tmp_RPNOAF) == -1)
      {  List_RPNOAF.Add(Tmp_RPNOAF); }
      if (List_PN.IndexOf(Tmp_PN) == -1)
      {  List_PN.Add(Tmp_PN); }
}
     //3> StringList 轉成字串
//將勾選的[提領編號][件號][交修件號存入 cookie V20304D_content6
      string Tmp_List_OGONOAF= String.Join(", ", List_OGONOAF.ToArray());
      string Tmp_List_PN = String.Join(", ", List_PN.ToArray());
      string Tmp_List_RPNOAF = String.Join(",", List_RPNOAF.ToArray());
      string Tmp_V20304D_content6 = "提領編號:" + Tmp_List_OGONOAF + "\r\n"
                                + "維修件號:" + Tmp_List_PN + "\r\n"
                                + "交修單號:" + Tmp_List_RPNOAF + "\r\n";
      MyCookie1 = new HttpCookie("V20304D_content6", HttpUtility.UrlEncode(Tmp_V20304D_content6));
      HttpContext.Current.Response.Cookies.Add(MyCookie1);
      HttpContext.Current.ApplicationInstance.CompleteRequest();

2024年7月7日 星期日

V20304A – 1>將空字串維持空字串, 小數的位數維持2位小數 – 即 model 的數值不轉換(convert) - renderer時若為小數,則格式化

目的: V20304A – 1>將空字串維持空字串, 小數的位數維持2位小數
                                  – 即 model 的數值不轉換(convert)
                             2>將空字串變成 0.00,小數的位數維持2位小數 – 即 model的數值,需轉換
                             3>輸出的數量,小數的格式(0000.00) – 即columns的 renderer的數值,需格式化

處理說明: 1>將空字串維持空字串,  - model
                         {  name: "RQHR",
                            //convert: function (value, record) { return Ext.util.Format.round(value, 2); }
                           },
                     2>小數欄位輸出的格式 : 0000.00
                        {
        header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float",
        renderer: Ext.util.Format.numberRenderer('0,000.00'),
        editor: { xtype: 'textfield', allowBlank: true }, //允許空白
    },


1>V20304A_JSON.js
var sub_model = [
    { name: "FMNO" },
    { name: "AMINO" },
    { name: "ITM" },
    { name: "ITMNO" },
    { name: "WKDESC" },
    {
        name: "STDHR",
        convert: function (value, record) { return Ext.util.Format.round(value, 2); }
    },
    {
        name: "RQHR",
        //convert: function (value, record) { return Ext.util.Format.round(value, 2); }
    },
    { name: "REMARK" },
    { name: "PNSHTNO" }
];

var sub_Columns = [
    { header: "", xtype: "rownumberer", width: 40, align: "center", sortable: false },
    //{ header: "系統件單號", dataIndex: "FMNO", width: 130, sortable: false, TMType: "string" },
    { header: "AMM項次", dataIndex: "AMINO", width: 80, sortable: false, TMType: "string" },
    //{ header: "流水序號", dataIndex: "ITM", width: 50, sortable: false, TMType: "string" },
    { header: "項次", dataIndex: "ITMNO", width: 70, sortable: false, TMType: "string" },
    { header: "工作項目", dataIndex: "WKDESC", width: 150, sortable: false, TMType: "string" },
    { header: "標準工時", dataIndex: "STDHR", width: 70, sortable: false, align: "right", TMType: "float", renderer: Ext.util.Format.numberRenderer('0,000.00') },
    {
        header: "需求工時", dataIndex: "RQHR", width: 70, sortable: false, align: "right", TMType: "float",
        renderer: Ext.util.Format.numberRenderer('0,000.00'),
        editor: { xtype: 'textfield', allowBlank: true }, //允許空白
        //editor: 'textfield',
    },
    {
        header: "備註", dataIndex: "REMARK", width: 250, sortable: false, TMType: "string",
        editor: { xtype: 'textfield', allowBlank: true }, //允許空白
        },
    //{ header: "件號專用表單編號", dataIndex: "PNSHTNO", width: 500, sortable: false, TMType: "string" }
];