Пример #1
0
        /// <summary>
        /// Ensures that an object with the specified name exists, while creating other properties are set to their default values
        /// </summary>
        /// <param name="i_sName">Name</param>
        /// <returns>cProject object</returns>
        public static cProject CreateIfRequiredAndGet(string i_sName)
        {
            cProject oObj = cProject.Get_Name(i_sName);

            if (oObj == null)
            {
                oObj       = cProject.Create();
                oObj.sName = i_sName;
                oObj.Save();
            }
            return(oObj);
        }
Пример #2
0
        public JsonResult AddProject(ProjectViewModel objprojectviewmodel)
        {
            try
            {
                if (objprojectviewmodel.SelectedClient[0] == "" || objprojectviewmodel.SelectedInternalHead[0] == "" || objprojectviewmodel.SelectedExternalHead[0] == "")
                {
                    return(Json("2"));
                }


                else
                {
                    if (objprojectviewmodel.hdnProjectID != null && objprojectviewmodel.hdnProjectID != "")
                    {
                        cProject objproject = cProject.Get_ID(Convert.ToInt32(objprojectviewmodel.hdnProjectID));
                        objproject.sProjectName = objprojectviewmodel.objProject.ProjectName;

                        string ClientId = objprojectviewmodel.SelectedClient[0].ToString();
                        objproject.objClient.iObjectID = Convert.ToInt32(ClientId);

                        string interHeadID = objprojectviewmodel.SelectedInternalHead[0].ToString();
                        objproject.iInternalHead = Convert.ToInt32(interHeadID);

                        string iStatus = objprojectviewmodel.SelectedStatus[0].ToString();
                        objproject.objStatus.iObjectID = Convert.ToInt32(iStatus);

                        string iExternalHeadID = objprojectviewmodel.SelectedExternalHead[0].ToString();
                        objproject.objExternalProjectHead.iObjectID = Convert.ToInt32(iExternalHeadID);

                        objproject.sDescription = objprojectviewmodel.objProject.Description;

                        objproject.dtStartDate = Convert.ToDateTime(objprojectviewmodel.objProject.StartDate);

                        objproject.dtEndDate = Convert.ToDateTime(objprojectviewmodel.objProject.EndDate);
                        //objproject.sCompletion = objprojectviewmodel.Complition;
                        objproject.Save();
                        return(Json("3"));
                    }
                    else
                    {
                        cProject objproject = cProject.Create();
                        objproject.sProjectName = objprojectviewmodel.objProject.ProjectName;

                        string ClientId = objprojectviewmodel.SelectedClient[0].ToString();
                        objproject.objClient.iObjectID = Convert.ToInt32(ClientId);

                        string interHeadID = objprojectviewmodel.SelectedInternalHead[0].ToString();
                        objproject.iInternalHead = Convert.ToInt32(interHeadID);

                        string iStatus = objprojectviewmodel.SelectedStatus[0].ToString();
                        objproject.objStatus.iObjectID = Convert.ToInt32(iStatus);

                        string iExternalHeadID = objprojectviewmodel.SelectedExternalHead[0].ToString();
                        objproject.objExternalProjectHead.iObjectID = Convert.ToInt32(iExternalHeadID);
                        objproject.dtStartDate = Convert.ToDateTime(objprojectviewmodel.objProject.StartDate);

                        objproject.dtEndDate    = Convert.ToDateTime(objprojectviewmodel.objProject.EndDate);
                        objproject.sDescription = objprojectviewmodel.objProject.Description;
                        //objproject.sCompletion = objprojectviewmodel.Complition;
                        objproject.Save();
                        return(Json("1"));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }