Esempio n. 1
0
        public int AddData(Dictionary <string, object> objs, UserInfo sysUser, string viewTitle, string tableName, string pkField, string pkValue, bool isReturn)
        {
            string    sql = @"select * from AppApprove where 1<>1 ";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql).Tables[0];

            dt.TableName = "AppApprove";
            DataRow dr = dt.NewRow();

            cmd = dbUpdate.BeginTransaction();
            try
            {
                foreach (KeyValuePair <string, object> kv in objs)
                {
                    dr[kv.Key] = kv.Value;
                }
                dr["approveId"] = IdGenerator.GetMaxId(dt.TableName);
                Create5Field(dr, sysUser.UserId, viewTitle);
                dt.Rows.Add(dr);
                dbUpdate.Update(dt, cmd);
                OverrideRefTable(tableName, pkField, pkValue, sysUser, viewTitle, isReturn);
                dbUpdate.Commit(cmd);
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback(cmd);
                throw new Exception(ex.Message);
            }
            return(1);
        }
Esempio n. 2
0
        public int Update(UserInfo sysUser, EntryModel model)
        {
            List <DataTable> dtlist = new List <DataTable>();
            string           sql    = @"select * from FiscalYear where 1<>1 ";
            DataTable        dt     = AppMember.DbHelper.GetDataSet(sql).Tables[0];

            dt.TableName = "FiscalYear";

            int formYear = DataConvert.ToInt32(model.FromYear);
            int toYear   = DataConvert.ToInt32(model.ToYear);

            string    sql2 = @"select * from FiscalPeriod where 1<>1 ";
            DataTable dt2  = AppMember.DbHelper.GetDataSet(sql2).Tables[0];

            dt2.TableName = "FiscalPeriod";

            for (int i = formYear; i <= toYear; i++)
            {
                DataRow dr = dt.NewRow();
                string  id = IdGenerator.GetMaxId(dt.TableName);
                dr["fiscalYearId"]   = id;
                dr["fiscalYearName"] = i.ToString();
                dr["fromDate"]       = i.ToString() + "/01/01";
                dr["toDate"]         = i.ToString() + "/12/31";
                dt.Rows.Add(dr);
                Create5Field(dt, sysUser.UserId, model.ViewTitle);
                UpdateFiscalPeriod(sysUser, model, i, id, dt2);
            }
            dtlist.Add(dt);
            dtlist.Add(dt2);
            DbUpdate = new DataUpdate();
            return(DbUpdate.Update(dtlist, true));
        }
Esempio n. 3
0
        public IHttpActionResult Put(int id, string newName = "", int newAge = 0)
        {
            int check = DataUpdate.Update(connectionStr, id, newName, newAge);

            if (check != 0)
            {
                return(Ok());
            }
            return(NotFound());
        }
        public int AddRegister(string registerNo, string companyName)
        {
            string    sql = @"select * from AppRegister";
            DataTable dt  = AppMember.DbHelper.GetDataSet(sql).Tables[0];

            dt.TableName = "AppRegister";
            foreach (DataRow dr in dt.Rows)
            {
                dr.Delete();
            }
            DataRow dr2 = dt.NewRow();

            dr2["registerNo"]  = registerNo;
            dr2["companyName"] = companyName;
            dr2["registerid"]  = IdGenerator.GetMaxId(dt.TableName);
            dr2["createDate"]  = IdGenerator.GetServerDate();
            dt.Rows.Add(dr2);
            DbUpdate = new DataUpdate();
            return(DbUpdate.Update(dt));
        }