Example #1
0
 public static void updateService(Service service, string code, string label)
 {
     try
     {
         service.memorize();
         service.Code = code;
         service.Label = label;
     }
     catch (Exception e)
     {
         service.restore();
         throw e;
     }
 }
Example #2
0
        public void updateService(Service service, string code, string label)
        {
            string targetcode = service.Code;
            try
            {
                service.memorize();
                service.Code = code;
                service.Label = label;
            }
            catch (Exception e)
            {
                service.restore();
                throw e;
            }

            try
            {
                IDbConnection cn = Database.connection();
                IDbCommand cmd = cn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "update services set code = @code,label = @label where code=@targetcode";
                IDataParameter p = cmd.CreateParameter();
                p.DbType = DbType.String;
                p.Value = targetcode;
                p.ParameterName = "@targetcode";
                cmd.Parameters.Add(p);

                p.DbType = DbType.String;
                p.Value = service.Code;
                p.ParameterName = "@code";
                cmd.Parameters.Add(p);

                p = cmd.CreateParameter();
                p.ParameterName = "@label";
                p.DbType = DbType.String;
                p.Value = service.Label;
                cmd.Parameters.Add(p);

                if (1 == cmd.ExecuteNonQuery())
                    _lst.Add(service);
                else
                    service = null;
            }
            catch (Exception e)
            {
                throw e;
            }
        }