Example #1
0
        public ProjectGeneralInfo GetProjectGeneralInfo(int ProjID)
        {
            ProjectGeneralInfo model = null;

            try
            {
                TBL_MP_PMC_ProjectMaster dbmodel = _dbContext.TBL_MP_PMC_ProjectMaster.Where(x => x.PK_ProjectID == ProjID).FirstOrDefault();

                if (dbmodel != null)
                {
                    model = new ProjectGeneralInfo();

                    model.ProjectID   = dbmodel.PK_ProjectID;
                    model.ProjectCode = dbmodel.ProjectNumber;
                    model.ProjectName = dbmodel.ProjectName;
                    if (dbmodel.ProjectDate != null)
                    {
                        model.EntryDate = (DateTime)dbmodel.ProjectDate;
                    }
                    else
                    {
                        model.EntryDate = null;
                    }
                    if (dbmodel.StartDate != null)
                    {
                        model.StartDate = (DateTime)dbmodel.StartDate;
                    }
                    else
                    {
                        model.StartDate = null;
                    }
                    if (dbmodel.EndDate != null)
                    {
                        model.EndDate = (DateTime)dbmodel.EndDate;
                    }
                    else
                    {
                        model.EndDate = null;
                    }

                    model.ProjectStatus          = dbmodel.FK_ProjectStatusID.ToString();
                    model.BillingClientID        = (int)dbmodel.BillingClientID;
                    model.BillingClientAddressID = dbmodel.BillingClientAddressID;
                    model.SiteClientID           = (int)dbmodel.SiteClientID;
                    model.SiteClientAddressID    = dbmodel.SiteClientAddressID;
                    model.IsActive = dbmodel.IsActive;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceProject::GetProjectGeneralInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model);
        }
Example #2
0
        public bool SetProjectGeneralInfo(ProjectGeneralInfo model)
        {
            bool result = false;

            try
            {
                TBL_MP_PMC_ProjectMaster dbModel = _dbContext.TBL_MP_PMC_ProjectMaster.Where(x => x.PK_ProjectID == model.ProjectID).FirstOrDefault();
                if (dbModel != null)
                {
                    dbModel.ProjectNumber          = model.ProjectCode;
                    dbModel.ProjectName            = model.ProjectName;
                    dbModel.ProjectDate            = (DateTime)model.EntryDate;
                    dbModel.StartDate              = (DateTime)model.StartDate;
                    dbModel.EndDate                = (DateTime)model.EndDate;
                    dbModel.BillingClientID        = model.BillingClientID;
                    dbModel.BillingClientAddressID = model.BillingClientAddressID;
                    dbModel.SiteClientID           = model.SiteClientID;
                    dbModel.SiteClientAddressID    = model.SiteClientAddressID;
                    dbModel.FK_ProjectStatusID     = int.Parse(model.ProjectStatus);
                    dbModel.IsActive               = model.IsActive;

                    _dbContext.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceProject::SetProjectGeneralInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }