示例#1
0
        public IHttpActionResult Update([FromBody] PROJECTDC projectDC)
        {
            List <EXCEPTIONDC> lstException = new List <EXCEPTIONDC>();

            try
            {
                var objProject = new PROJECTBL();

                int IsUpdated = 0;
                projectDC.CREATED_ON  = Convert.ToDateTime(projectDC.CREATED_ON);
                projectDC.MODIFIED_ON = Convert.ToDateTime(projectDC.MODIFIED_ON);
                List <PROJECTDC> projectList = new List <PROJECTDC>();
                projectList.Add(projectDC);
                int UpdatedCount = objProject.Update(projectList, ref lstException);
                if (UpdatedCount > 0)
                {
                    IsUpdated = 1;
                }
                return(Ok(IsUpdated));
            }
            catch (Exception ex)
            {
                return(new TextResult(lstException, Request));
            }
        }
示例#2
0
        public IHttpActionResult Insert([FromBody] PROJECTDC projectDC)
        {
            try
            {
                var projectBL = new PROJECTBL();
                projectDC.CREATED_ON  = Convert.ToDateTime(projectDC.CREATED_ON);
                projectDC.MODIFIED_ON = Convert.ToDateTime(projectDC.MODIFIED_ON);

                List <PROJECTDC> projectList = new List <PROJECTDC>();
                projectList.Add(projectDC);
                int ID = projectBL.Insert(projectList);
                return(Ok(ID));
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("unique_Projects_Project_Bid_Name"))
                {
                    throw new System.InvalidOperationException("ProjectName");
                }
                else
                {
                    throw ex;
                }
            }
        }
