Beispiel #1
0
        //user need save
        public object save(Form pForm)
        {
            object res = null;
            bool   ok  = false;

            try
            {
                environment.beginBatch();
                res = adapter.update();
                environment.commitBatch();
                ok = true;
            }
            catch (Exception exc)
            {
                environment.rollbackBatch();
                environment.getExceptionHandler().setException(exc);
            }



            if (ok)
            {
                environment.docEnd();

                if (pForm != null)
                {
                    pForm.Close();
                }

                if (handlerReferenceInformer != null)
                {
                    handlerReferenceInformer.Invoke(this, res);
                }


                //     onSaved();
            }


            if (ok)
            {
                var ds   = adapter.getDataSet();
                var code = (ds != null && ds.Tables.Count > 0 ? ds.Tables[0].TableName : "DUMMY");
                if (ds != null)
                {
                    ToolMobile.logRuntime(string.Format(
                                              "Doc commited by [{0}] with id [{1}] and worked as [{2}]",
                                              code,
                                              ToolCell.isNull(res, "null").ToString(),
                                              adapter.getAdapterWorkState().ToString()
                                              ));
                }
            }

            return(res);
        }
Beispiel #2
0
        protected virtual void doCmd(CmdType pCmd)
        {
            DataRow row_ = getGrid().ActiveRow;

            //
            CmdMenuItem[] arr_ = getMenuItems(row_);



            foreach (CmdMenuItem itm in arr_)
            {
                if (pCmd == itm.CmdType)
                {
                    ToolMobile.logRuntime(string.Format("Try do command [{0}] on form [{1}]", itm.CmdType.ToString(), this.getDsName()));

                    switch (itm.CmdType)
                    {
                    case CmdType.refresh:
                        doRefresh();
                        break;

                    case CmdType.add:
                        doAdd();
                        break;

                    case CmdType.view:
                        doView(row_);
                        break;

                    case CmdType.edit:
                        doEdit(row_);
                        break;

                    case CmdType.copy:
                        doCopy(row_);
                        break;

                    case CmdType.delete:
                        doDelete(row_);
                        break;

                    case CmdType.info1:
                    case CmdType.info2:
                    case CmdType.info3:
                    case CmdType.info4:
                    case CmdType.info5:
                        if (itm.activity != null)
                        {
                            itm.activity.done();
                        }
                        break;

                    case CmdType.batch1:
                    case CmdType.batch2:
                    case CmdType.batch3:
                    case CmdType.batch4:
                    case CmdType.batch5:
                        doCmdBatch(itm, row_);
                        break;

                    default:
                        if (itm.activity != null)
                        {
                            itm.activity.done();
                        }
                        else
                        {
                            doCmdUser(itm, row_);
                        }
                        break;
                    }
                }
            }
        }