Пример #1
0
    void ucGridView1_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e)
    {
        string    strCmd = e.CommandName;
        DataTable dt     = e.DataTable;

        if (dt != null && dt.Rows.Count > 0)
        {
            UserInfo      oUser = UserInfo.getUserInfo();
            DbHelper      db    = new DbHelper(LegalSample._LegalSysDBName);
            CommandHelper sb    = db.CreateCommandHelper();
            sb.Reset();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                switch (e.CommandName)
                {
                case "cmdUpdateAll":
                    sb.AppendStatement(string.Format("Update {0} Set DocNo = DocNo ", LegalSample._LegalDocTableName));
                    for (int j = 1; j < dt.Columns.Count; j++)
                    {
                        sb.Append(" ," + dt.Columns[j].ColumnName + " = ").AppendParameter(dt.Columns[j].ColumnName + i, dt.Rows[i][j].ToString());
                    }
                    sb.Append(" ,UpdUser = "******"UserID", oUser.UserID);
                    sb.Append(" ,UpdUserName = "******"UserName", oUser.UserName);
                    sb.Append(" ,UpdDateTime = ").AppendDbDateTime();
                    sb.Append(" Where 0=0 ");
                    sb.Append(" And DocNo  =").AppendParameter("DocNo" + i, dt.Rows[i][0].ToString().Split(',')[0]);
                    break;

                default:
                    break;
                }
            }

            DbConnection  cn = db.OpenConnection();
            DbTransaction tx = cn.BeginTransaction();
            try
            {
                db.ExecuteNonQuery(sb.BuildCommand(), tx);
                tx.Commit();
                Util.NotifyMsg(RS.Resources.Msg_Succeed, Util.NotifyKind.Success); //處理成功
            }
            catch
            {
                tx.Rollback();
                Util.NotifyMsg(RS.Resources.Msg_Error, Util.NotifyKind.Error); //處理失敗
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                tx.Dispose();
            }
        }
        else
        {
            Util.MsgBox(RS.Resources.Msg_DataNotFound);
        }
    }
Пример #2
0
 void ucGridView_Fix_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e)
 {
     if (e.CommandName == "cmdExportOpenXml" && !string.IsNullOrEmpty(ucGridView_Fix.ucExportOpenXmlPassword))
     {
         Util.MsgBox(string.Format("Excel 密碼為 [<b>{0}</b>] ,請妥善保存!", ucGridView_Fix.ucExportOpenXmlPassword));
     }
     else
     {
         Util.MsgBox(string.Format("<b>GridViewCommand</b><hr>Cmd=[{0}]", e.CommandName));
     }
 }
Пример #3
0
    void ucGridView1_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e)
    {
        DbHelper      db = new DbHelper(_DBName);
        CommandHelper sb = db.CreateCommandHelper();
        DataTable     dt = e.DataTable;

        if (dt != null && dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sb.AppendStatement("Update ").Append(_TableName).Append(" set UpdDateTime   = ").AppendDbDateTime();
                sb.Append(" , UpdUser = "******"UpdUser", UserInfo.getUserInfo().UserID);

                for (int j = 1; j < dt.Columns.Count; j++)
                {
                    sb.Append(" ," + dt.Columns[j].ColumnName + " = ").AppendParameter(dt.Columns[j].ColumnName + i, dt.Rows[i][j].ToString());
                }
                sb.Append(" Where 0=0 ");
                sb.Append(Util.getDataQueryKeySQL(_PKList, dt.Rows[i][0].ToString().Split(',')));
            }

            DbConnection  cn = db.OpenConnection();
            DbTransaction tx = cn.BeginTransaction();
            try
            {
                db.ExecuteNonQuery(sb.BuildCommand(), tx);
                tx.Commit();
                Util.NotifyMsg(RS.Resources.Msg_EditSucceed, Util.NotifyKind.Success);
            }
            catch
            {
                tx.Rollback();
                Util.NotifyMsg(RS.Resources.Msg_EditFail, Util.NotifyKind.Error);
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                tx.Dispose();
            }
        }
    }
Пример #4
0
    /// <summary>
    /// gvProxyTodoList 呼叫批次審核
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void gvProxyTodoList_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e)
    {
        DataTable dtVerify = getBatchVerifyData(e.DataTable, gvProxyTodoList.ucDataQryTable);

        if (dtVerify != null && dtVerify.Rows.Count > 0)
        {
            if (e.DataTable.Rows.Count > dtVerify.Rows.Count)
            {
                //若[批次審核]筆數少於原始傳遞筆數 2016.08.17
                Util.NotifyMsg(string.Format(WorkRS.Resources.FlowVerifyMsg_BatchVerifyCaseAutoIgnore1, e.DataTable.Rows.Count - dtVerify.Rows.Count));
            }

            StartBatchVerify(dtVerify);
        }
        else
        {
            //2016.08.17 改用 NotifyMsg 方式
            Util.NotifyMsg(WorkRS.Resources.FlowVerifyMsg_BatchVerifyCaseNotFound, Util.NotifyKind.Error);
        }
    }
Пример #5
0
    void ucGridDetail_GridViewCommand(object sender, Util_ucGridView.GridViewEventArgs e)
    {
        if (e.CommandName.Contains("cmdExport"))
        {
            ucGridDetail2.Refresh();
            return;
        }

        //承接明細檔 GridView 線上編輯模式結果
        DbHelper      db = new DbHelper(_DBName);
        CommandHelper sb = db.CreateCommandHelper();
        DataTable     dt = e.DataTable;

        if (dt == null || dt.Rows.Count <= 0)
        {
            Refresh();
        }
        else
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                switch (e.CommandName)
                {
                case "cmdDeleteAll":
                    sb.AppendStatement("Delete PODetail Where 0=0 ");
                    sb.Append(" And POID  =").AppendParameter("POID" + i, dt.Rows[i][0].ToString().Split(',')[0]);
                    sb.Append(" And POSeq =").AppendParameter("POSeq" + i, dt.Rows[i][0].ToString().Split(',')[1]);
                    break;

                case "cmdUpdateAll":
                    sb.AppendStatement("Update PODetail Set POID = POID ");
                    for (int j = 1; j < dt.Columns.Count; j++)
                    {
                        sb.Append(" ," + dt.Columns[j].ColumnName + " = ").AppendParameter(dt.Columns[j].ColumnName + i, dt.Rows[i][j].ToString());
                    }
                    sb.Append(" Where 0=0 ");
                    sb.Append(" And POID  =").AppendParameter("POID" + i, dt.Rows[i][0].ToString().Split(',')[0]);
                    sb.Append(" And POSeq =").AppendParameter("POSeq" + i, dt.Rows[i][0].ToString().Split(',')[1]);
                    break;

                default:
                    break;
                }
            }
            //重新計算加總值
            sb.AppendStatement(string.Format(_ReCal_BaseUpdSQL, _MainID));

            DbConnection  cn = db.OpenConnection();
            DbTransaction tx = cn.BeginTransaction();
            try
            {
                db.ExecuteNonQuery(sb.BuildCommand(), tx);
                tx.Commit();
                Util.NotifyMsg("處理成功", Util.NotifyKind.Success);
                fmMainRefresh();
            }
            catch
            {
                tx.Rollback();
                Util.NotifyMsg("處理失敗", Util.NotifyKind.Error);
            }
            finally
            {
                cn.Close();
                cn.Dispose();
                tx.Dispose();
            }
        }
    }