示例#3
0
        public PROJECTDC LoadByPrimaryKey(DBConnection Connection, int PROJECT_ID)
        {
            PROJECTDC     objPROJECT = new PROJECTDC();
            StringBuilder sql        = new StringBuilder();

            sql.Append("proc_PROJECTSLoadByPrimaryKey");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_PROJECT_ID", DbType.Int32, PROJECT_ID);


            DataSet ds = new DataSet();

            if (Connection.Transaction != null)
            {
                ds = Connection.dataBase.ExecuteDataSet(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                ds = Connection.dataBase.ExecuteDataSet(dbCommandWrapper.DBCommand);
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                objPROJECT = FillObject(ds.Tables[0].Rows[0]);
            }
            return(objPROJECT);
        }
示例#4
0
        public int Update(DBConnection Connection, PROJECTDC objPROJECT)
        {
            int updateCount = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_PROJECTSUpdate");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);


            dbCommandWrapper.AddInParameter("p_PROJECT_ID", DbType.Int32, objPROJECT.PROJECT_ID);
            dbCommandWrapper.AddInParameter("p_HYLAN_PROJECT_ID", DbType.String, objPROJECT.HYLAN_PROJECT_ID);
            dbCommandWrapper.AddInParameter("p_HYLAN_JOB_NUMBER", DbType.String, objPROJECT.HYLAN_JOB_NUMBER);
            dbCommandWrapper.AddInParameter("p_PROJECT_BID_NAME", DbType.String, objPROJECT.PROJECT_BID_NAME);
            dbCommandWrapper.AddInParameter("p_CLIENT", DbType.String, objPROJECT.CLIENT);
            dbCommandWrapper.AddInParameter("p_PROJECT_STATUS", DbType.Int16, objPROJECT.PROJECT_STATUS);
            dbCommandWrapper.AddInParameter("p_TENTATIVE_PROJECT_START_DATE", DbType.DateTime, objPROJECT.TENTATIVE_PROJECT_START_DATE);
            dbCommandWrapper.AddInParameter("p_ACTUAL_PROJECT_START_DATE", DbType.DateTime, objPROJECT.ACTUAL_PROJECT_START_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECTED_END_DATE", DbType.DateTime, objPROJECT.PROJECTED_END_DATE);
            dbCommandWrapper.AddInParameter("p_ACTUAL_PROJECT_CLOSE_DATE", DbType.DateTime, objPROJECT.ACTUAL_PROJECT_CLOSE_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECT_BID_DATE", DbType.DateTime, objPROJECT.PROJECT_BID_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECT_AWARDED", DbType.DateTime, objPROJECT.PROJECT_AWARDED);
            dbCommandWrapper.AddInParameter("p_BID_DOCUMENTS", DbType.String, objPROJECT.BID_DOCUMENTS);
            dbCommandWrapper.AddInParameter("p_NOTES", DbType.String, objPROJECT.NOTES);
            dbCommandWrapper.AddInParameter("p_PO_NUMBER", DbType.String, objPROJECT.PO_NUMBER);
            dbCommandWrapper.AddInParameter("p_PO_AMOUNT", DbType.Decimal, objPROJECT.PO_AMOUNT);
            dbCommandWrapper.AddInParameter("p_CREATED_ON", DbType.DateTime, objPROJECT.CREATED_ON);
            dbCommandWrapper.AddInParameter("p_CREATED_BY", DbType.Int32, objPROJECT.CREATED_BY);
            dbCommandWrapper.AddInParameter("p_MODIFIED_ON", DbType.DateTime, objPROJECT.MODIFIED_ON);
            dbCommandWrapper.AddInParameter("p_MODIFIED_BY", DbType.Int32, objPROJECT.MODIFIED_BY);
            dbCommandWrapper.AddInParameter("p_LOCK_COUNTER", DbType.Int32, objPROJECT.LOCK_COUNTER);

            try
            {
                if (Connection.Transaction != null)
                {
                    updateCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
                }
                else
                {
                    updateCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
                }

                if (updateCount == 0)
                {
                    objPROJECT.ISDIRTY = ISDIRTY = true;
                    throw new Exception(Constants.ConcurrencyMessageSingleRow);
                }
            }
            catch (Exception exp)
            {
                //Utilities.InsertIntoErrorLog("Error: PROJECT UPDATE ", exp.Message + "\r\n" + exp.StackTrace, Convert.ToInt32(objPROJECT.MODIFIED_BY));
                objPROJECT.SetError(exp);
                throw exp;
            }
            return(updateCount);
        }
示例#5
0
        public IHttpActionResult Get(int id)
        {
            var objProjects = new PROJECTBL();
            var objResults  = new PROJECTDC();

            if (id > 0)
            {
                objResults = objProjects.LoadByPrimaryKey(id);
            }
            return(Ok(new { objResults }));
        }
示例#6
0
        public int Insert(DBConnection Connection, PROJECTDC objPROJECT)
        {
            int p_ID = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_PROJECTSInsert");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddOutParameter("p_PROJECT_ID", DbType.Int32, objPROJECT.PROJECT_ID);
            dbCommandWrapper.AddInParameter("p_HYLAN_PROJECT_ID", DbType.String, objPROJECT.HYLAN_PROJECT_ID);
            dbCommandWrapper.AddInParameter("p_HYLAN_JOB_NUMBER", DbType.String, objPROJECT.HYLAN_JOB_NUMBER);
            dbCommandWrapper.AddInParameter("p_PROJECT_BID_NAME", DbType.String, objPROJECT.PROJECT_BID_NAME);
            dbCommandWrapper.AddInParameter("p_CLIENT", DbType.String, objPROJECT.CLIENT);
            dbCommandWrapper.AddInParameter("p_PROJECT_STATUS", DbType.Int16, objPROJECT.PROJECT_STATUS);
            dbCommandWrapper.AddInParameter("p_TENTATIVE_PROJECT_START_DATE", DbType.DateTime, objPROJECT.TENTATIVE_PROJECT_START_DATE);
            dbCommandWrapper.AddInParameter("p_ACTUAL_PROJECT_START_DATE", DbType.DateTime, objPROJECT.ACTUAL_PROJECT_START_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECTED_END_DATE", DbType.DateTime, objPROJECT.PROJECTED_END_DATE);
            dbCommandWrapper.AddInParameter("p_ACTUAL_PROJECT_CLOSE_DATE", DbType.DateTime, objPROJECT.ACTUAL_PROJECT_CLOSE_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECT_BID_DATE", DbType.DateTime, objPROJECT.PROJECT_BID_DATE);
            dbCommandWrapper.AddInParameter("p_PROJECT_AWARDED", DbType.DateTime, objPROJECT.PROJECT_AWARDED);
            dbCommandWrapper.AddInParameter("p_BID_DOCUMENTS", DbType.String, objPROJECT.BID_DOCUMENTS);
            dbCommandWrapper.AddInParameter("p_NOTES", DbType.String, objPROJECT.NOTES);
            dbCommandWrapper.AddInParameter("p_PO_NUMBER", DbType.String, objPROJECT.PO_NUMBER);
            dbCommandWrapper.AddInParameter("p_PO_AMOUNT", DbType.Decimal, objPROJECT.PO_AMOUNT);
            dbCommandWrapper.AddInParameter("p_CREATED_ON", DbType.DateTime, objPROJECT.CREATED_ON);
            dbCommandWrapper.AddInParameter("p_CREATED_BY", DbType.Int32, objPROJECT.CREATED_BY);
            dbCommandWrapper.AddInParameter("p_MODIFIED_ON", DbType.DateTime, objPROJECT.MODIFIED_ON);
            dbCommandWrapper.AddInParameter("p_MODIFIED_BY", DbType.Int32, objPROJECT.MODIFIED_BY);
            dbCommandWrapper.AddInParameter("p_LOCK_COUNTER", DbType.Int32, objPROJECT.LOCK_COUNTER);


            if (Connection.Transaction != null)
            {
                Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
            }

            p_ID = Convert.ToInt32(dbCommandWrapper.DBCommand.Parameters["@p_PROJECT_ID"].Value);
            return(p_ID);
        }
示例#7
0
        private PROJECTDC FillObject(IDataReader reader)
        {
            PROJECTDC objPROJECT = null;

            if (reader != null && reader.Read())
            {
                DataTable schemaTable = reader.GetSchemaTable();
                objPROJECT                              = new PROJECTDC();
                objPROJECT.PROJECT_ID                   = (int)reader["PROJECT_ID"];
                objPROJECT.HYLAN_PROJECT_ID             = (String)reader["HYLAN_PROJECT_ID"];
                objPROJECT.HYLAN_JOB_NUMBER             = reader["HYLAN_JOB_NUMBER"] == DBNull.Value ? null : (String)reader["HYLAN_JOB_NUMBER"];
                objPROJECT.PROJECT_BID_NAME             = reader["PROJECT_BID_NAME"] == DBNull.Value ? null : (String)reader["PROJECT_BID_NAME"];
                objPROJECT.CLIENT                       = (int)reader["CLIENT"];
                objPROJECT.TENTATIVE_PROJECT_START_DATE = reader["TENTATIVE_PROJECT_START_DATE"] == DBNull.Value ? null : (DateTime?)reader["TENTATIVE_PROJECT_START_DATE"];
                objPROJECT.ACTUAL_PROJECT_START_DATE    = reader["ACTUAL_PROJECT_START_DATE"] == DBNull.Value ? null : (DateTime?)reader["ACTUAL_PROJECT_START_DATE"];
                objPROJECT.PROJECTED_END_DATE           = reader["PROJECTED_END_DATE"] == DBNull.Value ? null : (DateTime?)reader["PROJECTED_END_DATE"];
                objPROJECT.ACTUAL_PROJECT_CLOSE_DATE    = reader["ACTUAL_PROJECT_CLOSE_DATE"] == DBNull.Value ? null : (DateTime?)reader["ACTUAL_PROJECT_CLOSE_DATE"];
                objPROJECT.PROJECT_BID_DATE             = reader["PROJECT_BID_DATE"] == DBNull.Value ? null : (DateTime?)reader["PROJECT_BID_DATE"];
                objPROJECT.PROJECT_AWARDED              = reader["PROJECT_AWARDED"] == DBNull.Value ? null : (DateTime?)reader["PROJECT_AWARDED"];
                objPROJECT.BID_DOCUMENTS                = reader["BID_DOCUMENTS"] == DBNull.Value ? null : (String)reader["BID_DOCUMENTS"];
                objPROJECT.NOTES                        = Utilities.NotesFormat(Convert.ToInt32(reader["NOTES_COUNT"].ToString()), reader["NOTES_DATE"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["NOTES_DATE"].ToString()));
                objPROJECT.ATTACHMENTS                  = Utilities.AttachmentsFormat(Convert.ToInt32(reader["ATTACHMENTS_COUNT"].ToString()));
                objPROJECT.PO_NUMBER                    = reader["PO_NUMBER"] == DBNull.Value ? null : (String)reader["PO_NUMBER"];
                objPROJECT.PO_AMOUNT                    = objPROJECT.PO_AMOUNT = reader["PO_AMOUNT"] == DBNull.Value ? 0 : (decimal?)reader["PO_AMOUNT"];
                objPROJECT.CREATED_ON                   = (DateTime)reader["CREATED_ON"];
                objPROJECT.CREATED_BY                   = (int)reader["CREATED_BY"];
                objPROJECT.MODIFIED_ON                  = (DateTime)reader["MODIFIED_ON"];
                objPROJECT.MODIFIED_BY                  = (int)reader["MODIFIED_BY"];
                objPROJECT.LOCK_COUNTER                 = (int)reader["LOCK_COUNTER"];

                objPROJECT.CLIENT_NAME    = reader["CLIENT_NAME"] == DBNull.Value ? null : (String)reader["CLIENT_NAME"];
                objPROJECT.PROJECT_STATUS = (int)reader["PROJECT_STATUS"];
                if (schemaTable.Columns.Contains("PROJECT_STATUS_NAME") && reader["PROJECT_STATUS_NAME"] != DBNull.Value)
                {
                    objPROJECT.PROJECT_STATUS_LU.LOOK_UP_ID = objPROJECT.PROJECT_STATUS;
                    objPROJECT.PROJECT_STATUS_LU.LU_TYPE    = "PROJECT_STATUS";
                    objPROJECT.PROJECT_STATUS_LU.LU_NAME    = (String)reader["PROJECT_STATUS_NAME"];
                }

                reader.Close();
                reader.Dispose();
            }
            return(objPROJECT);
        }
示例#8
0
        public PROJECTDC LoadByPrimaryKey(int ID)
        {
            DBConnection objConnection = new DBConnection();
            PROJECTDA    objPROJECTDA  = new PROJECTDA();
            PROJECTDC    objPROJECTDC  = null;

            try
            {
                objConnection.Open(false);
                objPROJECTDC = objPROJECTDA.LoadByPrimaryKey(objConnection, ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objConnection.Close();
            }
            return(objPROJECTDC);
        }
示例#9
0
        private int Delete(DBConnection Connection, PROJECTDC objPROJECT)
        {
            int deleteCount = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_PROJECTSDelete");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_ID", DbType.Int32, objPROJECT.PROJECT_ID);

            if (Connection.Transaction != null)
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
            }

            return(deleteCount);
        }