예제 #1
0
        public Boolean insertRegion(region reg)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "insert into Region (RegionID,Name,Status,CreateTime,CreateUser)" +
                                   "values (" +
                                   "'" + reg.regionID + "'," +
                                   "'" + reg.name + "'," +
                                   reg.status + "," +
                                   "GETDATE()" + "," +
                                   "'" + Login.userLoggedIn + "'" + ")";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("insert", "Region", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
예제 #2
0
        public List <region> getRegions()
        {
            region        reg;
            List <region> Regions = new List <region>();

            try
            {
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "select RegionID, Name,status " +
                                      "from Region order by RegionID";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    reg          = new region();
                    reg.regionID = reader.GetString(0);
                    reg.name     = reader.GetString(1);
                    reg.status   = reader.GetInt32(2);
                    Regions.Add(reg);
                }
                conn.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error querying Region Data");
            }
            return(Regions);
        }
예제 #3
0
        public Boolean updateRegion(region reg)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update Region set name='" + reg.name +
                                   "',Status=" + reg.status +
                                   " where RegionID='" + reg.regionID + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "Region", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
예제 #4
0
        public Boolean validateRegion(region reg)
        {
            Boolean status = true;

            try
            {
                if (reg.regionID.Trim().Length == 0 || reg.regionID == null)
                {
                    return(false);
                }
                if (reg.name.Trim().Length == 0 || reg.name == null)
                {
                    return(false);
                }
            }
            catch (Exception)
            {
            }
            return(status);
        }