private void frmAdd_Load(object sender, EventArgs e) { Task <DataTable> task = Config.hCntMain.getPostVsDeps(); task.Wait(); dtPostVsDeps = task.Result; //dgvData.DataSource = dtPostVsDeps; task = Config.hCntMain.getDocuments_vs_DepartmentsPosts(id_Document); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { foreach (DataRow row in task.Result.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtPostVsDeps.AsEnumerable().Where(r => r.Field <int>("id") == (int)row["id_DepartmentsPosts"]); if (rowCollect.Count() > 0) { //rowCollect.First()["isSelect"] = true; rowCollect.First()["id_DocVsDepPosts"] = (int)row["id"]; rowCollect.First()["isBrowse"] = row["isBrowse"]; rowCollect.First()["id_Status"] = row["id_Status"]; rowCollect.First()["nameStatus"] = row["nameStatus"]; } } dtPostVsDeps.DefaultView.Sort = "isSelect desc, nameDeps asc, namePost asc"; dtPostVsDeps.DefaultView.RowFilter = "id_DocVsDepPosts > 0 and id_Status = 3"; dtPostVsDeps = dtPostVsDeps.DefaultView.ToTable().Copy(); dgvData.DataSource = dtPostVsDeps; } }
private void getDepartmentsAccessView() { int id_deps = int.Parse(cmbDeps.SelectedValue.ToString()); dtDepartmentsAccessView_view = dtDepartmentsAccessView.Copy(); Task <DataTable> task = Config.hCntMain.getDepartmentsAccessView(id_deps); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { foreach (DataRow row in task.Result.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtDepartmentsAccessView_view.AsEnumerable().Where(r => r.Field <Int16>("id") == (int)row["id_DepartmentsView"]); if (rowCollect.Count() > 0) { rowCollect.First()["id_DepartmentsAccessView"] = row["id"]; rowCollect.First()["isSelect"] = row["isActive"]; } } dtDepartmentsAccessView_view.AcceptChanges(); dgvData.DataSource = dtDepartmentsAccessView_view; } else { dgvData.DataSource = dtDepartmentsAccessView_view; } }
private async void BtMergeOrder_Click(object sender, EventArgs e) { if (dtMerge.AsEnumerable().Where(r => r.Field <bool>("isSelect")).Count() == 0) { MessageBox.Show("Необходимо выбрать главный заказ!", "Выбор заказ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Logging.StartFirstLevel(1662); EnumerableRowCollection <DataRow> rowCollect = dtMerge.AsEnumerable().Where(r => r.Field <bool>("isSelect")); int id_main = (int)rowCollect.First()["id"]; string OrderNumber = (string)rowCollect.First()["OrderNumber"]; Logging.Comment($"Магазин:{((int)rowCollect.First()["id_shop"] == 1 ? "К-21" : "Х - 14")}"); Logging.Comment($"Главный заказ ID:{id_main}; Номер:{OrderNumber}"); rowCollect = dtMerge.AsEnumerable().Where(r => !r.Field <bool>("isSelect")); foreach (DataRow row in rowCollect) { int id = (int)row["id"]; Config.connect.setMergeOrder(id_main, OrderNumber, id).Wait(); Logging.Comment($"Выбранный заказ ID:{id}; Номер:{row["OrderNumber"]}"); } Logging.StopFirstLevel(); this.DialogResult = DialogResult.OK; }
private void loadData(int id) { Task <DataTable> task = Config.hCntMain.getDocuments(id); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { cmbTypeDoc.SelectedValue = (int)task.Result.Rows[0]["id_TypeDoc"]; tbNameDoc.Text = (string)task.Result.Rows[0]["cName"]; tbFileName.Text = Path.GetFileNameWithoutExtension((string)task.Result.Rows[0]["FileName"]); fileName = (string)task.Result.Rows[0]["FileName"]; task = Config.hCntMain.getDocuments_vs_DepartmentsPosts(id); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { foreach (DataRow row in task.Result.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtPostVsDeps.AsEnumerable().Where(r => r.Field <int>("id") == (int)row["id_DepartmentsPosts"]); if (rowCollect.Count() > 0) { rowCollect.First()["isSelect"] = true; if (this.id != 0) { rowCollect.First()["id_DocVsDepPosts"] = (int)row["id"]; } } } dtPostVsDeps.DefaultView.Sort = "isSelect desc, nameDeps asc, namePost asc"; dtPostVsDeps = dtPostVsDeps.DefaultView.ToTable().Copy(); dgvData.DataSource = dtPostVsDeps; } } }
private static bool IsEnumerableCollectionGroupFounded(EnumerableRowCollection <DataRow> collection, string type, ref string topLevel, ref string siteService) { int rowsBySubgroupCount = collection.Count(); if (rowsBySubgroupCount == 1) { DataRow dataRowBySubgroup = collection.First(); string typeByGroup = dataRowBySubgroup[3].ToString(); if (string.IsNullOrEmpty(typeByGroup) || typeByGroup.ToLower().Equals(type)) { SetupTopLevelAndSiteServiceValue(dataRowBySubgroup, ref topLevel, ref siteService); return(true); } } else if (rowsBySubgroupCount == 2) { DataRow dataRowBySubgroupFirst = collection.First(); DataRow dataRowBySubgroupLast = collection.Last(); string typeBySubgroupFirst = dataRowBySubgroupFirst[3].ToString(); string typeBySubgroupLast = dataRowBySubgroupLast[3].ToString(); if (typeBySubgroupFirst.ToLower().Equals(type)) { SetupTopLevelAndSiteServiceValue(dataRowBySubgroupFirst, ref topLevel, ref siteService); return(true); } else if (typeBySubgroupLast.ToLower().Equals(type)) { SetupTopLevelAndSiteServiceValue(dataRowBySubgroupLast, ref topLevel, ref siteService); return(true); } else if (string.IsNullOrEmpty(typeBySubgroupFirst)) { SetupTopLevelAndSiteServiceValue(dataRowBySubgroupFirst, ref topLevel, ref siteService); return(true); } else if (string.IsNullOrEmpty(typeBySubgroupLast)) { SetupTopLevelAndSiteServiceValue(dataRowBySubgroupLast, ref topLevel, ref siteService); return(true); } } else if (rowsBySubgroupCount > 2) { Logging.ToLog("Результат поиска группировки по подгруппе более 3, пропуск"); } return(false); }
private void newTableDepsForTree(DataTable dtDeps, DataTable dtPostvsDeps, DataTable dtDepsLinkToDep) { DataTable dtTmp = new DataTable(); var groupDepsVsPost = dtPostvsDeps.AsEnumerable().GroupBy(r => new { id_Departments = r.Field <int>("id_Departments") }) .Select(s => new { s.Key.id_Departments }); foreach (var gDep in groupDepsVsPost) { EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == gDep.id_Departments); if (rowCollect.Count() > 0) { rowCollect.First()["isTop"] = true; } } if (tbNameDeps.Text.Trim().Length != 0 || tbNamePosts.Text.Trim().Length != 0 || tbNameDocuments.Text.Trim().Length != 0) { filterTable(dtDeps, dtPostvsDeps, dtDepsLinkToDep); } else { foreach (DataRow row in dtDepsLinkToDep.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == (int)row["id_DepartmentsView"]); if (rowCollect.Count() > 0) { rowCollect.First()["isUsed"] = true; } } } foreach (DataRow row in dtDeps.Copy().AsEnumerable().Where(r => r.Field <int>("id_Parent") != 0 //&& r.Field<bool>("isTop") && r.Field <bool>("isUsed"))) { int id_Parent = (int)row["id_Parent"]; EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == id_Parent); rowCollect.First()["isTop"] = true; rowCollect.First()["isUsed"] = true; if ((int)rowCollect.First()["id_Parent"] != 0) { LinkToParent((int)rowCollect.First()["id_Parent"], dtTmp, dtDeps); } } }
private void LinkToParent(int id_Parent, DataTable dtTmp, DataTable dtDeps) { EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == id_Parent); rowCollect.First()["isTop"] = true; rowCollect.First()["isUsed"] = true; if ((int)rowCollect.First()["id_Parent"] != 0) { LinkToParent((int)rowCollect.First()["id_Parent"], dtTmp, dtDeps); } }
private bool sendMail(string user, string userTitle, string pass, string toEmail, byte[] file, string fileName, EnumerableRowCollection <DataRow> rowCollect) { //string user = "******"; //string pass = "******"; string host = rowCollect.First()["host"].ToString(); int port = (int)rowCollect.First()["port"]; // отправитель - устанавливаем адрес и отображаемое в письме имя MailAddress from = new MailAddress(user, userTitle); // кому отправляем MailAddress to = new MailAddress(toEmail); // создаем объект сообщения MailMessage m = new MailMessage(from, to); // тема письма m.Subject = fileName; // текст письма m.Body = ""; // письмо представляет код html m.IsBodyHtml = true; Attachment data = new Attachment( new MemoryStream(file), fileName); // your path may look like Server.MapPath("~/file.ABC") //Attachment data = new Attachment( // @"D:\Disk E\Img\EjPg0vSUcAASql3.jpg", // MediaTypeNames.Application.Octet); //// your path may look like Server.MapPath("~/file.ABC") m.Attachments.Add(data); // адрес smtp-сервера и порт, с которого будем отправлять письмо SmtpClient smtp = new SmtpClient(host, port); // логин и пароль smtp.Credentials = new NetworkCredential(user, pass); smtp.EnableSsl = true; try { smtp.Send(m); } catch (Exception ex) { return(false); } return(true); }
private void btOpen_Click(object sender, EventArgs e) { EnumerableRowCollection <DataRow> rowCollect = dtData.AsEnumerable() .Where(r => r.Field <object>("DateOpen") == null); frmSelectDate frmSelectDate = new frmSelectDate() { Text = "Открыть секцию", dateMin = (DateTime)rowCollect.First()["DateSeal"] }; if (DialogResult.OK == frmSelectDate.ShowDialog()) { _proc.setSealSections(id_agreements, frmSelectDate.date, 2); Logging.StartFirstLevel(765); Logging.Comment("Смена статуса секции на «Открыта»"); Logging.Comment($"ID договора:{id_agreements}"); Logging.Comment($"Место:{placeName}"); Logging.Comment($"Дата открытия:{frmSelectDate.date.ToShortDateString()}"); Logging.StopFirstLevel(); getData(); } }
private void init_category() { int id_deps = cmbDeps.SelectedValue == null ? -1 : (int)cmbDeps.SelectedValue; Task <DataTable> task = Config.hCntMain.getCategory(id_deps, true); task.Wait(); DataTable dtCategory = task.Result; if (id != 0) { EnumerableRowCollection <DataRow> rowCollect = dtCategory.AsEnumerable().Where(r => r.Field <object>("id") != null && r.Field <object>("id") != DBNull.Value && r.Field <int>("id") == id); if (rowCollect.Count() > 0) { rowCollect.First().Delete(); dtCategory.AcceptChanges(); } } if (chckParentCategory.Checked) { Task <DataTable> task2 = Config.hCntMain.getDicCategoryParent(); task2.Wait(); DataTable dtCategoryParent = task2.Result; dtCategoryParent.DefaultView.RowFilter = " id_Departments <> " + cmbDeps.SelectedValue.ToString(); dtCategory.Merge(dtCategoryParent.DefaultView.ToTable()); } //dtCategory.DefaultView.Sort = " id_Departments asc, cName asc"; dtCategory.DefaultView.Sort = "cName asc"; cmbParentCategory.DataSource = dtCategory; cmbParentCategory.DisplayMember = "cName"; cmbParentCategory.ValueMember = "id"; }
private void BtAdd_Click(object sender, EventArgs e) { if (dgvMain.CurrentRow != null && dgvMain.CurrentRow.Index != -1) { DataRowView row = dtCat.DefaultView[dgvMain.CurrentRow.Index]; if (dtUseCategory.AsEnumerable().Where(r => r.Field <int>("id_Category") == (int)row["id"]).Count() == 0) { object id = DBNull.Value; if (dtUseCategoryOld != null) { EnumerableRowCollection <DataRow> rowCollectID = dtUseCategoryOld.AsEnumerable().Where(r => r.Field <int>("id_Category") == (int)row["id"] && r.Field <object>("id") != null); if (rowCollectID.Count() > 0) { id = (int)rowCollectID.First()["id"]; if (listDel.Contains((int)id)) { listDel.Remove((int)id); } } } DataRow newRow = dtUseCategory.NewRow(); newRow["id"] = id; newRow["id_Category"] = row["id"]; newRow["cName"] = row["cName"]; dtUseCategory.Rows.Add(newRow); btRemove.Enabled = btRemoveAll.Enabled = dtUseCategory.DefaultView.Count != 0; } DgvMain_SelectionChanged(null, null); } }
private bool checkLogin(string username, string password) { EnumerableRowCollection <DataRow> results = from row in mailBox.Tables["users"].AsEnumerable() where row.Field <string>("username") == username select row; if (!results.Any()) { return(false); } DataRow dataRow = results.First <DataRow>(); string storedPassword = dataRow.Field <string>("password"); SHA512 shaM = new SHA512Managed(); byte[] saltedPlainText = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)); byte[] hashedBytes = shaM.ComputeHash(saltedPlainText); string hash = BitConverter.ToString(hashedBytes).Replace("-", ""); if (storedPassword.ToLower() == hash.ToLower()) { return(true); } return(false); }
public void getMailBox() { // List all objects ListObjectsRequest listRequest = new ListObjectsRequest { BucketName = bucketName, Prefix = string.Format("{0}/{1}/{2}/", bucketPrefix, sessionDomain, sessionUser) }; Task <ListObjectsResponse> listResponse = awsClient.ListObjectsAsync(listRequest); ListObjectsResponse response = listResponse.Result; int counter = 1; Int64 mailboxSize = 0; foreach (S3Object obj in response.S3Objects) { if (obj.Size > 0) // if zero length, it's probably a folder { mailBox.Tables["messages"].Rows.Add(counter, obj.Key, obj.Size, false); mailboxSize += obj.Size; counter++; } } EnumerableRowCollection <DataRow> results = from users in mailBox.Tables["users"].AsEnumerable() where users.Field <string>("username") == sessionUser select users; if (results.Any()) { DataRow dataRow = results.First <DataRow>(); dataRow["size"] = mailboxSize; } }
public void Dele(string data) { if (!isAuthorized) { SendBuffer("-ERR Not Authorized."); return; } Int64 msgNum = -1; Int64.TryParse(data, out msgNum); if (msgNum == -1) { SendBuffer("-ERR no such message"); return; } EnumerableRowCollection <DataRow> results = from messages in mailBox.Tables["messages"].AsEnumerable() where messages.Field <Int64>("index") == msgNum select messages; if (!results.Any()) { SendBuffer("-ERR no such message"); return; } DataRow dataRow = results.First <DataRow>(); dataRow["deleted"] = true; }
private static int GetPriority(DataRow dataRow, DataTable priorities) { int priority = 99; string kodoper = dataRow["KODOPER"].ToString(); try { if (string.IsNullOrEmpty(kodoper)) { return(priority); } EnumerableRowCollection <DataRow> rows = from row in priorities.AsEnumerable() where row.Field <string>(7) != null && row.Field <string>(7).Equals(kodoper) select row; if (rows.Count() == 1) { DataRow row = rows.First(); if (int.TryParse(row[6].ToString(), out int parsedPriority)) { priority = parsedPriority; } } } catch (Exception e) { Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace); } return(priority); }
public void Export(EnumerableRowCollection <DataLogModel.ImpactsRow> impacts) { Workbook workbook = new Workbook(); workbook.Properties.Title = "LaJust Sports Export"; workbook.Properties.Created = DateTime.Now; Worksheet impactSheet = workbook.Worksheets.Add("Impacts"); WorksheetRow row = impactSheet.Table.Rows.Add(); row.Cells.Add(new WorksheetCell("Sequence", DataType.String)); row.Cells.Add(new WorksheetCell("Time", DataType.String)); row.Cells.Add(new WorksheetCell("Device ID", DataType.String)); row.Cells.Add(new WorksheetCell("Game Number", DataType.String)); row.Cells.Add(new WorksheetCell("Round Number", DataType.String)); row.Cells.Add(new WorksheetCell("Seconds", DataType.String)); row.Cells.Add(new WorksheetCell("Competitor", DataType.String)); row.Cells.Add(new WorksheetCell("Data Source", DataType.String)); row.Cells.Add(new WorksheetCell("Required Impact", DataType.String)); row.Cells.Add(new WorksheetCell("Actual Impact", DataType.String)); row.Cells.Add(new WorksheetCell("Panel", DataType.String)); foreach (var impactRow in impacts) { row = impactSheet.Table.Rows.Add(); row.Cells.Add(new WorksheetCell(impactRow.ID.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.Timestamp.ToString("G"), DataType.String)); row.Cells.Add(new WorksheetCell(impactRow.SensorId.ToString(), DataType.String)); row.Cells.Add(new WorksheetCell(impactRow.GameNumber.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.RoundNumber.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.ElapsedTime.TotalSeconds.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.Name.ToString(), DataType.String)); row.Cells.Add(new WorksheetCell(impactRow.DataSource.ToString(), DataType.String)); row.Cells.Add(new WorksheetCell(impactRow.RequiredLevel.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.ImpactLevel.ToString(), DataType.Number)); row.Cells.Add(new WorksheetCell(impactRow.SensorPanel.ToString(), DataType.String)); } string filename = string.Format("{0} {1} G{2:D3}-{3}R.xls", impacts.First().Timestamp.ToString("yyyy-MM-dd"), impacts.First().Name, impacts.First().GameNumber, impacts.First().RoundNumber); workbook.Save(Path.Combine(GetDataDirectory(), filename)); }
private void init_deps() { Task <DataTable> task = Config.hCntMain.getDeps(); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { dtDeps = task.Result.Copy(); task = null; DataColumn col = new DataColumn("isSelect", typeof(bool)); col.DefaultValue = false; dtDeps.Columns.Add(col); col = new DataColumn("idLinkPost", typeof(int)); col.DefaultValue = 0; dtDeps.Columns.Add(col); dtDeps.AcceptChanges(); task = Config.hCntMain.getPostLinkDep(id); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { foreach (DataRow row in task.Result.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == (int)row["id_Departments"]); if (rowCollect.Count() > 0) { rowCollect.First()["isSelect"] = true; rowCollect.First()["idLinkPost"] = row["id"]; } } dtDeps.AcceptChanges(); dtDeps.DefaultView.Sort = "isSelect desc,name asc"; dtDeps = dtDeps.DefaultView.ToTable().Copy(); } dgvData.DataSource = dtDeps; } }
public void Retr(string data) { if (!isAuthorized) { SendBuffer("-ERR Not Authorized."); return; } Int64 msgNum = -1; Int64.TryParse(data, out msgNum); if (msgNum == -1) { SendBuffer("-ERR no such message"); return; } EnumerableRowCollection <DataRow> results = from messages in mailBox.Tables["messages"].AsEnumerable() where messages.Field <Int64>("index") == msgNum select messages; if (!results.Any()) { SendBuffer("-ERR no such message"); return; } DataRow dataRow = results.First <DataRow>(); SendBuffer("+OK"); string response = ""; string filename = dataRow.Field <string>("filename"); string[] lines = readS3File(bucketName, filename).Split("\r\n"); string prev = ""; foreach (string line in lines) { if (line == "." && prev == "\r\n") { continue; //byte stuff per RFC } response += line + "\r\n"; prev = line; } response += "\r\n."; SendBuffer(response); }
private void frmAdd_Load(object sender, EventArgs e) { init_combobox(); if (row != null) { id = (int)row["id"]; tbID.Text = id.ToString(); tbID.Enabled = false; tbName.Text = (string)row["cName"]; oldName = tbName.Text.Trim(); cmbDeps.SelectedValue = row["id_otdel"]; cmbDeps.Enabled = false; cmbNds.SelectedValue = row["id_nds"]; chbIsCredit.Checked = (bool)row["isCredit"]; chbWithSubGroups.Checked = (int)row["isWithSubGroups"] == 1; getAdresProizvod((int)cmbDeps.SelectedValue); if (dtGrp2 != null) { Task <DataTable> task = Config.hCntMain.getGrp1VsGrp2(id); task.Wait(); dtGrp_old = task.Result; foreach (DataRow row in dtGrp_old.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtGrp2.AsEnumerable().Where(r => r.Field <int>("id") == (int)row["id"]); if (rowCollect.Count() > 0) { rowCollect.First()["isSelect"] = true; } } string _filter = dtGrp2.DefaultView.RowFilter; dtGrp2.DefaultView.RowFilter = ""; dtGrp2.DefaultView.Sort = "isSelect desc, cName asc"; dtGrp2 = dtGrp2.DefaultView.ToTable().Copy(); dtGrp2.DefaultView.RowFilter = _filter; dgvAdress.DataSource = dtGrp2; } } else { getAdresProizvod(0); } isEditData = false; }
public void setSelectStatus(int id = 0) { cSelect.Visible = true; btSelect.Visible = true; //btAddDoc.Visible = false; //btPrint.Visible = btViewComponents.Visible = false; btAdded.Visible = btEdited.Visible = btDelete.Visible = !isStatusFirst; if (isStatusFirst) { id_actWriteOff = id; cbStatus.SelectedValue = 1; cbStatus.Enabled = false; toolTip1.SetToolTip(btSelect, "Подтвердить акт списания оборудования"); if (id != 0) { DataTable dtDataBody = readSQL.getContentWriteOff(id); if (dtDataBody != null && dtDataBody.Rows.Count > 0) { foreach (DataRow row in dtDataBody.Rows) { EnumerableRowCollection <DataRow> rowCollect = dtData.AsEnumerable() .Where(r => r.Field <int>("id") == (int)row["id_Hardware"]); if (rowCollect.Count() > 0) { rowCollect.First()["isSelect"] = true; } } } dgvData.DataSource = null; dtData.DefaultView.RowFilter = ""; dtData.DefaultView.Sort = "isSelect desc"; dtData = dtData.DefaultView.ToTable().Copy(); filter(); dgvData.DataSource = dtData; } else { filter(); } } else { toolTip1.SetToolTip(btSelect, "Подтвердить акт приема-передачи оборудования"); } }
/// <summary> /// 产品料号值变化时触发。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbPartNumber_SelectedValueChanged(object sender, EventArgs e) { string partNumber = this.cmbPartNumber.Text; EnumerableRowCollection <DataRow> drs = this._dtPartNumber.AsEnumerable() .Where(dr => Convert.ToString(dr[POR_PART_FIELDS.FIELD_PART_ID]) == partNumber); if (drs.Count() > 0) { this.tePartDescription.Text = Convert.ToString(drs.First()[POR_PART_FIELDS.FIELD_PART_DESC]); this.tePartDescription.Properties.ReadOnly = true; } else { this.tePartDescription.Text = string.Empty; this.tePartDescription.Properties.ReadOnly = false; } }
public double GetRate(int code, DateTime date) { try { CBRDaily.DailyInfoSoapClient client = new CBRDaily.DailyInfoSoapClient(); System.Data.DataSet ds = client.GetCursOnDate(date); EnumerableRowCollection <DataRow> dsEl = from num in ds.Tables[0].AsEnumerable() where Int32.Parse(num["vCode"].ToString()) == 840 select num; var rv = dsEl.First()["VCurs"]; return(Convert.ToDouble(rv)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(0.0); } }
private void frmLoaderFile1C_Load(object sender, EventArgs e) { DataTable conf = Config.hCntMain.EditGetConf(ConnectionSettings.GetIdProgram(), "", ""); EnumerableRowCollection <DataRow> rowCollect = conf.AsEnumerable().Where(r => r.Field <string>("id_value").Equals("psss")); if (rowCollect.Count() > 0) { net = new NetworkShare(true, false); net.ConnectToShare(); pathSign = rowCollect.First()["value"].ToString() + "\\sign"; if (!Directory.Exists(pathSign)) { MessageBox.Show(Config.centralText("Программа не обнаружила\nкаталога с подписями\nарендодателей.\nЗагрузка счетов 1С невозможна.\n"), "Загрузка счетов", MessageBoxButtons.OK, MessageBoxIcon.Warning); Close(); return; } } }
/// <summary> /// 工单BOM单元值改变时触发事件。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gvBOM_CellValueChanged(object sender, CellValueChangedEventArgs e) { //物料编码。 if (e.Column == this.gclMaterialCode) { string materialCode = Convert.ToString(e.Value); EnumerableRowCollection <DataRow> drs = this._dtMaterialCode .AsEnumerable() .Where(dr => Convert.ToString(dr["MATERIAL_CODE"]) == materialCode); if (drs.Count() > 0) { DataRow dr = drs.First(); this._dtWorkOrderBom.Rows[e.RowHandle][POR_WORK_ORDER_BOM_FIELDS.FIELD_DESCRIPTION] = dr["MATERIAL_NAME"]; this._dtWorkOrderBom.Rows[e.RowHandle][POR_WORK_ORDER_BOM_FIELDS.FIELD_MATERIAL_UNIT] = dr["UNIT"]; this.gvBOM.FocusedColumn = this.gcolReqQty; } } }
private static void GetTopLevelAndSiteService(DataRow dataRow, DataTable grouping, out string topLevel, out string siteService) { topLevel = string.Empty; siteService = string.Empty; try { string kodoper = dataRow["KODOPER"].ToString(); string group = dataRow["GROUP_NAME"].ToString().ToLower(); string subgroup = dataRow["SUBGROUP"].ToString().ToLower(); EnumerableRowCollection <DataRow> rowsByKodoper = from row in grouping.AsEnumerable() where (row.Field <string>(0) != null && row.Field <string>(0).Equals(kodoper)) select row; if (rowsByKodoper.Count() >= 1) { DataRow dataRowGrouping = rowsByKodoper.First(); SetupTopLevelAndSiteServiceValue(dataRowGrouping, ref topLevel, ref siteService); return; } string type = dataRow["TYPE_NAME"].ToString().ToLower(); EnumerableRowCollection <DataRow> rowsByGroup = from row in grouping.AsEnumerable() where (row.Field <string>(1) != null && row.Field <string>(1).ToLower().Equals(@group)) select row; if (IsEnumerableCollectionGroupFounded(rowsByGroup, type, ref topLevel, ref siteService)) { return; } EnumerableRowCollection <DataRow> rowsBySubgroup = from row in grouping.AsEnumerable() where (row.Field <string>(2) != null && row.Field <string>(2).ToLower().Equals(subgroup)) select row; IsEnumerableCollectionGroupFounded(rowsBySubgroup, type, ref topLevel, ref siteService); } catch (Exception e) { Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace); } }
private void getData() { dtData = Config.hCntMain.getMemorandums(dtpDate.Value.Date, dtpEnd.Value.Date, id_ListServiceRecords, true); if (dtData != null && dtData.Rows.Count > 0) { foreach (int key in dicListMemorandum.Keys) { EnumerableRowCollection <DataRow> rowCollect = dtData.AsEnumerable().Where(r => r.Field <int>("id") == key); if (rowCollect.Count() > 0) { rowCollect.First()["isSelect"] = true; } } } setFilter(); dgvData.DataSource = dtData; }
private void init_depsCombobox() { DataTable dtDeps = null; Task <DataTable> task = Config.hCntMain.getDeps(true); task.Wait(); if (task.Result != null && task.Result.Rows.Count > 0) { dtDeps = task.Result.Copy(); task = null; } if (UserSettings.User.StatusCode.ToLower().Equals("ркв")) { if (dtDepsLinkToDep == null) { EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == 0); dtDeps = rowCollect.CopyToDataTable(); } else { DataTable dtTmp = dtDeps.Clone(); EnumerableRowCollection <DataRow> rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == 0); dtTmp.Merge(rowCollect.CopyToDataTable()); foreach (DataRow row in dtDepsLinkToDep.Rows) { rowCollect = dtDeps.AsEnumerable().Where(r => r.Field <Int16>("id") == (int)row["id_DepartmentsView"]); if (rowCollect.Count() > 0) { dtTmp.ImportRow(rowCollect.First()); } } dtTmp.DefaultView.Sort = "isMain asc, name asc"; dtDeps = dtTmp.DefaultView.ToTable().Copy(); } } cmbDeps.DataSource = dtDeps; cmbDeps.DisplayMember = "name"; cmbDeps.ValueMember = "id"; }
private void CmbDepsCategory_SelectionChangeCommitted(object sender, EventArgs e) { int id_otdel = (int)cmbDepsCategory.SelectedValue; DataTable dtCatergory = Config.hCntMain.getCategory(id_otdel, true).Result; //категории слева, с пустой строчкой и "без категории" /* DataTable dtCategoryTovar = dtCatergory.Copy(); * DataColumn dc = new DataColumn("isHead", typeof(int)); * dc.DefaultValue = 0; * dtCategoryTovar.Columns.Add(dc); * dtCategoryTovar.AsEnumerable().Where(r => r.Field<int?>("id") == null).First()["isHead"] = 1; * DataRow row = dtCategoryTovar.NewRow(); * row["id"] = -1; * row["cName"] = "Без категории"; * row["id_Departments"] = 0; * row["id_ParentCategory"] = DBNull.Value; * row["isHead"] = 1; * dtCategoryTovar.Rows.Add(row); * * * dtCategoryTovar.DefaultView.Sort = "isHead desc, cName asc"; * cmbCategoryTovar.DataSource = dtCategoryTovar; * cmbCategoryTovar.DisplayMember = "cName"; * cmbCategoryTovar.ValueMember = "id";*/ EnumerableRowCollection <DataRow> rowCollection = dtCatergory.AsEnumerable().Where(r => r.Field <object>("id") == null); while (rowCollection.Count() > 0) { rowCollection.First().Delete(); } dtCatergory.DefaultView.Sort = "cName asc"; cmbCategory.DataSource = dtCatergory; cmbCategory.DisplayMember = "cName"; cmbCategory.ValueMember = "id"; CmbCategory_SelectionChangeCommitted(null, null); }
private bool checkLogin(string username, string password) { if (mailBox.Tables["users"].Rows.Count == 0) { string[] passwordFile = readS3File(bucketName, string.Format("{0}/{1}/{2}", bucketPrefix, sessionDomain, "passwd.txt")).Split("\r\n"); foreach (var line in passwordFile) { string[] parts = line.Trim().Split(":"); mailBox.Tables["users"].Rows.Add(parts[0], parts[1], 0); } } EnumerableRowCollection <DataRow> results = from row in mailBox.Tables["users"].AsEnumerable() where row.Field <string>("username") == username select row; if (!results.Any()) { return(false); } DataRow dataRow = results.First <DataRow>(); string storedPassword = dataRow.Field <string>("password"); SHA512 shaM = new SHA512Managed(); byte[] saltedPlainText = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)); byte[] hashedBytes = shaM.ComputeHash(saltedPlainText); string hash = BitConverter.ToString(hashedBytes).Replace("-", ""); if (storedPassword.ToLower() == hash.ToLower()) { return(true); } return(false); }
private void addNoteDeps(int id_deps, TreeNode parentNote) { TreeNode node = new TreeNode(); EnumerableRowCollection <DataRow> rowCollect = dtDepsToTree.AsEnumerable().Where(r => r.Field <Int16>("id") == id_deps && r.Field <bool>("isUsed")); if (rowCollect.Count() > 0) { node.Text = (string)rowCollect.First()["name"]; node.ImageIndex = 0; node.SelectedImageIndex = 1; node.Tag = new Deps(); ((Deps)node.Tag).setIsPost(false); ((Deps)node.Tag).setIdDeps(id_deps); ((Deps)node.Tag).setIdPost(0); } addNotePost(id_deps, node); rowCollect = dtDepsToTree.AsEnumerable().Where(r => r.Field <int>("id_Parent") == id_deps && r.Field <bool>("isUsed")).OrderByDescending(r => r.Field <bool>("isTop")); foreach (DataRow row in rowCollect) { addNoteDeps((Int16)row["id"], node); } if (parentNote == null) { trvDeps.Nodes.Add(node); } else { parentNote.Nodes.Add(node); } }