private void FillProducts(AgrDataSet.ProjectsRow drProjects) { foreach (AgrDataSet.ProjectProductRow drProjectProject in drProjects.GetProjectProductRows()) { AgrDataSet.ProductRow drProduct = drProjectProject.ProductRow; project_list.Items.Add(drProduct.Id.ToString(), drProduct.Name, -1); } }
public static bool EditProduct(int id, string name, string description) { AgrDataSet.ProductRow drProduct = Ds.Product.FindById(id); drProduct.Name = name; drProduct.Description = description; Storage.SaveProductList(Ds); return(true); }
private void FillProjects(AgrDataSet.ProductRow drProduct) { foreach (AgrDataSet.ProjectProductRow drProductProject in drProduct.GetProjectProductRows()) { AgrDataSet.ProjectsRow drProjects = drProductProject.ProjectsRow; AgrDataSet.ProjectRow[] drsProject = drProjects.GetProjectRows(); project_list.Items.Add(drProjects.Id.ToString(), drsProject.Length > 0 ? drsProject[0].Name : drProjects.Id.ToString(), -1); FillClients(drProjects); } }
public static AgrDataSet.ProductRow AddProduct(string name) { try { object newId = Ds.Product.Compute("MAX (Id)", ""); int id = (newId.ToString() == "") ? 1 : ((int)newId + 1); AgrDataSet.ProductRow drProduct = Ds.Product.AddProductRow(id, name, ""); return(Storage.SaveProductList(Ds) ? drProduct : null); } catch (Exception) { return(null); } }
public static int CreateProject(string id, string customer, string customerName, string product, string options, DateTime sDate, DateTime eDate, string comments, string userName, bool isManagerSetPlanDate, string packageType) { //var drsProject = (AgrDataSet.ProjectRow[])Ds.Project.Select("Name= '" + id + "'"); //if (drsProject.Length != 0) // return drsProject[0].Id; var drsProduct = (AgrDataSet.ProductRow[])Ds.Product.Select("Name= '" + product + "'"); AgrDataSet.ProductRow drProduct = drsProduct.Length == 0 ? AddProduct(product) : drsProduct[0]; var drsClient = (AgrDataSet.ClientRow[])Ds.Client.Select("Name= '" + customer + "'"); AgrDataSet.ClientRow drClient = drsClient.Length == 0 ? AddClient(customer) : drsClient[0]; AgrDataSet.ProjectRow drProject = AddProject(id, customerName, drClient, drProduct, options, sDate, eDate, comments, userName, isManagerSetPlanDate, packageType); return(drProject == null ? -1 : drProject.Id); }
private void UserListSelectedIndexChanged(object sender, System.EventArgs e) { splitContainer1.Panel2.Enabled = (user_list.SelectedItems.Count == 1); project_list.Items.Clear(); project_list.Items.Clear(); if (user_list.SelectedItems.Count == 1) { AgrDataSet.ProductRow drProduct = Db.Ds.Product. FindById(int.Parse(user_list.SelectedItems[0].Name)); name_text.Text = drProduct.Name; description_text.Text = drProduct.Description; FillProjects(drProduct); } else { name_text.Text = ""; description_text.Text = ""; } }
public static bool CheckIsExist(string id, string customer, string customerName, string product, string options, DateTime sDate, DateTime eDate) { var drsProject = (AgrDataSet.ProjectRow[])Ds.Project.Select( "Name = '" + id + "' AND CustomerName = '" + customerName + "' AND Options = '" + options + "' AND TimeBegin = '" + sDate + "' AND TimeEndPlaned = '" + eDate + "'"); foreach (AgrDataSet.ProjectRow drProject in drsProject) { var drsProduct = (AgrDataSet.ProductRow[])Ds.Product.Select("Name= '" + product + "'"); if (drsProduct.Length < 0) { continue; } AgrDataSet.ProductRow drProduct = drsProduct[0]; if (Ds.ProjectProduct.FindByProjectIdProductId(drProject.Id, drProduct.Id) == null) { continue; } var drsClient = (AgrDataSet.ClientRow[])Ds.Client.Select("Name= '" + customer + "'"); if (drsClient.Length < 0) { continue; } AgrDataSet.ClientRow drClient = drsClient[0]; if (Ds.ClientProject.FindByClientIdProjectId(drClient.Id, drProject.Id) == null) { continue; } return(true); } return(false); }
/// <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); } }
// после этого перестает падать надо блокировать доступ к базе во время чтения записи.. // куча клиентов лезет одновременно //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); } }
private void AddUserBtnClick(object sender, System.EventArgs e) { AgrDataSet.ProductRow id = Db.AddProduct(""); FillProduct(-1, id.Id); }
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); } }
//public static AgrProject Project(int id) //{ // AgrProject project = ProjectList.Projects.FirstOrDefault(s => s.ProjectId == id); // if (project != null) // project.Load(); // return project; //} public static AgrDataSet.ProjectRow AddProject(string name, string customerName, AgrDataSet.ClientRow drClient, AgrDataSet.ProductRow drProduct, string options, DateTime sDate, DateTime eDate, string comments, string user, bool isManagerSetPlanDate, string packageType) { try { object newId = Ds.Projects.Compute("MAX (Id)", ""); int id = (newId.ToString() == "") ? 1 : ((int)newId + 1); AgrDataSet.ProjectsRow drProjects = Ds.Projects.AddProjectsRow(id, DateTime.Now, DateTime.MinValue); AgrDataSet.ClientProjectRow drClientProject = Ds.ClientProject.AddClientProjectRow(drClient, drProjects); AgrDataSet.ProjectProductRow drProjectProduct = Ds.ProjectProduct.AddProjectProductRow(drProjects, drProduct); //string[] opts = options.Split(','); //foreach (var opt in opts.Select(s => s.Trim()).Where(s => s.Length > 0)) //{ // AgrDataSet.OptionRow drOption = Ds.Option.FindByName(opt); // if (drOption == null) // drOption = Ds.Option.AddOptionRow(opt, ""); // AgrDataSet.ProjectOptionRow drProjectOption = Ds.ProjectOption. // AddProjectOptionRow(drProjects.Id, drProduct.Id, drOption); //} DateTime date = DateTime.MinValue; AgrDataSet.ProjectRow drProject = Ds.Project.AddProjectRow(drProjects, name, customerName, isManagerSetPlanDate, date, date, date, date, date, date, "", false, false, false, date, date, date, date, date, date, false, false, false, date, date, date, date, date, date, sDate, eDate, date, "", "", "", "", "", "", false, date, date, date, date, "", "", date, date, date, false, false, options, packageType, false); // Сораняем проект if (!Storage.SaveProject(Ds, id)) { drProjects.Delete(); return(null); } // Сохраняем только существующий комментарий if (!string.IsNullOrEmpty(comments)) { var drUser = Ds.User.FindByName(user); Ds.Comment.AddCommentRow(drProjects, DateTime.Now, comments, drUser); Storage.SaveComment(Ds, id); } int idx = ProjectLoaded.BinarySearch(id); if (idx < 0) { ProjectLoaded.Insert(~idx, id); } return(drProject); } catch (Exception) { return(null); } }