当前位置: 首页>>代码示例>>C#>>正文


C# Employee.GetType方法代码示例

本文整理汇总了C#中Employee.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Employee.GetType方法的具体用法?C# Employee.GetType怎么用?C# Employee.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveEmployee

        public void SaveEmployee(Employee Employee)
        {
            LogDeb.LogException("EmployeeService", "SaveEmployee", "SaveEmployee Debut Ok");

            string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("spSaveEmployee", con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter parameterId = new SqlParameter()
                {
                    ParameterName = "@Id",
                    Value = Employee.Id
                };

                cmd.Parameters.Add(parameterId);

                SqlParameter parameterName = new SqlParameter()
                {
                    ParameterName = "@Name",
                    Value = Employee.Name
                };
                cmd.Parameters.Add(parameterName);

                SqlParameter parameterGender = new SqlParameter()
                {
                    ParameterName = "@Gender",
                    Value = Employee.Gender
                };
                cmd.Parameters.Add(parameterGender);

                SqlParameter parameterDateofb = new SqlParameter()
                {
                    ParameterName = "@Dateofb",
                    Value = Employee.Dateofb
                };
                cmd.Parameters.Add(parameterDateofb);

                SqlParameter parameterEmployeeType = new SqlParameter()
                {
                    ParameterName = "@EmployeeType",
                    Value = Employee.Type
                };
                cmd.Parameters.Add(parameterEmployeeType);

                if (Employee.GetType() == typeof(FullTimeEmployee))
                {
                    SqlParameter parameterAnnualSalary = new SqlParameter()
                    {
                        ParameterName = "@AnnualSalary",
                        Value = ((FullTimeEmployee)Employee).AnnualSalary
                    };
                    cmd.Parameters.Add(parameterAnnualSalary);
                }
                else
                {
                    SqlParameter parameterHourlyPay = new SqlParameter
                    {
                        ParameterName = "@HourlyPay",
                        Value = ((PartTimeEmployee)Employee).HourlyPay
                    };
                    cmd.Parameters.Add(parameterHourlyPay);

                    SqlParameter parameterHoursWorked = new SqlParameter
                    {
                        ParameterName = "@HoursWorked",
                        Value = ((PartTimeEmployee)Employee).HoursWorked
                    };
                    cmd.Parameters.Add(parameterHoursWorked);
                }

                con.Open();
                cmd.ExecuteNonQuery();
                LogDeb.LogException("EmployeeService", "SaveEmployee", "SaveEmployee End Ok");

            }
        }
开发者ID:dimafoot,项目名称:EBusiness2,代码行数:78,代码来源:EmployeeService.cs

示例2: GetEmployees

 public void GetEmployees(int type)
 {
     var employee = new Employee(type);
     var employeeType = employee.GetType();
 }
开发者ID:wj1s,项目名称:Refactoring_csharp,代码行数:5,代码来源:ReplaceTypeCodeWithSubclasses.cs

示例3: TranslateValuesForEmployee

        public void TranslateValuesForEmployee(Employee employee, FieldLegalValueConfiguration fieldLegalValueConfiguration, string[] propertiesForEmployee, out TranslationLogEntry logEntry)
        {
            logEntry = null;

            if (propertiesForEmployee == null)
            {
                propertiesForEmployee = Utilities.GetPropertyNames<Employee>();
            }

            // Loop through all fields for type
            foreach (string fieldName in propertiesForEmployee)
            {
                string fieldValue = Convert.ToString(employee.GetMemberValue(fieldName));
                IEnumerable<FieldLegalValue> legalValuesForFieldName = fieldLegalValueConfiguration.FieldLegalValuesForFieldName(fieldName);

                if (String.IsNullOrEmpty(fieldValue) == false)
                {
                    if (legalValuesForFieldName.Any(v => v.LegalValue == fieldValue) == true || legalValuesForFieldName.Count() == 0) // Check if legal
                    {

                    }
                    else
                    {
                        PropertyInfo propertyInfo = employee.GetType().GetProperty(fieldName);

                        FieldTranslatorChange change = new FieldTranslatorChange();
                        change.FieldName = fieldName;
                        change.PreviousValue = employee.GetMemberValue(fieldName);

                        bool logChange = true;

                        if (legalValuesForFieldName.Any(v => v.FieldTranslations.Cast<FieldTranslation>().Any(t => t.TranslationValue == fieldValue))) // If not legal - check if it can be autocorrected
                        {
                            object newValue = null;

                            var legalValueMatch = legalValuesForFieldName.Where(v => v.FieldTranslations.Cast<FieldTranslation>().Any(t => t.TranslationValue == fieldValue)).FirstOrDefault();

                            if (legalValueMatch != null)
                            {
                                newValue = legalValueMatch.LegalValue;
                            }

                            employee.SetMemberValue(fieldName, Convert.ChangeType(newValue, propertyInfo.PropertyType));
                            change.NewValue = Convert.ChangeType(newValue, propertyInfo.PropertyType);
                            change.Status = FieldTranslatorChangeStatus.Changed;
                        }
                        else // If it cannot be autocorrected
                        {
                            if (legalValuesForFieldName.All(x => x.DisallowOtherValues == false) == true) // Ignore if if it will allow other values than the ones defined as a legal value
                            {
                                logChange = false;
                            }
                            // Else Use the following behaviour
                            else if (Behaviour == FieldTranslatorBehaviour.KeepNonLegalValues)
                            {
                                change.Status = FieldTranslatorChangeStatus.Ignored;
                            }
                            else if (Behaviour == FieldTranslatorBehaviour.RemoveNonLegalValues)
                            {
                                employee.SetMemberValue(fieldName, Convert.ChangeType(null, propertyInfo.PropertyType));
                                change.Status = FieldTranslatorChangeStatus.Removed;
                            }
                        }

                        if (this.CommitChanges == true)
                        {
                            employee.Save();
                        }

                        if (logChange)
                        {
                            change.Employee = employee;
                            Changes.Add(change);
                        }

                        if (this.CommitChanges == true && change.Status != FieldTranslatorChangeStatus.Ignored && change.Status != FieldTranslatorChangeStatus.None)
                        {
                            Customer currentCustomer = CustomerUtilities.CurrentCustomerFromSession(employee.Session);

                            logEntry = new TranslationLogEntry(employee.Session)
                            {
                                PreviousValue = Convert.ToString(change.PreviousValue),
                                FieldName = fieldName,
                                NewValue = Convert.ToString(change.NewValue),
                                Employee = employee,
                                ChangeStatus = Convert.ToInt32(change.Status),
                                Customer = currentCustomer
                            };

                            logEntry.Save();
                        }
                    }
                }
            }
        }
开发者ID:a1exb1,项目名称:DX_Farlon_Data_Consolidator,代码行数:95,代码来源:FieldTranslator.cs


注:本文中的Employee.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。