/// <summary>Загружает лимиты договора</summary> public bool Load() { try { using (var PFL = new PerfomanceLogger(Contract.SessionLog, "ContractLimits.Load")) { if (Contract.LimitsCursor != null) { var Data = new QueryResult(Contract.LimitsCursor.GetDataReader()); this.Clear(); // загружаем все лимиты (online, offline и комбинированные) /*QueryResult Data = OraQuery.Execute(Connection, "select cl.ID, cl.Limit, cl.Duration, cl.PurseID, p.Name as PurseName, p.Type as PurseType from ContractLimits cl, Purses p where cl.PurseID = p.ID and cl.ContractID = :ContractID order by PurseType, PurseID, Duration", new string[] { "ContractID" }, new object[] { Contract.ID });*/ foreach (DataRow row in Data.Rows) Add(new LimitInfo(this, row)); } } } catch (Exception e) { ErrorMessage.Add("Ошибка при получении лимитов карты\n{0}", e.Message); } return ErrorMessage.IsEmpty; }
private void UpdateCertTankPlants() { //StatusSplash.Create(MainStatusStrip); //StatusSplash.Message("���������� ������� �� ������������"); DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetCertTankPlants", new object[] { Date1.Value, Date2.Value, null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); PlantCombo.DisplayMember = "ShortPlantName"; PlantCombo.DataSource = DataResult; Functions.SetComboDropDownAutoWidth(PlantCombo); //StatusSplash.Close(); }
// Acttion, ������������ ������� �� ���������� ������� private void ShowChartAction_Execute(object sender, EventArgs e) { Plant CurrentPlant; ReportPart CurrentPart; DataRow ChartRow; BookColumn ChartColumn; GetCurrentCellInfo(out CurrentPlant, out CurrentPart, out ChartRow, out ChartColumn); if (ChartColumn == null) { MessageBox.Show("���������� ������� ������� � ������� ��� ��������� ��������", "�������� ��������", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ChartRow == null || CurrentPart == null) { MessageBox.Show("���������� ������� ������ � ��������� ��� ��������� ��������", "�������� ��������", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string ModuleNorm = FM[CurrentPart.NormRow, ChartColumn.column1]; string ModuleName = ""; string CurrentFieldIndex = CurrentPart.FieldName(ChartColumn.column1).Split('*')[1]; object CurrentLowerNorm = ChartRow["LowerLimit*" + CurrentFieldIndex]; object CurrentUpperNorm = ChartRow["UpperLimit*" + CurrentFieldIndex]; List<Plant> PlantsList = new List<Plant>(); foreach (ReportPart part in Parts) if (part.Data != null && part.Data.Rows.Count > 0) { Plant p = plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"])); if (!PlantsList.Contains(p)) PlantsList.Add(p); } QueryResult[] ChartDatas = new QueryResult[PlantsList.Count]; DataRow ModuleRow; int i = 0; foreach (ReportPart part in Parts) { if (part.Data != null && part.Data.Rows.Count > 0) { string FieldName = part.FieldName(ChartColumn.column1); if (FieldName != "") { string[] values = FieldName.Split('*'); int ColumnIndex = Functions.ConvertToInt32(values[1]); ModuleRow = part.Columns.Rows[ColumnIndex]; ModuleName = ModuleRow["TextModule"].ToString(); if (ModuleRow["TestGroup"].ToString().Trim() != "") ModuleName = ModuleRow["TestGroup"].ToString() + ", " + ModuleName; string DateField = "qaodecisiontime"; string CertField = "batchno"; string DataField = "Result*" + ColumnIndex.ToString(); string MinField = "LowerLimit*" + ColumnIndex.ToString(); string MaxField = "UpperLimit*" + ColumnIndex.ToString(); // ���� ����� ���������, �� /*if (ModuleNorm.ToLower() != ModuleRow["ModuleNorm"].ToString().ToLower()) continue;*/ if (CurrentLowerNorm.ToString().ToLower() != part.Data[0, MinField].ToString().ToLower() || CurrentUpperNorm.ToString().ToLower() != part.Data[0, MaxField].ToString().ToLower()) continue; // ��������� ����� �������� ������� QueryResult dt = new QueryResult(part.Data.DefaultView.ToTable(false, DateField, CertField, DataField, MinField, MaxField)); // �������������� �������� dt.Columns[DateField].ColumnName = "Date"; dt.Columns[CertField].ColumnName = "Passport"; dt.Columns[DataField].ColumnName = "Value"; dt.Columns[MinField].ColumnName = "Min"; dt.Columns[MaxField].ColumnName = "Max"; // ���������� ����� �������� dt.AddColumn("PlantName", typeof(string), plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"])).ShortPlantName); dt.AddColumn("Module", typeof(string), ModuleName); dt.AddColumn("Norm", typeof(string), ModuleRow["ModuleNorm"]); if (Functions.IsNumber(FM[part.RowAvg, ChartColumn.column1])) dt.AddColumn("Average", typeof(double), FM[part.RowAvg, ChartColumn.column1]); i = PlantsList.IndexOf(plants.FindPlant(Convert.ToInt32(part.Data[0, "plantid"]))); if (ChartDatas[i] == null) ChartDatas[i] = new QueryResult(dt); else { // ���� � ������ ������ ���� �������� � ����������� �������, �� �� ����� ���������� ChartDatas[i].Merge(dt); // �������� ����������������� �������� ����� ����������� ������ if (ChartDatas[i].Columns.Contains("Average")) { object newavg = ChartDatas[i].Compute("avg(Average)", ""); foreach (DataRow row in ChartDatas[i].Rows) row["Average"] = newavg; } } } } if (ChartDatas[i] != null) // ��������� ������ ����� ������������ (����� ����������, ���� ���� ����������� ������ ���������) { DataView dv = ChartDatas[i].DefaultView; dv.Sort = "Date, Passport"; ChartDatas[i] = new QueryResult(dv.ToTable()); } } //Array.Resize<QueryResult>(ref ChartDatas, 5); ChartForm form = new ChartForm(); form.Text = string.Format("{0}. {1}, {2}", (ProductCombo.SelectedItem as DataRowView)["Description"], ModuleName, ModuleNorm); form.TitleLabel.Text = form.Text; form.Initialize(ChartDatas); form.WindowState = FormWindowState.Maximized; form.Show(); }
int ResultIndex(QueryResult Columns, string ModuleText) { for (int j = 0; j < Columns.Rows.Count; j++) if (Columns[j, "ModuleText"].ToString() == ModuleText) return j; return -1; }
// ��������� QueryResult ��� ������ ��� ���������� �������� ������ private QueryResult GetResultForColumn(ReportPart part, params BookColumn[] columns) { QueryResult result = new QueryResult(); string[] FieldNames = new string[columns.Length]; for (int i = 0; i < FieldNames.Length; i++) { FieldNames[i] = part.FieldName(columns[i].column1, StaticColumns, part.DynamicColumns); if (FieldNames[i] == "") return null; result.Columns.Add(FieldNames[i]); } /*for (int i = 0; i < part.Data.Rows.Count; i++) //if (!HasNullValues(part.Data.Rows[i], FieldNames)) result.Rows.Add(part.Data[i, FieldNames]);*/ for (int r = part.Row1; r <= part.Row2; r++) { object[] values = new object[columns.Length]; for (int j = 0; j < columns.Length; j++) values[j] = FM[r, columns[j].column1]; result.Rows.Add(values); } return result; }
// ��� �������� ���� ��������� ������ ��������� �������� �� ������� ������ � ���������� ����� �� ������� // ������ �� ����������� ������� private void BookContextMenu_Opening(object sender, CancelEventArgs e) { Plant CurrentPlant; ReportPart CurrentPart; DataRow CurrentRow; BookColumn CurrentColumn; GetCurrentCellInfo(out CurrentPlant, out CurrentPart, out CurrentRow, out CurrentColumn); PassportMenuAction.Enabled = CurrentPlant != null && CurrentPart != null && CurrentRow != null; ShowChartAction.Enabled = CurrentColumn != null && CurrentPart != null && CurrentRow != null; // ��������� MenuItem'� ����������� � ��������� ������ �������� if (PassportMenuAction.Enabled) { DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetPassportLanguages", new object[] { CurrentPlant.ID, CurrentRow["qaonr"], null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); // ������ ����� PassportMenuItem.DropDownItems.Clear(); MainPassportMenuItem.DropDownItems.Clear(); foreach (DataRow row in DataResult.Rows) { ToolStripMenuItem item = new ToolStripMenuItem(); MainActionList.SetAction(item, ShowPassportAction); item.Text = string.Format("{0} �{1} {2}", CurrentPlant.ShortPlantName, CurrentRow["batchno"], row["LanguageName"]); item.Tag = item.Tag = new PassportInfo(CurrentPlant.ID, CurrentRow["productid"], CurrentRow["qaonr"], CurrentRow["certnr"], row["LanguageID"]); PassportMenuItem.DropDownItems.Add(item); ToolStripMenuItem mainitem = new ToolStripMenuItem(); MainActionList.SetAction(mainitem, ShowPassportAction); mainitem.Text = item.Text; mainitem.Tag = item.Tag; MainPassportMenuItem.DropDownItems.Add(mainitem); } PassportMenuAction.Enabled = PassportMenuItem.DropDownItems.Count > 0; } // ��������� MenuItem'� ����������� � ��� ������������ ���������, ������� �������� if (CurrentPlant != null && CurrentRow != null && CurrentPlant.IsChild) { DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetParentPassportsInfo", new object[] { CurrentPlant.ID, CurrentRow["qaonr"], null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); if (DataResult.Rows.Count > 0) { PassportMenuItem.DropDownItems.Add("-"); MainPassportMenuItem.DropDownItems.Add("-"); } foreach (DataRow row in DataResult.Rows) { ToolStripMenuItem item = new ToolStripMenuItem(); MainActionList.SetAction(item, ShowPassportAction); item.Text = row["PassportName"].ToString(); item.Tag = new PassportInfo(row["SourcePlantID"], row["ProductID"], row["SourceQaonr"], row["SourceCertnr"], row["LanguageID"]); PassportMenuItem.DropDownItems.Add(item); ToolStripMenuItem mainitem = new ToolStripMenuItem(); MainActionList.SetAction(mainitem, ShowPassportAction); mainitem.Text = item.Text; mainitem.Tag = item.Tag; MainPassportMenuItem.DropDownItems.Add(mainitem); } PassportMenuAction.Enabled = PassportMenuItem.DropDownItems.Count > 0; } }
public void Show(OracleConnection connection, PassportInfo info) { if (Functions.IsNull(info)) return; Splash.ProgressInit(2); try { string HostName = Dns.GetHostName(); string IPAddress = Functions.GetCurrentIPAddress(); string TemporaryFileName; // запрос для получения вида паспорта (pdf файл) Splash.Message("Получение вида паспорта..."); MemoryStream PassportStream = GetPassport(connection, info.PlantID, info.OrderID, info.LanguageID); Splash.ProgressAdd(); if (!Functions.IsNull(PassportStream)) // нашли вид паспорта { Splash.ProgressMaximum(4); Splash.Message("Маркировка паспорта..."); PassportStream = MarkPassport(PassportStream); // маркируем документ - добавляем слова "Копия" и разную информацию if (Functions.IsNull(PassportStream)) { MessageBox.Show("Ошибка при маркировке паспорта. Паспорт без маркировке 'COPY' выдать нельзя", "Просмотр паспорта", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TemporaryFileName = GetTempFilePath(".pdf"); FileStream FS = new FileStream(TemporaryFileName, FileMode.Create, FileAccess.Write); PassportStream.WriteTo(FS); FS.Close(); Splash.ProgressAdd(); } else { Splash.ProgressMaximum(6); // запрос для получения данных паспорта Splash.Message("Получение данных паспорта..."); OracleCommand DataCommand = OracleProc.Execute(connection, "DataAccessPKG.GetPassportData", new object[] { info.PlantID, info.OrderID, info.LanguageID, null }); QueryResult Data = new QueryResult(DataCommand.Parameters["rc"].Value); Splash.ProgressAdd(); Splash.Message("Загрузка шаблона паспорта..."); MemoryStream TemplateStream = GetPassportTemplate(connection, info.PlantID, info.ProductID, info.LanguageID); Splash.ProgressAdd(); Splash.Message("Формирование документа..."); //PassportTemplate CurrentTemplate = plant.PassportTemplates.FindLanguage(LanguageID); if (TemplateStream == null) { MessageBox.Show(string.Format("Отсутствует шаблон паспорта продукта {0} (ID предприятия: {1}) для языка {2}. Обратитесь в тех.поддержку за помощью", info.ProductID, info.PlantID, info.LanguageID), "Просмотр паспорта", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Data.Rows.Count == 0) { MessageBox.Show("Отсутствуют данные по выбранному паспорту. Попробуйте обновить данные за текущий период", "Просмотр паспорта", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MSWordReport word = new MSWordReport(TemplateStream); QueryResult PassportData = FormatPassportData(Data); word.Execute(PassportData); // добавляем информацию о пользователе Data.AddColumn("UserInfo", typeof(string), string.Format("Пользователь: {0} ({1}). Компьютер: {2} ({3})", Program.StartForm.current.User.name, Common.PZUsers.Current.WindowsDomainName(), HostName, IPAddress)); Data.AddColumn("CreationDate", typeof(DateTime), DateTime.Now); word.Document.MailMerge.Execute(Data.Rows[0]); word.PrepareToSave(); word.Document.Protect(Aspose.Words.ProtectionType.ReadOnly); // вставляем знак "Копия" Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(word.Document); builder.MoveToHeaderFooter(Aspose.Words.HeaderFooterType.HeaderPrimary); System.Drawing.Image image = System.Drawing.Image.FromFile(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Images\\Exclamation.gif")); double useablePageWidth = builder.PageSetup.PageWidth - builder.PageSetup.LeftMargin - builder.PageSetup.RightMargin; double useablePageHeight = builder.PageSetup.PageHeight - builder.PageSetup.TopMargin - builder.PageSetup.BottomMargin; const int PointsPerInch = 72; double imageWidth = (image.Width / image.HorizontalResolution) * PointsPerInch; double imageHeight = (image.Height / image.VerticalResolution) * PointsPerInch; double imageLeft = (useablePageWidth - imageWidth) / 2; double imageTop = (useablePageHeight - imageHeight) / 2; builder.InsertImage(image, Aspose.Words.RelativeHorizontalPosition.Margin, imageLeft, Aspose.Words.RelativeVerticalPosition.Margin, imageTop, imageWidth, imageHeight, Aspose.Words.WrapType.None, Aspose.Words.WrapSide.Both, true, null); TemporaryFileName = GetTempFilePath(".doc"); word.Document.Save(TemporaryFileName); Splash.ProgressAdd(); } // логирование паспорта Splash.Message("Запись в журнал операций..."); OracleProc.Execute(connection, "LogPKG.LogPassport", new object[] { info.PlantID, info.CertificateID, info.OrderID, Program.StartForm.current.Program.id, Program.StartForm.current.User.id, HostName, IPAddress, Common.PZUsers.Current.WindowsDomainName() }); connection.Commit(); Splash.ProgressAdd(); Splash.Message(TemporaryFileName.EndsWith(".doc") ? "Запуск Microsoft Word..." : "Запуск Adobe Acrobat Reader..."); //PrintDocumentFromWord(TemporaryFileName); OpenDocument(TemporaryFileName); Splash.ProgressAdd(); } finally { Splash.Close(); } /*System.Diagnostics.Process.Start(TemporaryFileName); Splash.ProgressAdd(); */ }
private void UpdatePlants() { DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetPlants", new object[] { null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); for (int i = 0; i < DataResult.Rows.Count; i++) { plants.Add(new Plant(Convert.ToInt32(DataResult[i, "PlantID"]), DataResult[i, "shortplantname"].ToString(), DataResult[i, "longplantname"].ToString(), DataResult[i, "datasource"].ToString(), Convert.ToInt32(DataResult[i, "sortorder"]), DataResult[i, "reporturl"].ToString(), Functions.ConvertToBool(DataResult[i, "ischild"]))); } }
public void Initialize(QueryResult[] ChartDatas) { if (ChartDatas != null) { FilledDatas = new List<QueryResult>(); foreach (QueryResult cd in ChartDatas) if (cd != null && cd.Rows.Count > 0) FilledDatas.Add(cd); } DisplayCharts(); OneChartMenuItem_CheckedChanged(OneChartMenuItem, new EventArgs()); }
private void onBankFinish(QueryResult result) { AppendSumLog (result.batchCurrnum + "更新结算标志"); List<QueryItem> jsonQueryItems = new List<QueryItem> (); string nowTimeStr = DateTime.Now.ToString ("yyyy-MM-dd HH:mm:ss"); string[] fields = new string[] { "status", "results", "reciveDate" }; try { if (result.batchStatus == 2) { //商户审核拒绝 QueryItem jsonItem = new QueryItem () { table = "transactionSum", action = DBAction.Update, where = " batchCurrnum='" + result.batchCurrnum + "'", fields = fields, values = new string[]{ "-2", "商户审核拒绝", nowTimeStr } }; jsonQueryItems.Add (jsonItem); } else { if (result.batchEContent == null) throw new Exception ("获取明细为空"); string logStr = ""; foreach (QueryResult.DetailInfo detail in result.batchEContent) { QueryItem jsonItem = new QueryItem () { table = "transactionSum", action = DBAction.Update, where = " batchCurrnum='" + result.batchCurrnum + "'",//+ "' and id=" + detail.tradeNum, fields = fields, values = new string[3] }; switch (detail.status) { case "": case "处理中": jsonItem.values [0] = "1"; break; case "成功": jsonItem.values [0] = "3"; break; case "失败": jsonItem.values [0] = "-2"; break; default: throw new Exception ("处理结果明细有未定义的状态值"); } logStr += detail.faren + detail.status + "; "; jsonItem.values [1] = detail.reason; jsonItem.values [2] = nowTimeStr; jsonQueryItems.Add (jsonItem); } SetBankLog (result.batchCurrnum, logStr); } string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject (jsonQueryItems); string resultStr = execDb (jsonStr); JsonMessage<string> jsonMessage = Newtonsoft.Json.JsonConvert.DeserializeObject<JsonMessage<string>> (resultStr); if (jsonMessage.Message != null) throw new Exception (jsonMessage.Message); } catch (Exception ex) { AppendSumLog (result.batchCurrnum + "更新结算标志异常:"+ ex.Message); onError ("更新结算标志异常:", ex); } }
private void UpdateAction_Execute(object sender, EventArgs e) { QueryResult UniquePlant = new QueryResult(); try { Book.Visible = false; Book.AutoRedraw = false; FM.ClearBook(); FM.Book.BackColorBkg = Color.FromKnownColor(KnownColor.Control); FM.Book.Locked = false; int row = 2 /*1 - для заголовка*/, column = 1, maxrow = int.MinValue; bool allflag = (IntegralCheck.Checked && /*!PlantsCheck.Checked &&*/ !UNCCheck.Checked && !ProductsCheck.Checked); if (allflag) { UNCCheck.Checked = true; UNCCheck.Enabled = false; StatusSplash.ProgressInit(UNCCombo.Items.Count); } StatusSplash.Create(MainStatusStrip); for (int p = 0; p < (allflag ? UNCCombo.Items.Count : 1); p++) { StatusSplash.Message("Создание и анализ отчета..."); if (allflag) UNCCombo.SelectedIndex = p; // строим запрос OracleCommand Command = DataConnection.CreateCommand(); Command.CommandText = @" select unique plantid, longplantname, sortorder, standardnr, /*productid,*/ productdocument, /*ProductSpecification,*/ uncproductcode, synonymtext, /*productname,*/ testnd, testgroup, textmodule, uniontext, reqtext1, unit, uncmodulecode, sortnr, /*okpgroup, okpcode, ntd, shortname, tradename, ndname,*/ uncproduct from productspecificationview where /*plantid != 3 and*/ 1=1 %PlantMacro% %UNCMacro% %ProductMacro% order by uncproductcode, sortnr, sortorder, standardnr, synonymtext"; ApplyPlantMacro(Command); ApplyUNCMacro(Command); ApplyProductMacro(Command); QueryResult Data = new QueryResult(Command.ExecuteReader()); foreach (DataRow datarow in Data.Rows) foreach (DataColumn datacolumn in Data.Columns) datarow[datacolumn.ColumnName] = StartForm.DictionaryReplace(datarow[datacolumn.ColumnName].ToString()); QueryResult[] SplittedData = Data.Split("PlantID, LongPlantName", out UniquePlant); column = 1; Parts = new List<AnalyzePart>(); for (int i = 0; i < UniquePlant.Rows.Count; i++) { int startrow = row; ReportProduct(ref row, ref column, SplittedData[i], UniquePlant.Rows[i]); if (IntegralCheck.Checked) { //column += MaxCol; maxrow = Math.Max(maxrow, row); row = startrow; } } if (allflag) { row = maxrow + 1; FM.SetBorder(row, 1, row, FM.ColumnsCount, EdgeEnum.Top, LineStyleEnum.Thick); StatusSplash.ProgressAdd(); } if (IntegralCheck.Checked) AnalyzeParts(); } //FM.Book.Rows = maxrow + FM.Book.FixedRows; ReportTitle(1); if (allflag) { UNCCheck.Checked = false; UNCCheck.Enabled = true; } } finally { FM.Book.Locked = true; Book.AutoRedraw = true; Book.Refresh(); Book.Visible = true;// UniquePlant.Rows.Count > 0; StatusSplash.Close(); StatusSplash.Close(); } }
private void ReportProduct(ref int row, ref int column, QueryResult PlantData, DataRow Plant) { int maxrow = int.MinValue, startrow = row; // Делим данные по продуктам QueryResult UniqueProduct; // UNCProductCode, ProductName, SynonymText, TradeName, NDName, NTD, ProductDocument, TradeName, NDName, NTD QueryResult[] SplittedData = PlantData.Split("StandardNR, UNCProductCode, SynonymText, ProductDocument", out UniqueProduct); for (int i = 0; i < UniqueProduct.Rows.Count; i++) { if (i > 0 && !IntegralCheck.Checked) row += 2; ReportData(ref row, column, SplittedData[i], Plant, UniqueProduct.Rows[i]); maxrow = Math.Max(maxrow, row); if (IntegralCheck.Checked) { column += MaxCol; row = startrow; } /*else row++;*/ // рисуем границу } //row--; row = maxrow; }
private void ReportData(ref int row, int column, QueryResult ProductData, DataRow Plant, DataRow Product) { int cMethod, cModule, cUnit, cNorm, cUNCCode, cFirst, cLast; CalculateColumns(column, out cMethod, out cModule, out cUnit, out cNorm, out cUNCCode, out cFirst, out cLast); int startdrawrow = row; FM.SetColumnWidth(cMethod, cMethod, 150); FM.SetColumnWidth(cModule, cModule, 500); FM.SetColumnWidth(cUnit, cUnit, 120); FM.SetColumnWidth(cNorm, cNorm, 140); FM.SetColumnWidth(cUNCCode, cUNCCode, 60); // выводим название завода if (Plant != null) { FM.DrawCell(row, cFirst, row, cLast, Plant["LongPlantName"].ToString(), AlignmentEnum.CenterCenter, false, true).FontSize = 10; FM.SetRowAutoHeight(row, row); row++; } // выводим заголовок продукта FM.DrawCell(row, cFirst, row, cLast, string.Format("Код: {0}. Наименование: {1}", Functions.IsNull(Product["UNCProductCode"]) ? "Не прокодирован" : Product["UNCProductCode"], Product["SynonymText"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; //row++; //FM.DrawCell(row, cFirst, row, cLast, string.Format("НД: {0}", Product["ProductDocument"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; FM.SetRowAutoHeight(row, row); row++; FM.DrawCell(row, cFirst, row, cLast, string.Format("Стандарт ЛИМС: {0}", Product["StandardNR"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; FM.Book.Row(row).Height = 0; row++; /*FM.DrawCell(row, cFirst, row, cLast, string.Format("Наименование на паспорте ЛИМС: {0}", Product["ProductName"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; * row++;*/ /*FM.DrawCell(row, cFirst, row, cLast, string.Format("Код UNC: {0}. Торговое наименование UNC: {1}", Product["UNCProductCode"], Product["TradeName"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; row++; FM.DrawCell(row, cFirst, row, cLast, string.Format("UNC наименование по {0}: {1}", Product["NTD"], Product["NDName"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; row++; FM.DrawCell(row, cFirst, row, cLast, string.Format("Стандарт ЛИМС: {0}. Продукт ЛИМС: {1}", Product["StandardNR"], Product["SynonymText"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; //FM.DrawCell(row, cFirst, row, cLast, string.Format("Продукт ЛИМС: {0}", Product["SynonymText"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10; row++; FM.DrawCell(row, cFirst, row, cLast, string.Format("Нормативный документ ЛИМС: {0}", Product["ProductDocument"]), AlignmentEnum.LeftCenter, true, true).FontSize = 10;*/ //FM.SetRowAutoHeight(row - 6, row); // выводим заголовок для спецификации /*FM.DrawCell(row, 1, "Группа испытаний", AlignmentEnum.CenterCenter, false, true); FM.Book.Column(1).Width = 150; FM.DrawCell(row, 2, "Наименование испытания", AlignmentEnum.CenterCenter, false, true); FM.Book.Column(2).Width = 300;*/ if (cMethod > 0) FM.DrawCell(row, cMethod, "Метод", AlignmentEnum.CenterCenter, false, true); FM.DrawCell(row, cModule, "Наименование показателя", AlignmentEnum.CenterCenter, false, true); if (cUnit > 0) FM.DrawCell(row, cUnit, "Ед. изм.", AlignmentEnum.CenterCenter, false, true); FM.DrawCell(row, cNorm, "Норма", AlignmentEnum.CenterCenter, false, true); FM.DrawCell(row, cUNCCode, "Код UNC", AlignmentEnum.CenterCenter, false, true); FM.Range(row, cFirst, row, cLast).BackColor = Color.LightGray; FM.SetBorder(row, cFirst, row, cLast, LineStyleEnum.Thick); FM.SetRowAutoHeight(row, row); row++; // выводим данные по продукту int startrow = row; foreach (DataRow r in ProductData.Rows) { if (cMethod > 0) FM.DrawCell(row, cMethod, r["TestND"].ToString()); FM.DrawCell(row, cModule, r["UnionText"].ToString()); if (cUnit > 0) FM.DrawCell(row, cUnit, r["Unit"].ToString()); FM.DrawCell(row, cNorm, r["ReqText1"].ToString()); FM.DrawCell(row, cUNCCode, r["UNCModuleCode"].ToString()); row++; } row--; Parts.Add(new AnalyzePart(this, column, startrow, row)); FM.SetBorder(startrow, cFirst, row, cLast, LineStyleEnum.Thin); /*if (ShowMethodCheck.Checked) FM.MergeEqualValues(startrow, cMethod, row, cMethod);*/ FM.SetRowAutoHeight(startrow, row); FM.SetBorder(startdrawrow, cLast, row, cLast, EdgeEnum.Right, LineStyleEnum.Thick); }
private void UpdateCertTankProducts() { //StatusSplash.Create(MainStatusStrip); //StatusSplash.Message("���������� ������� �� ���������"); if (PlantCombo.SelectedItem == null || ControlTypeCombo.SelectedItem == null) return; DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetCertTankProducts", new object[] { (PlantCombo.SelectedItem as DataRowView)["PlantID"], (ControlTypeCombo.SelectedItem as DataRowView)["OsgID"], Date1.Value, Date2.Value, null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); ProductCombo.DisplayMember = "Description"; ProductCombo.DataSource = DataResult; Functions.SetComboDropDownAutoWidth(ProductCombo); //StatusSplash.Close(); }
private void AddDataToChart(QueryResult ChartData, Line line, Line avg, Line lower, Line upper, object AlternameAvgValue) { double Value; DateTime Date; foreach (DataRow row in ChartData.Rows) { if (!DateTime.TryParse(row["Date"].ToString(), out Date)) continue; if (line != null) { if (double.TryParse(row["Value"].ToString(), out Value)) line.Add(Date, Value); else if (line.Count != 0) line.Add(Date, line.YValues[line.Count - 1], Color.Transparent); } if (avg != null && ShowAverage && ChartData.Columns.Contains("Average")) { if (AlternameAvgValue != null && double.TryParse(AlternameAvgValue.ToString(), out Value)) avg.Add(Date, Value); else if (double.TryParse(row["Average"].ToString(), out Value)) avg.Add(Date, Value); } if (lower != null && double.TryParse(row["Min"].ToString(), out Value)) lower.Add(Date, Value); if (upper != null && double.TryParse(row["Max"].ToString(), out Value)) upper.Add(Date, Value); } }
private void UpdateData(ref int row) { int startrow = row; StatusSplash.Message("��������� ������..."); DataCommand = OracleProc.Execute(DataConnection, "DataAccessPKG.GetCertTankData", new object[] { (PlantCombo.SelectedItem as DataRowView)["PlantID"], (ControlTypeCombo.SelectedItem as DataRowView)["OsgID"], (ProductCombo.SelectedItem as DataRowView)["ProductID"],Date1.Value, Date2.Value, null }); DataResult = new QueryResult(DataCommand.Parameters["rc"].Value); foreach (DataRow dr in DataResult.Rows) { dr["TestGroup"] = StartForm.DictionaryReplace(dr["TestGroup"].ToString()); dr["TextModule"] = StartForm.DictionaryReplace(dr["TextModule"].ToString()); } QueryResult UniqueSplit; QueryResult[] SplittedData = DataResult.Split("plantid, productid, certproductdescription", out UniqueSplit); Parts = new ReportPart[SplittedData.Length]; StatusSplash.Message("������������ ������..."); // ����� ���� ������ ������ �� ����� - ������ �� ����������� �������� StatusSplash.ProgressInit(SplittedData.Length); for (int i = 0; i < SplittedData.Length; i++) { Parts[i] = new ReportPart(); Parts[i].Data = SplittedData[i].Transpose( "plantid, productid, qaonr, qaodecisiontime, tank, tanklevel, tankmass, batchno, certnr", "testgroup, textmodule, modulenorm, precisionid", "result, upperlimit, lowerlimit", out Parts[i].Rows, out Parts[i].Columns); Parts[i].Data.Columns.Add(new DataColumn("RowNumber", typeof(int))); Parts[i].DataFields = new Dictionary<int, string>(); // ������� ���������� � ����� - �����, ������� int inforow = row; row += 1;//row += 2; Parts[i].TitleInfoRow = inforow; UpdatePart(Parts[i], ref row); /*FM.DrawCell(inforow, 1, inforow, Parts[i].DynamicColumns.LastColumn, plants.FindPlant(Convert.ToInt32(UniqueSplit[i, "plantid"])).ShortPlantName, AlignmentEnum.LeftCenter, true, true).FontSize = 10;*/ FM.DrawCell(inforow/*+1*/, 1, inforow/*+1*/, Parts[i].DynamicColumns.LastColumn, UniqueSplit[i, "certproductdescription"], AlignmentEnum.LeftCenter, true, true).FontSize = 10; FM.SetRowAutoHeight(inforow, inforow + 1); StatusSplash.ProgressAdd(); } row++; }
// сводный график private void DisplaySingleChart() { Charts = new TChart[1]; Charts[0] = new TChart(); TChart chart = Charts[0]; InitializeChart(chart); chart.Legend.Visible = true; chart.Legend.CheckBoxes = true; chart.Legend.Alignment = LegendAlignments.Bottom; chart.Header.Text = FilledDatas[0][0, "Module"].ToString() + ", " + FilledDatas[0][0, "Norm"].ToString(); chart.Axes.Bottom.Title.Text = "Дата"; Line lower = NewChartLine(chart, 0, 2, Color.Red, "Нижний предел", false); Line upper = NewChartLine(chart, 0, 2, Color.Red, "Верхний предел", false); Line avg = null; object avgvalue = 0; if (IsOneAverage) { avg = NewChartLine(chart, 0, 2, Color.Lime, "Средневзвешенное значение", false); QueryResult avgdata = new QueryResult(); avgdata.Columns.Add("Average"); foreach (QueryResult ChartData in FilledDatas) if (ChartData.Columns.Contains("Average")) avgdata.Rows.Add(ChartData[0, "Average"]); avgvalue = avgdata.Calculate("Average", new AverageCalculation()); // вычисляем } for (int i = 0; i < FilledDatas.Count; i++) { QueryResult ChartData = FilledDatas[i]; Line line = NewChartLine(chart, 0, 2, PlantColors[i%PlantColors.Count], ChartData[0, "PlantName"].ToString(), true); line.Function = new Steema.TeeChart.Functions.Average(false); line.DataSource = ChartData; if (!IsOneAverage) avg = NewChartLine(chart, 0, 2, line.Color, ChartData[0, "PlantName"].ToString()+": Средневзвешенное значение", false); AddDataToChart(ChartData, line, avg, lower, upper, IsOneAverage?avgvalue:null); //avg.Function = new Steema.TeeChart.Functions.Average(false); } }
// ������� ����� �� �������� private void UpdateSummary(ReportPart part, ref int row, params BookColumns[] Book�olumnsArray) { BookColumns columns = BookColumns.Merge(Book�olumnsArray); int MaxRowOffset = 0; bool ContainsSummary = false; bool ContainsMinMaxAvg = false; foreach (BookColumn column in columns) if (column.formulatype != FormulaType.None && column.column1 == column.column2 && !column.isgroup) switch (column.formulatype) { case FormulaType.Summary: DataResult = GetResultForColumn(part, cMass); if (DataResult == null) break; FM.DrawCell(row, cMass.column1 - 1, "�����", AlignmentEnum.RightCenter); FM.DrawCell(row, cMass.column1, DataResult.Calculate(DataResult.Columns[0].ColumnName, new SummaryCalculation()), AlignmentEnum.RightCenter); MaxRowOffset = Math.Max(MaxRowOffset, 1); ContainsSummary = true; break; case FormulaType.MinMaxAvg: DataResult = GetResultForColumn(part, cMass, column); if (DataResult == null) break; part.RowMin = row; part.RowMax = row + 1; part.RowAvg = row + 2; FM.DrawCell(part.RowMin, StaticColumns.LastColumn, "�������", AlignmentEnum.RightCenter); FM.DrawCell(part.RowMax, StaticColumns.LastColumn, "��������", AlignmentEnum.RightCenter); FM.DrawCell(part.RowAvg, StaticColumns.LastColumn, "��.�����.", AlignmentEnum.RightCenter); FM.DrawCell(part.RowMin, column.column1, DataResult.Calculate(DataResult.Columns[1].ColumnName, new MininumCalculation()), AlignmentEnum.RightCenter); FM.DrawCell(part.RowMax, column.column1, DataResult.Calculate(DataResult.Columns[1].ColumnName, new MaximumCalculation()), AlignmentEnum.RightCenter); object avg = DataResult.Calculate(new string[] { DataResult.Columns[0].ColumnName, DataResult.Columns[1].ColumnName }, new AverageWeightCalculation()); if (Functions.IsNull(avg)) avg = DataResult.Calculate(new string[] { DataResult.Columns[1].ColumnName }, new AverageCalculation()); FM.DrawCell(part.RowAvg, column.column1, avg, AlignmentEnum.RightCenter); MaxRowOffset = Math.Max(MaxRowOffset, 3); ContainsMinMaxAvg = true; break; default: throw new Exception("Unknown formula type for column "+column.header); } if (ContainsSummary) FM.SetBorder(row, cMass.column1 - 1, row, cMass.column1, LineStyleEnum.Thin).BackColor = Color.LightGray; if (ContainsMinMaxAvg) FM.SetBorder(row, StaticColumns.LastColumn, row + 2, columns.LastColumn, LineStyleEnum.Thin).BackColor = Color.LightGray; part.SummaryRow1 = row; part.SummaryRow2 = row + MaxRowOffset - 1; row = row + MaxRowOffset; }
private QueryResult FormatPassportData(QueryResult source) { QueryResult result = new QueryResult(); result.Columns.Add(new DataColumn("Item", typeof(string))); result.Columns.Add(new DataColumn("Text", typeof(string))); result.Columns.Add(new DataColumn("Method", typeof(string))); result.Columns.Add(new DataColumn("Norm", typeof(string))); result.Columns.Add(new DataColumn("Result", typeof(string))); string Text = "", Norm = "", Result = "", Method = ""; int Item = 1; for (int i = 0; i < source.Rows.Count; i++) { if (source[i, "CertGroup"].ToString() == "") { Text = source[i, "CertText"].ToString(); Norm = source[i, "CertNorm"].ToString(); Result = source[i, "Result"].ToString(); Method = source[i, "CertMethod"].ToString(); } else { int StartIndex = i; Text = source[i, "CertGroup"].ToString() + '\n'; Norm = "\n"; Result = "\n"; Method = "\n" + source[StartIndex, "CertMethod"].ToString(); bool IsOneMethod = true; string Group = source[i, "CertGroup"].ToString(); while (i < source.Rows.Count && Group == source[i, "CertGroup"].ToString()) { Text += '\t' + source[i, "CertText"].ToString() + '\n'; Norm += source[i, "CertNorm"].ToString() + '\n'; Result += source[i, "Result"].ToString() + '\n'; IsOneMethod &= (source[StartIndex, "CertMethod"].ToString() == source[i, "CertMethod"].ToString()); if (!Method.TrimEnd('\n').EndsWith(source[i, "CertMethod"].ToString())) Method += source[i, "CertMethod"].ToString() + '\n'; else Method += '\n'; i++; }; i--; bool IsOneRow = StartIndex == i; if (IsOneRow) { Norm = Norm.TrimStart('\n'); Result = Result.TrimStart('\n'); } Text = Text.TrimEnd('\n', '\t'); Norm = Norm.TrimEnd('\n'); Result = Result.TrimEnd('\n'); if (IsOneMethod) Method = source[StartIndex, "CertMethod"].ToString(); else Method = Method.TrimEnd('\n'); } result.Rows.Add(new object[] { Item, Text, Method, Norm, Result }); Item++; } return result; }