Exemplo n.º 1
0
        public static void Set(int employeeId, string settingName, DateTime?dateTimeValue)
        {
            SqlConnection   cn           = GetConnection();
            EmployeeSetting currentValue = Get(cn, employeeId, settingName);

            if (currentValue != null)
            {
                if ((dateTimeValue != null) || !dateTimeValue.HasValue)
                {
                    // Update
                    Update(cn, currentValue.Id, dateTimeValue);
                }
                else
                {
                    // Delete
                    Delete(cn, currentValue.Id);
                }
            }
            else
            {
                if (dateTimeValue != null)
                {
                    // Insert
                    Insert(cn, employeeId, settingName, dateTimeValue);
                }
            }
            FinishedWithConnection(cn);
        }
Exemplo n.º 2
0
 public static void Refresh(EmployeeSetting setting)
 {
     if (setting != null)
     {
         Refresh(setting, EmployeeSetting.Get(setting.EmployeeId, setting.Name));
     }
 }
Exemplo n.º 3
0
        private static EmployeeSetting Get(SqlConnection cn, int employeeId, string settingName)
        {
            EmployeeSetting result = null;

            if (settingName == null)
            {
                return(null);
            }
            for (int i = 0; i < 2; i++)
            {
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM EmployeeSetting WHERE (EmployeeSettingEmployeeId=@EmployeeSettingEmployeeId) AND (EmployeeSettingName LIKE @EmployeeSettingName)", cn))
                {
                    BuildSqlParameter(cmd, "@EmployeeSettingEmployeeId", SqlDbType.Int, employeeId);
                    BuildSqlParameter(cmd, "@EmployeeSettingName", SqlDbType.Text, settingName);
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                        {
                            result = BuildEmployeeSetting(rdr);
                        }
                    }
                }
                if (result == null)
                {
                    EmployeeSetting.Insert(cn, employeeId, settingName, (string)null);
                }
                else
                {
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static EmployeeSetting Get(int employeeId, string settingName)
        {
            EmployeeSetting result = null;
            SqlConnection   cn     = GetConnection();

            result = Get(cn, employeeId, settingName);
            FinishedWithConnection(cn);
            return(result);
        }
Exemplo n.º 5
0
 public static void Refresh(EmployeeSetting setting, EmployeeSetting tempSetting)
 {
     if ((setting == null) || (tempSetting == null))
     {
         return;
     }
     setting.Name          = tempSetting.Name;
     setting.EmployeeId    = tempSetting.EmployeeId;
     setting.StringValue   = tempSetting.StringValue;
     setting.IntValue      = tempSetting.IntValue;
     setting.FloatValue    = tempSetting.FloatValue;
     setting.DateTimeValue = tempSetting.DateTimeValue;
 }