Beispiel #1
0
        /// <summary>
        /// Save Out Employees.
        /// </summary>
        /// <param name="employees">Out Employees</param>
        public void SaveOutEmployees(List <OutEmployeeInfo> employees)
        {
            using (var conn = new SqlConnection(SQLHelper.ConnectionStringLocalTransaction)) {
                conn.Open();
                using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted)) {
                    try {
                        SqlParameter[] parms = { new SqlParameter("@EmpId",       SqlDbType.VarChar,    50),
                                                 new SqlParameter("@EmpName",     SqlDbType.NVarChar,   50),
                                                 new SqlParameter("@Sex",         SqlDbType.VarChar,    10),
                                                 new SqlParameter("@CardId",      SqlDbType.VarChar,    50),
                                                 new SqlParameter("@CardAddress", SqlDbType.NVarChar,  200),
                                                 new SqlParameter("@CardIssue",   SqlDbType.NVarChar,  200),
                                                 new SqlParameter("@Hometown",    SqlDbType.NVarChar,  200),
                                                 new SqlParameter("@CompanyName", SqlDbType.NVarChar,  100),
                                                 new SqlParameter("@ProjectName", SqlDbType.NVarChar,  100),
                                                 new SqlParameter("@OfficePhone", SqlDbType.VarChar,    20),
                                                 new SqlParameter("@MobilePhone", SqlDbType.VarChar,    20),
                                                 new SqlParameter("@Email",       SqlDbType.VarChar,    50),
                                                 new SqlParameter("@Comment",     SqlDbType.NVarChar, 1024),
                                                 new SqlParameter("@ParentEmpId", SqlDbType.VarChar,    50),
                                                 new SqlParameter("@Photo",       SqlDbType.Image),
                                                 new SqlParameter("@PhotoLayout", SqlDbType.Int),
                                                 new SqlParameter("@Enabled",     SqlDbType.Bit) };

                        foreach (var employee in employees)
                        {
                            parms[0].Value  = employee.EmpId;
                            parms[1].Value  = employee.EmpName;
                            parms[2].Value  = employee.Sex;
                            parms[3].Value  = ComUtility.DBNullStringChecker(employee.CardId);
                            parms[4].Value  = ComUtility.DBNullStringChecker(employee.CardAddress);
                            parms[5].Value  = ComUtility.DBNullStringChecker(employee.CardIssue);
                            parms[6].Value  = ComUtility.DBNullStringChecker(employee.Hometown);
                            parms[7].Value  = ComUtility.DBNullStringChecker(employee.CompanyName);
                            parms[8].Value  = ComUtility.DBNullStringChecker(employee.ProjectName);
                            parms[9].Value  = ComUtility.DBNullStringChecker(employee.OfficePhone);
                            parms[10].Value = employee.MobilePhone;
                            parms[11].Value = employee.Email;
                            parms[12].Value = ComUtility.DBNullStringChecker(employee.Comment);
                            parms[13].Value = employee.ParentEmpId;
                            parms[14].Value = ComUtility.DBNullBytesChecker(employee.Photo);
                            parms[15].Value = employee.PhotoLayout;
                            parms[16].Value = employee.Enabled;

                            SQLHelper.ExecuteNonQuery(tran, CommandType.Text, SQLText.SQL_EE_SaveOutEmployee, parms);
                        }

                        tran.Commit();
                    } catch {
                        tran.Rollback();
                        throw;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Save Organization Employees.
        /// </summary>
        /// <param name="employees">employees</param>
        public void SaveOrgEmployees(List <OrgEmployeeInfo> employees)
        {
            using (var conn = new SqlConnection(SQLHelper.ConnectionStringLocalTransaction)) {
                conn.Open();
                using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted)) {
                    try {
                        SqlParameter[] parms = { new SqlParameter("@EmpId",             SqlDbType.VarChar,     50),
                                                 new SqlParameter("@EmpType",           SqlDbType.Int),
                                                 new SqlParameter("@EmpName",           SqlDbType.NVarChar,    50),
                                                 new SqlParameter("@EnglishName",       SqlDbType.VarChar,     50),
                                                 new SqlParameter("@Sex",               SqlDbType.VarChar,     10),
                                                 new SqlParameter("@CardID",            SqlDbType.VarChar,     50),
                                                 new SqlParameter("@Hometown",          SqlDbType.NVarChar,   200),
                                                 new SqlParameter("@BirthDay",          SqlDbType.DateTime),
                                                 new SqlParameter("@Marriage",          SqlDbType.Int),
                                                 new SqlParameter("@HomeAddress",       SqlDbType.NVarChar,   200),
                                                 new SqlParameter("@HomePhone",         SqlDbType.VarChar,     20),
                                                 new SqlParameter("@EntryDay",          SqlDbType.DateTime),
                                                 new SqlParameter("@PositiveDay",       SqlDbType.DateTime),
                                                 new SqlParameter("@DepId",             SqlDbType.VarChar,     50),
                                                 new SqlParameter("@DutyName",          SqlDbType.NVarChar,    50),
                                                 new SqlParameter("@OfficePhone",       SqlDbType.VarChar,     20),
                                                 new SqlParameter("@MobilePhone",       SqlDbType.VarChar,     20),
                                                 new SqlParameter("@Email",             SqlDbType.VarChar,     50),
                                                 new SqlParameter("@Comment",           SqlDbType.NVarChar,  1024),
                                                 new SqlParameter("@Photo",             SqlDbType.Image),
                                                 new SqlParameter("@PhotoLayout",       SqlDbType.Int),
                                                 new SqlParameter("@ResignationDate",   SqlDbType.DateTime),
                                                 new SqlParameter("@ResignationRemark", SqlDbType.NVarChar,  1024),
                                                 new SqlParameter("@Enabled",           SqlDbType.Bit) };

                        foreach (var employee in employees)
                        {
                            parms[0].Value  = employee.EmpId;
                            parms[1].Value  = (Int32)employee.EmpType;
                            parms[2].Value  = employee.EmpName;
                            parms[3].Value  = ComUtility.DBNullStringChecker(employee.EnglishName);
                            parms[4].Value  = employee.Sex;
                            parms[5].Value  = ComUtility.DBNullStringChecker(employee.CardId);
                            parms[6].Value  = ComUtility.DBNullStringChecker(employee.Hometown);
                            parms[7].Value  = employee.BirthDay;
                            parms[8].Value  = (Int32)employee.Marriage;
                            parms[9].Value  = ComUtility.DBNullStringChecker(employee.HomeAddress);
                            parms[10].Value = ComUtility.DBNullStringChecker(employee.HomePhone);
                            parms[11].Value = employee.EntryDay;
                            parms[12].Value = employee.PositiveDay;
                            parms[13].Value = employee.DepId;
                            parms[14].Value = ComUtility.DBNullStringChecker(employee.DutyName);
                            parms[15].Value = ComUtility.DBNullStringChecker(employee.OfficePhone);
                            parms[16].Value = employee.MobilePhone;
                            parms[17].Value = employee.Email;
                            parms[18].Value = ComUtility.DBNullStringChecker(employee.Comment);
                            parms[19].Value = ComUtility.DBNullBytesChecker(employee.Photo);
                            parms[20].Value = employee.PhotoLayout;
                            parms[21].Value = ComUtility.DBNullDateTimeChecker(employee.ResignationDate);
                            parms[22].Value = ComUtility.DBNullStringChecker(employee.ResignationRemark);
                            parms[23].Value = employee.Enabled;

                            SQLHelper.ExecuteNonQuery(tran, CommandType.Text, SQLText.SQL_EE_SaveOrgEmployee, parms);
                        }

                        tran.Commit();
                    } catch {
                        tran.Rollback();
                        throw;
                    }
                }
            }
        }