コード例 #1
0
ファイル: Db.cs プロジェクト: MyLastAngel/Agregat
 public static bool SetComment(int projectId, DateTime time, string message, string userName)
 {
     AgrDataSet.ProjectsRow drProjects = Ds.Projects.FindById(projectId);
     if (drProjects == null)
     {
         LogManager.LogError(unit, "SetComment. Ошибка. Проект не найден: " + projectId);
         return(false);
     }
     AgrDataSet.UserRow drUser = Ds.User.FindByName(userName);
     if (drUser == null)
     {
         LogManager.LogError(unit, "SetComment. Ошибка. Пользователь не найден: " + userName);
         return(false);
     }
     drProjects.Date = DateTime.Now;
     AgrDataSet.ProjectRow[] drsProject = drProjects.GetProjectRows();
     if (drsProject.Length > 0)
     {
         bool res = Storage.AddComment(projectId, time, message, userName);
         if (res)
         {
             Ds.Comment.AddCommentRow(drProjects, time, message, drUser);
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
 private void FillProjects(AgrDataSet.ClientRow drClient)
 {
     foreach (AgrDataSet.ClientProjectRow drClientProject in drClient.GetClientProjectRows())
     {
         AgrDataSet.ProjectsRow  drProjects = drClientProject.ProjectRow;
         AgrDataSet.ProjectRow[] drsProject = drProjects.GetProjectRows();
         project_list.Items.Add(drProjects.Id.ToString(),
                                drsProject.Length > 0 ? drsProject[0].Name : drProjects.Id.ToString(),
                                -1);
         FillProducts(drProjects);
     }
 }
コード例 #3
0
        /// <summary>Загружаем проект</summary>
        public AgrProject GetProject(int id)
        {
            lock (Db.Ds)
            {
                LogManager.LogDebug(IpClient(), "Запрос проекта " + id);
                AgrDataSet.ProjectsRow drProjects = Db.Ds.Projects.FindById(id);
                if (drProjects == null)
                {
                    return(null);
                }
                AgrDataSet.ProjectRow        drProject        = drProjects.GetProjectRows()[0];
                AgrDataSet.ClientProjectRow  drClientProject  = drProjects.GetClientProjectRows()[0];
                AgrDataSet.ClientRow         drClient         = drClientProject.ClientRow;
                AgrDataSet.ProjectProductRow drProjectProduct = drProjects.GetProjectProductRows()[0];
                AgrDataSet.ProductRow        drProduct        = drProjectProduct.ProductRow;
                var project = new AgrProject(drProject.Id)
                {
                    ID            = drProject.Name,
                    Customer      = drClient.Name,
                    CustomerName  = drProject.CustomerName,
                    Product       = drProduct.Name,
                    Options       = drProject.Options,
                    ChangedDate   = drProjects.Date,
                    TimeEndActual =
                        drProjects.TimeEndActual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProjects.TimeEndActual,

                    IsManagerSetPlanDate = drProject.IsManagerSetPlanDate,

                    IsStop           = drProject.IsStop,
                    COM_Package_Type = drProject.COM_Package_Type,

                    #region ITO

                    #region G
                    Time_ITO_G_Plan =
                        drProject.Time_ITO_G_Plan == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_G_Plan,

                    Time_ITO_G_Actual =
                        drProject.Time_ITO_G_Actual == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_G_Actual,

                    Is_ITO_G_NotNeed = drProject.Is_ITO_G_NotNeed,
                    #endregion G

                    #region E
                    Time_ITO_E_Plan =
                        drProject.Time_ITO_E_Plan == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_E_Plan,

                    Time_ITO_E_Actual =
                        drProject.Time_ITO_E_Actual == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_E_Actual,

                    Is_ITO_E_NotNeed = drProject.Is_ITO_E_NotNeed,
                    #endregion E

                    #region R
                    Time_ITO_R_Plan =
                        drProject.Time_ITO_R_Plan == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_R_Plan,

                    Time_ITO_R_Actual =
                        drProject.Time_ITO_R_Actual == DateTime.MinValue
                                       ? (DateTime?)null
                                       : drProject.Time_ITO_R_Actual,

                    ITO_R_Mode = drProject.ITO_R_Mode,

                    Is_ITO_R_NotNeed = drProject.Is_ITO_R_NotNeed,
                    #endregion R

                    #endregion ITO

                    #region WH

                    #region G
                    Time_WH_G_Plan =
                        drProject.Time_WH_G_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_G_Plan,

                    Time_WH_G_Actual =
                        drProject.Time_WH_G_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_G_Actual,

                    Is_WH_G_NotNeed = drProject.Is_WH_G_NotNeed,

                    Time_WH_G_Requests_Create =
                        drProject.Time_WH_G_Requests_Create == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_G_Requests_Create,

                    #endregion G

                    #region E
                    Time_WH_E_Plan =
                        drProject.Time_WH_E_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_E_Plan,

                    Time_WH_E_Actual =
                        drProject.Time_WH_E_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_E_Actual,

                    Is_WH_E_NotNeed = drProject.Is_WH_E_NotNeed,

                    Time_WH_E_Requests_Create =
                        drProject.Time_WH_E_Requests_Create == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_E_Requests_Create,
                    #endregion E

                    #region R
                    Time_WH_R_Plan =
                        drProject.Time_WH_R_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_R_Plan,

                    Time_WH_R_Actual =
                        drProject.Time_WH_R_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_WH_R_Actual,

                    Is_WH_R_NotNeed = drProject.Is_WH_R_NotNeed,
                    #endregion R

                    #endregion WH

                    #region OMTS

                    #region G
                    Time_OMTS_G_Plan =
                        drProject.Time_OMTS_G_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OMTS_G_Plan,

                    Time_OMTS_G_Actual =
                        drProject.Time_OMTS_G_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OMTS_G_Actual,
                    #endregion G

                    #region E
                    Time_OMTS_E_Plan =
                        drProject.Time_OMTS_E_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OMTS_E_Plan,

                    Time_OMTS_E_Actual =
                        drProject.Time_OMTS_E_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OMTS_E_Actual,
                    #endregion E

                    #endregion OMTS

                    TimeBegin     = drProject.TimeBegin,
                    TimeEndPlaned = drProject.TimeEndPlaned,
                    Com_New_Time  =
                        drProject.Com_New_Time == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Com_New_Time,
                    MF_Collector           = drProject.MF_Collector,
                    MF_Complete_Percentage = drProject.MF_Complete_Percentage,
                    MF_Level     = drProject.MF_Level,
                    MF_Rama      = drProject.MF_Rama,
                    MF_Post      = drProject.MF_Post,
                    MF_Agregat   = drProject.MF_Agregat,
                    MF_SH_Place  = drProject.MF_SH_Place,
                    MF_SH        = drProject.MF_SH,
                    MF_Time_Plan =
                        drProject.MF_Time_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.MF_Time_Plan,
                    MF_Time_Test_Actual =
                        drProject.MF_Time_Test_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.MF_Time_Test_Actual,
                    MF_Time = drProject.MF_Time == DateTime.MinValue ? (DateTime?)null : drProject.MF_Time,

                    #region OTK
                    Time_OTK_Plan =
                        drProject.Time_OTK_Plan == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OTK_Plan,

                    Time_OTK_G_Actual =
                        drProject.Time_OTK_G_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OTK_G_Actual,

                    Time_OTK_E_Actual =
                        drProject.Time_OTK_E_Actual == DateTime.MinValue
                                   ? (DateTime?)null
                                   : drProject.Time_OTK_E_Actual,
                    Is_OTK_G_NotNeed = drProject.Is_OTK_G_NotNeed,
                    Is_OTK_E_NotNeed = drProject.Is_OTK_E_NotNeed,

                    #endregion OTK
                };

                // Сообщения
                foreach (AgrDataSet.CommentRow drComment in drProjects.GetCommentRows())
                {
                    project.Messages.Add(new AgrProjectComment(drComment.Time, drComment.UserName,
                                                               drComment.Value));
                }

                // Недокомплект
                foreach (AgrDataSet.RequestRow drRequest in drProjects.GetRequestRows())
                {
                    project.Requests.Add(new AgrRequest((OMTSRequestType)drRequest.Type, drRequest.Name)
                    {
                        TotalCount        = drRequest.TotalCount,
                        ExistCount        = drRequest.ExistCount,
                        Article           = drRequest.Article,
                        DateComplete_Plan = drRequest.DateComplete_Plan == DateTime.MinValue
                                                    ? (DateTime?)null
                                                    : drRequest.DateComplete_Plan,
                        DateComplete = drRequest.DateComplete == DateTime.MinValue
                                               ? (DateTime?)null
                                               : drRequest.DateComplete,
                        IsCustomerMaterials = drRequest.IsCustomerMaterials
                    });
                }
                return(project);
            }
        }
コード例 #4
0
ファイル: AgrProject.cs プロジェクト: MyLastAngel/Agregat
        // после этого перестает падать надо блокировать доступ к базе во время чтения записи..
        // куча клиентов лезет одновременно
        //static readonly object lockObject = new object();
        //public static LProjects Projects(DateTime? fromDate, StateTime stateTime, int previousId)
        //{
        //    lock (lockObject)
        //    {
        //    }
        //}

        public static LProjects Projects(DateTime?fromDate, StateTime stateTime, int previousId)
        {
            lock (Db.Ds)
            {
                if (!Db.LoadProjects())
                {
                    return(null);
                }
                AgrDataSet.ProjectsRow[] drsProjects;
                if (fromDate == null)
                {
                    if (stateTime == StateTime.Worked)
                    {
                        if (previousId >= 0)
                        {
                            drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                                          Select("TimeEndActual = '" + DateTime.MinValue
                                                 + "' AND Id > " + previousId, "Id");
                        }
                        else
                        {
                            drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                                          Select("TimeEndActual = '" + DateTime.MinValue +
                                                 "'");
                        }
                    }
                    else
                    {
                        drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.Select();
                    }
                }
                else
                {
                    switch (stateTime)
                    {
                    case StateTime.Changed:
                        drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                                      Select("Date > '" + fromDate + "'");
                        break;

                    case StateTime.Worked:
                        //drsProject = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                        //    Select("TimeEndActual = '" + DateTime.MinValue + "'");
                        if (previousId >= 0)
                        {
                            drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                                          Select(
                                "((TimeEndActual = '" +
                                DateTime.MinValue
                                + "') OR (TimeEndActual > '" + fromDate
                                + "')) AND Id > " + previousId, "Id");
                        }
                        else
                        {
                            drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.
                                          Select("(TimeEndActual = '" +
                                                 DateTime.MinValue
                                                 + "') OR (TimeEndActual > '" +
                                                 fromDate + "')");
                        }
                        break;

                    default:
                        drsProjects = (AgrDataSet.ProjectsRow[])Db.Ds.Projects.Select();
                        break;
                    }
                }
                var projects = new LProjects();
                int index1   = 0;
                for (int index = 0; index < drsProjects.Length; index++)
                {
                    if (index1 >= 10)
                    {
                        break;
                    }
                    AgrDataSet.ProjectsRow drProjects = drsProjects[index];
                    if ((previousId >= 0) && (previousId == drProjects.Id))
                    {
                        continue;
                    }
                    if (Db.LoadProject(drProjects.Id))
                    {
                        index1++;
                        AgrDataSet.ProjectRow         drProject        = drProjects.GetProjectRows()[0];
                        AgrDataSet.ClientProjectRow[] drsClientProject = drProjects.GetClientProjectRows();
                        if (drsClientProject.Length == 0)
                        {
                            continue;
                        }
                        AgrDataSet.ClientProjectRow drClientProject = drsClientProject[0];
                        AgrDataSet.ClientRow        drClient        = drClientProject.ClientRow;

                        AgrDataSet.ProjectProductRow[] drsProjectProduct = drProjects.GetProjectProductRows();
                        if (drsProjectProduct.Length == 0)
                        {
                            continue;
                        }
                        AgrDataSet.ProjectProductRow drProjectProduct = drsProjectProduct[0];
                        AgrDataSet.ProductRow        drProduct        = drProjectProduct.ProductRow;

                        var project = new AgrProject(drProject.Id)
                        {
                            ID            = drProject.Name,
                            Customer      = drClient.Name,
                            CustomerName  = drProject.CustomerName,
                            Product       = drProduct.Name,
                            Options       = drProject.Options,
                            ChangedDate   = drProjects.Date,
                            TimeEndActual =
                                drProjects.TimeEndActual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProjects.TimeEndActual,

                            IsManagerSetPlanDate = drProject.IsManagerSetPlanDate,

                            IsStop           = drProject.IsStop,
                            COM_Package_Type = drProject.COM_Package_Type,

                            #region ITO

                            #region G
                            Time_ITO_G_Plan =
                                drProject.Time_ITO_G_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_G_Plan,

                            Time_ITO_G_Actual =
                                drProject.Time_ITO_G_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_G_Actual,

                            Is_ITO_G_NotNeed = drProject.Is_ITO_G_NotNeed,

                            #endregion G

                            #region E
                            Time_ITO_E_Plan =
                                drProject.Time_ITO_E_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_E_Plan,

                            Time_ITO_E_Actual =
                                drProject.Time_ITO_E_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_E_Actual,

                            Is_ITO_E_NotNeed = drProject.Is_ITO_E_NotNeed,

                            #endregion E

                            #region R
                            Time_ITO_R_Plan =
                                drProject.Time_ITO_R_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_R_Plan,

                            Time_ITO_R_Actual =
                                drProject.Time_ITO_R_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_ITO_R_Actual,

                            ITO_R_Mode = drProject.ITO_R_Mode,

                            Is_ITO_R_NotNeed = drProject.Is_ITO_R_NotNeed,

                            #endregion R

                            #endregion ITO

                            #region WH

                            #region G
                            Time_WH_G_Plan =
                                drProject.Time_WH_G_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_G_Plan,

                            Time_WH_G_Actual =
                                drProject.Time_WH_G_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_G_Actual,

                            Is_WH_G_NotNeed = drProject.Is_WH_G_NotNeed,

                            Time_WH_G_Requests_Create =
                                drProject.Time_WH_G_Requests_Create == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_G_Requests_Create,

                            #endregion G

                            #region E
                            Time_WH_E_Plan =
                                drProject.Time_WH_E_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_E_Plan,

                            Time_WH_E_Actual =
                                drProject.Time_WH_E_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_E_Actual,

                            Is_WH_E_NotNeed = drProject.Is_WH_E_NotNeed,

                            Time_WH_E_Requests_Create =
                                drProject.Time_WH_E_Requests_Create == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_E_Requests_Create,

                            #endregion E

                            #region R
                            Time_WH_R_Plan =
                                drProject.Time_WH_R_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_R_Plan,

                            Time_WH_R_Actual =
                                drProject.Time_WH_R_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_WH_R_Actual,

                            Is_WH_R_NotNeed = drProject.Is_WH_R_NotNeed,

                            #endregion R

                            #endregion WH

                            #region OMTS

                            #region G
                            Time_OMTS_G_Plan =
                                drProject.Time_OMTS_G_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OMTS_G_Plan,

                            Time_OMTS_G_Actual =
                                drProject.Time_OMTS_G_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OMTS_G_Actual,

                            #endregion G

                            #region E
                            Time_OMTS_E_Plan =
                                drProject.Time_OMTS_E_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OMTS_E_Plan,

                            Time_OMTS_E_Actual =
                                drProject.Time_OMTS_E_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OMTS_E_Actual,

                            #endregion E

                            #endregion OMTS

                            TimeBegin     = drProject.TimeBegin,
                            TimeEndPlaned = drProject.TimeEndPlaned,
                            Com_New_Time  =
                                drProject.Com_New_Time == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Com_New_Time,
                            MF_Collector           = drProject.MF_Collector,
                            MF_Complete_Percentage = drProject.MF_Complete_Percentage,
                            MF_Level     = drProject.MF_Level,
                            MF_Rama      = drProject.MF_Rama,
                            MF_Post      = drProject.MF_Post,
                            MF_Agregat   = drProject.MF_Agregat,
                            MF_SH_Place  = drProject.MF_SH_Place,
                            MF_SH        = drProject.MF_SH,
                            MF_Time_Plan =
                                drProject.MF_Time_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.MF_Time_Plan,
                            MF_Time_Test_Actual =
                                drProject.MF_Time_Test_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.MF_Time_Test_Actual,
                            MF_Time = drProject.MF_Time == DateTime.MinValue ? (DateTime?)null : drProject.MF_Time,

                            #region OTK
                            Time_OTK_Plan =
                                drProject.Time_OTK_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OTK_Plan,

                            Time_OTK_G_Actual =
                                drProject.Time_OTK_G_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OTK_G_Actual,

                            Time_OTK_E_Actual =
                                drProject.Time_OTK_E_Actual == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drProject.Time_OTK_E_Actual,
                            Is_OTK_G_NotNeed = drProject.Is_OTK_G_NotNeed,
                            Is_OTK_E_NotNeed = drProject.Is_OTK_E_NotNeed,

                            #endregion OTK
                        };

                        // Сообщения
                        foreach (AgrDataSet.CommentRow drComment in drProjects.GetCommentRows())
                        {
                            project.Messages.Add(new AgrProjectComment(drComment.Time, drComment.UserName,
                                                                       drComment.Value));
                        }

                        // Недокомплект
                        foreach (AgrDataSet.RequestRow drRequest in drProjects.GetRequestRows())
                        {
                            project.Requests.Add(new AgrRequest((OMTSRequestType)drRequest.Type, drRequest.Name)
                            {
                                TotalCount        = drRequest.TotalCount,
                                ExistCount        = drRequest.ExistCount,
                                Article           = drRequest.Article,
                                DateComplete_Plan = drRequest.DateComplete_Plan == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drRequest.DateComplete_Plan,
                                DateComplete = drRequest.DateComplete == DateTime.MinValue
                                    ? (DateTime?)null
                                    : drRequest.DateComplete,
                                IsCustomerMaterials = drRequest.IsCustomerMaterials
                            });
                        }

                        projects.Add(project);
                    }
                }
                return(projects);
            }
        }
コード例 #5
0
ファイル: Db.cs プロジェクト: MyLastAngel/Agregat
        public static bool SetProject(AgrProject project)
        {
            try
            {
                AgrDataSet.ProjectsRow drProjects = Ds.Projects.FindById(project.ProjectId);
                if (drProjects == null)
                {
                    LogManager.LogError(unit, "SetProject. Ошибка. Проект не найден: " + project.ProjectId);
                    return(false);
                }
                drProjects.Date = DateTime.Now;

                drProjects.TimeEndActual = project.TimeEndActual == null
                    ? DateTime.MinValue
                    : (DateTime)project.TimeEndActual;

                AgrDataSet.ProjectRow[] drsProject = drProjects.GetProjectRows();
                AgrDataSet.ProjectRow   drProject  = drsProject[0];

                drProject.Name                   = project.ID;
                drProject.CustomerName           = project.CustomerName;
                drProject.Options                = project.Options;
                drProject.IsStop                 = project.IsStop;
                drProject.COM_Package_Type       = project.COM_Package_Type;
                drProject.MF_Complete_Percentage = project.MF_Complete_Percentage;

                AgrDataSet.ClientProjectRow drClientProject = drProjects.GetClientProjectRows()[0];
                AgrDataSet.ClientRow        drClient        = drClientProject.ClientRow;
                if (drClient.Name != project.Customer)
                {
                    var drsClient = (AgrDataSet.ClientRow[])Ds.Client.Select("Name = '" + project.Customer + "'");
                    if (drsClient.Length > 0)
                    {
                        drClientProject.ClientId = drsClient[0].Id;
                    }
                    else
                    {
                        drClientProject.Delete();
                        object newId = Ds.Client.Compute("MAX (Id)", "");
                        int    id    = (newId.ToString() == "") ? 1 : ((int)newId + 1);

                        drClient = Ds.Client.AddClientRow(id, project.Customer);
                        Ds.ClientProject.AddClientProjectRow(drClient, drProjects);
                    }
                }

                //drClient.Description = project.CustomerName;
                AgrDataSet.ProjectProductRow drProjectProduct = drProjects.GetProjectProductRows()[0];
                AgrDataSet.ProductRow        drProduct        = drProjectProduct.ProductRow;
                if (drProduct.Name != project.Product)
                {
                    var drsProduct = (AgrDataSet.ProductRow[])Ds.Product.Select("Name = '" + project.Product + "'");
                    if (drsProduct.Length > 0)
                    {
                        drProjectProduct.ProductId = drsProduct[0].Id;
                    }
                    else
                    {
                        drProjectProduct.Delete();
                        object newId = Ds.Product.Compute("MAX (Id)", "");
                        int    id    = (newId.ToString() == "") ? 1 : ((int)newId + 1);

                        drProduct = Ds.Product.AddProductRow(id, project.Product, "");
                        Ds.ProjectProduct.AddProjectProductRow(drProjects, drProduct);
                    }
                }
                //drProduct.Name = project.Product;

                drProject.IsManagerSetPlanDate = project.IsManagerSetPlanDate;

                #region ITO

                #region G
                drProject.Time_ITO_G_Plan = project.Time_ITO_G_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_G_Plan;

                drProject.Time_ITO_G_Actual = project.Time_ITO_G_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_G_Actual;

                drProject.Is_ITO_G_NotNeed = project.Is_ITO_G_NotNeed;
                #endregion G

                #region E
                drProject.Time_ITO_E_Plan = project.Time_ITO_E_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_E_Plan;

                drProject.Time_ITO_E_Actual = project.Time_ITO_E_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_E_Actual;

                drProject.Is_ITO_E_NotNeed = project.Is_ITO_E_NotNeed;
                #endregion E

                #region R
                drProject.Time_ITO_R_Plan = project.Time_ITO_R_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_R_Plan;

                drProject.Time_ITO_R_Actual = project.Time_ITO_R_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_ITO_R_Actual;

                drProject.ITO_R_Mode = project.ITO_R_Mode;

                drProject.Is_ITO_R_NotNeed = project.Is_ITO_R_NotNeed;
                #endregion R

                #endregion ITO

                #region WH

                #region G
                drProject.Time_WH_G_Plan = project.Time_WH_G_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_G_Plan;

                drProject.Time_WH_G_Actual = project.Time_WH_G_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_G_Actual;

                drProject.Is_WH_G_NotNeed = project.Is_WH_G_NotNeed;
                #endregion G

                #region E
                drProject.Time_WH_E_Plan = project.Time_WH_E_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_E_Plan;

                drProject.Time_WH_E_Actual = project.Time_WH_E_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_E_Actual;

                drProject.Is_WH_E_NotNeed = project.Is_WH_E_NotNeed;
                #endregion E

                #region R
                drProject.Time_WH_R_Plan = project.Time_WH_R_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_R_Plan;

                drProject.Time_WH_R_Actual = project.Time_WH_R_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_R_Actual;

                drProject.Is_WH_R_NotNeed = project.Is_WH_R_NotNeed;
                #endregion R

                drProject.Time_WH_E_Requests_Create = project.Time_WH_E_Requests_Create == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_E_Requests_Create;
                drProject.Time_WH_G_Requests_Create = project.Time_WH_G_Requests_Create == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_WH_G_Requests_Create;
                #endregion WH

                #region OMTS
                drProject.Time_OMTS_E_Plan = project.Time_OMTS_E_Plan == null
                ? DateTime.MinValue
                : (DateTime)project.Time_OMTS_E_Plan;

                drProject.Time_OMTS_E_Actual = project.Time_OMTS_E_Actual == null
                ? DateTime.MinValue
                : (DateTime)project.Time_OMTS_E_Actual;

                drProject.Time_OMTS_G_Plan = project.Time_OMTS_G_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_OMTS_G_Plan;
                drProject.Time_OMTS_G_Actual = project.Time_OMTS_G_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_OMTS_G_Actual;
                #endregion OMTS

                drProject.TimeBegin     = project.TimeBegin;
                drProject.TimeEndPlaned = project.TimeEndPlaned;
                drProject.Com_New_Time  = project.Com_New_Time == null
                    ? DateTime.MinValue
                    : (DateTime)project.Com_New_Time;

                #region MF
                drProject.MF_Level    = project.MF_Level;
                drProject.MF_Rama     = project.MF_Rama;
                drProject.MF_Post     = project.MF_Post;
                drProject.MF_Agregat  = project.MF_Agregat;
                drProject.MF_SH_Place = project.MF_SH_Place;
                drProject.MF_SH       = project.MF_SH;
                //drProject.MF_Test = project.MF_Test;
                drProject.MF_Time_Plan = project.MF_Time_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.MF_Time_Plan;

                drProject.MF_Time_Test_Actual = project.MF_Time_Test_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.MF_Time_Test_Actual;
                drProject.MF_Time = project.MF_Time == null
                    ? DateTime.MinValue
                    : (DateTime)project.MF_Time;
                drProject.MF_Collector           = project.MF_Collector;
                drProject.MF_Complete_Percentage = project.MF_Complete_Percentage;
                #endregion MF

                #region OTK
                drProject.Time_OTK_Plan = project.Time_OTK_Plan == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_OTK_Plan;

                drProject.Time_OTK_G_Actual = project.Time_OTK_G_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_OTK_G_Actual;
                drProject.Time_OTK_E_Actual = project.Time_OTK_E_Actual == null
                    ? DateTime.MinValue
                    : (DateTime)project.Time_OTK_E_Actual;
                drProject.Is_OTK_G_NotNeed = project.Is_OTK_G_NotNeed;
                drProject.Is_OTK_E_NotNeed = project.Is_OTK_E_NotNeed;

                #endregion OTK

                // недокомплект
                var drsRequest = (AgrDataSet.RequestRow[])Ds.Request.Select("ProjectId = " + drProject.Id);
                foreach (AgrDataSet.RequestRow drRequest in drsRequest)
                {
                    drRequest.Delete();
                }

                foreach (AgrRequest request in project.Requests)
                {
                    Ds.Request.AddRequestRow(drProjects,
                                             request.Article, request.Name, (int)request.Type,
                                             request.DateComplete_Plan == null ? DateTime.MinValue : (DateTime)request.DateComplete_Plan,
                                             request.DateComplete == null ? DateTime.MinValue : (DateTime)request.DateComplete,
                                             request.TotalCount, request.ExistCount, request.IsCustomerMaterials);
                }
                Storage.SaveClientList(Ds);
                Storage.SaveProductList(Ds);
                return(Storage.SaveProject(Ds, project.ProjectId) && Storage.SaveRequest(Ds, project.ProjectId));
            }
            catch (Exception exc)
            {
                LogManager.LogError(unit, "SetProject. Ошибка. " + exc.Message);
                return(false);
            }
        }