public virtual void reinitEditingForData()
        {
            initChanger();

            //init defaults
            if (userAdapter.getAdapterWorkState() == AdapterWorkState.stateAdd)
            {
                DataSet ds = userAdapter.getDataSet();

                string[][] arrDefaults = getDefaultValues();
                foreach (string[] arrTmp in arrDefaults)
                {
                    string tableName    = arrTmp[0];
                    string tableColName = arrTmp[1];
                    string valueStr     = arrTmp[2];

                    DataTable tableTmp = ds.Tables[tableName];
                    if (tableTmp != null)
                    {
                        DataColumn colTmp = tableTmp.Columns[tableColName];
                        if (colTmp != null)
                        {
                            string val_  = getValue(valueStr);
                            object value = XmlFormating.helper.parse(val_, colTmp.DataType);
                            ToolColumn.setColumnValue(tableTmp, colTmp.ColumnName, value);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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);
        }