示例#1
0
        public void Submit(Dictionary <ColDef, object> Map, String tblName, Tuple <ColDef, Object> id, EntryMode mode)
        {
            String sql = "";

            if (mode == EntryMode.New)
            {
                foreach (var kv in Map) // remove id if exists
                {
                    if (kv.Key.Name.Equals(id.Item1.Name))
                    {
                        Map.Remove(kv.Key);
                        break;
                    }
                }
                object _id = model.ExecuteScalar("SELECT (Max(" + id.Item1.Name + ") + 1) FROM " + tblName); // generate new id
                if (_id.ToString().Equals(""))
                {
                    _id = 1;
                }
                Map.Add(id.Item1, _id);
                sql = SqlStatements.BuildInsert(tblName, Map);
            }
            else if (mode == EntryMode.Edit)
            {
                sql = SqlStatements.BuildUpdate(tblName, Map, id);
            }

            model.Tasks.Add(new Action <String>(s => model.ExecuteActionQuery(s)).BeginInvoke(sql, null /*p => { CRM.Pages.Navigator.UpdateTablesAsync(); }*/, null));
        }
示例#2
0
 public Model()
 {
     TblCustomers      = new DefTblCustomers();
     TblNotes          = new DefTblNotes();
     TblContactPersons = new DefTblContactPersons();
     Sql   = new SqlStatements();
     Tasks = new List <IAsyncResult>();
 }