protected override ResultStatus Save(PokeBall pokeBall) { base.Save(gcMain); daoLOGV = new LOGV(); DataTable dt = (DataTable)gcMain.DataSource; DataTable dtProdType = daoAPDK_PARAM.ListAll2(); DataTable dtChange = dt.GetChanges(); DataTable dtForAdd = dt.GetChanges(DataRowState.Added); DataTable dtForModified = dt.GetChanges(DataRowState.Modified); if (dtChange == null) { MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(ResultStatus.Fail); } if (dtChange.Rows.Count == 0) { MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(ResultStatus.Fail); } //Update to DB else { string val1, val2, val3, val4; string prodType, subProdType; //隱藏欄位賦值 foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Added) { dr["AM7T_W_TIME"] = DateTime.Now; dr["AM7T_W_USER_ID"] = GlobalInfo.USER_ID; //從下拉選單的table去取得對應的商品類別和副類別 string selectStr = "PARAM_KEY=" + "'" + dr["AM7T_PARAM_KEY"] + "'"; prodType = dtProdType.Select(selectStr)[0]["PARAM_PROD_TYPE"].ToString(); subProdType = dtProdType.Select(selectStr)[0]["PARAM_PROD_SUBTYPE"].ToString(); dr["AM7T_PROD_TYPE"] = prodType; dr["AM7T_PROD_SUBTYPE"] = subProdType; } if (dr.RowState == DataRowState.Modified) { dr["AM7T_W_TIME"] = DateTime.Now; dr["AM7T_W_USER_ID"] = GlobalInfo.USER_ID; //寫LOGV val1 = dr["AM7T_Y"].AsString(); val2 = dr["AM7T_PARAM_KEY"].AsString(); val3 = dr["ORG_DAY_COUNT"].AsString() + "->" + dr["AM7T_DAY_COUNT"].AsString(); val4 = dr["ORG_AVG_QNTY"].AsString() + "->" + dr["AM7T_AVG_QNTY"].AsString(); daoLOGV.Insert(_ProgramID, GlobalInfo.USER_ID, "U", val1, val2, val3, val4, ""); } } ResultData myResultData = daoAM7T.UpdateAM7T(dt); if (myResultData.Status == ResultStatus.Fail) { MessageDisplay.Error("更新資料庫AM7T錯誤! "); return(ResultStatus.Fail); } //列印(新增/刪除/修改) PrintOrExportChangedByKen(gcMain, dtForAdd, dtForDeleted, dtForModified); dtForDeleted.Clear(); _IsPreventFlowPrint = true; } //不要自動列印 _IsPreventFlowPrint = true; return(ResultStatus.Success); }
protected override ResultStatus Save(PokeBall pokeBall) { base.Save(gcMain); daoLOGV = new LOGV(); DataTable dt = (DataTable)gcMain.DataSource; DataTable dtChange = dt.GetChanges(); if (dtChange == null) { MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(ResultStatus.Fail); } if (dtChange.Rows.Count == 0) { MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(ResultStatus.Fail); } //Update to DB else { string type, val1, val2, val3, val4, val5; //隱藏欄位賦值 foreach (DataRow dr in dt.Rows) { if (dr.RowState == DataRowState.Added) { dr["AM7_FC_QNTY"] = 0; dr["OP_TYPE"] = "I"; //寫LOGV type = dr["OP_TYPE"].AsString(); val1 = dr["AM7_Y"].AsString(); val2 = dr["AM7_DAY_COUNT"].AsString(); val3 = dr["AM7_FUT_AVG_QNTY"].AsString(); val4 = dr["AM7_OPT_AVG_QNTY"].AsString(); val5 = dr["AM7_FC_TAX"].AsString(); daoLOGV.Insert(_ProgramID, GlobalInfo.USER_ID, type, val1, val2, val3, val4, val5); } if (dr.RowState == DataRowState.Modified) { dr["OP_TYPE"] = "U"; //寫LOGV type = dr["OP_TYPE"].AsString(); val1 = dr["AM7_Y"].AsString(); val2 = dr["AM7_DAY_COUNT"].AsString(); val3 = dr["AM7_FUT_AVG_QNTY"].AsString(); val4 = dr["AM7_OPT_AVG_QNTY"].AsString(); val5 = dr["AM7_FC_TAX"].AsString(); daoLOGV.Insert(_ProgramID, GlobalInfo.USER_ID, type, val1, val2, val3, val4, val5); } } ResultData myResultData = daoAM7.UpdateAM7(dt); if (myResultData.Status == ResultStatus.Fail) { MessageDisplay.Error("更新資料庫AM7錯誤! "); return(ResultStatus.Fail); } } //不要自動列印 _IsPreventFlowPrint = true; return(ResultStatus.Success); }