Exemple #1
0
        public JobPositionVO GetByID(int id)
        {
            JobPositionVO vo = new JobPositionVO();
            DataTable     dt = Select("ID=" + id + "");

            if (dt.Rows.Count > 0)
            {
                vo = b.ConvertObj(dt.Rows[0], new JobPositionVO()) as JobPositionVO;
            }
            return(vo);
        }
Exemple #2
0
        public JobPositionVO GetIDByName(string postName)
        {
            JobPositionVO vo = new JobPositionVO();

            DataTable dt = Select("PostName=N'" + postName + "'");

            if (dt.Rows.Count > 0)
            {
                vo = b.ConvertObj(dt.Rows[0], new JobPositionVO()) as JobPositionVO;
            }
            return(vo);
        }
Exemple #3
0
        public int Create(JobPositionVO vo)
        {
            int id;

            if (!dao.isExist(vo.Id.ToString()))
            {
                id = dao.Insert(vo);
            }
            else
            {
                id = dao.Update(vo);
            }
            return(id);
        }
Exemple #4
0
        public int Update(JobPositionVO vo)
        {
            int ID = 0;

            try
            {
                b.Update("Job_Position", vo.Id.ToString(), b.ConvertColName(vo), b.ConvertValueList(vo));
                ID = vo.Id;
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return(ID);
        }
Exemple #5
0
        public int Insert(JobPositionVO vo)
        {
            int lastInsertId = 0;

            try
            {
                lastInsertId = b.Insert("Job_Position", b.ConvertColName(vo), b.ConvertValueList(vo));
                string syncDataToOtherDB = @"SET IDENTITY_INSERT [{0}].[dbo].[JOB_POSITION] ON
                                           INSERT INTO [{0}].[dbo].[JOB_POSITION]([ID],[PostName],[DepartmentID],[ReportTo],[JobSpecification],[JobDescription],[Rank])            
                                           SELECT [ID],[PostName],[DepartmentID],[ReportTo],[JobSpecification],[JobDescription],[Rank]
                                           FROM [dbo].[JOB_POSITION]
                                           WHERE [ID]={1}
                                           SET IDENTITY_INSERT [{0}].[dbo].[Employee] OFF ";

                //if (Program.Branch == "HO")
                //{
                //    string salesDataBaseName = Properties.Settings.Default.PTIC_Sales_DbName;

                //    string cmdSql = string.Format(syncDataToOtherDB, salesDataBaseName, lastInsertId);
                //    int effectedCount = b.ExecuteNonQuery(cmdSql);
                //}
                //else if (Program.Branch == "Factory")
                //{
                //    try
                //    {
                //        string FactoryDatabaseName = Properties.Settings.Default.Proven_Factory_DbName;
                //        string cmdSql = string.Format(syncDataToOtherDB, FactoryDatabaseName, lastInsertId);
                //        int effectedCount = b.ExecuteNonQuery(cmdSql);
                //    }
                //    catch (SqlException ex)
                //    { }
                //}
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return(lastInsertId);
        }