private void AddRow([NotNull] LogEventItem logEventItem) { Assert.ArgumentNotNull(logEventItem, nameof(logEventItem)); if (_dataGridView.RowCount > _maxDisplayedLogMessages) { DataGridViewRow firstRow = _dataGridView.Rows[0]; firstRow.Tag = null; _dataGridView.Rows.Remove(firstRow); firstRow.Dispose(); } int rowIndex = _dataGridView.Rows.Add( logEventItem.LogLevelImage, logEventItem.LogNummer, logEventItem.LogDateTime, logEventItem.LogMessage); DataGridViewRow row = _dataGridView.Rows[rowIndex]; row.Tag = logEventItem; DataGridViewCell newMessageCell = row.Cells[_columnLogMessage.Index]; // set as current cell --> scrolls _dataGridView.CurrentCell = newMessageCell; _dataGridView.CurrentCell.Selected = false; }
protected override void Dispose(bool disposing) { try { if (disposing) { if (components != null) { components.Dispose(); } foreach (DataGridView grid in gridList) { ((DataTable)grid.DataSource).Dispose(); grid.Dispose(); } lastDoubleClickRow?.Dispose(); } } finally { base.Dispose(disposing); } }
public void EditItem(string formid) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; modQuotationForm mod = _dal.GetItem(formid, out Util.emsg); if (mod != null) { txtFormId.Text = formid; dtpFormDate.Value = mod.FormDate; txtNo.Text = mod.No; txtCurrency.Text = mod.Currency; txtCustName.Tag = mod.CustId; txtCustName.Text = mod.CustName; txtRemark.Text = mod.Remark; txtContactPerson.Text = mod.ContactPerson; txtFormId.ReadOnly = true; txtCustName.ReadOnly = true; DBGrid.Rows.Clear(); LoadDBGrid(); BindingCollection <modQuotationDetail> list = _dal.GetDetail(formid, out Util.emsg); if (list == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { dalProductList dalpdt = new dalProductList(); foreach (modQuotationDetail modd in list) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = modd.ProductId; row.Cells[1].Value = modd.ProductName; row.Cells[2].Value = modd.Specify; row.Cells[3].Value = modd.UnitNo; row.Cells[4].Value = modd.Brand; row.Cells[5].Value = modd.Qty.ToString(); row.Cells[6].Value = modd.Price.ToString(); row.Cells[7].Value = modd.Remark; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
private void DBGrid2_DoubleClick(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (DBGrid2.CurrentRow == null) { return; } modAccProductSummary mod = (modAccProductSummary)DBGrid2.CurrentRow.DataBoundItem; if (DBGrid.RowCount > 0) { for (int i = 0; i < DBGrid.RowCount; i++) { if (DBGrid.Rows[i].Cells[1].Value.ToString().Trim() == mod.ProductId) { MessageBox.Show("该产品已经添加,您不能重复添加!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (DBGrid2.CurrentRow.Cells[10].Value == null || string.IsNullOrEmpty(DBGrid2.CurrentRow.Cells[10].Value.ToString()) || decimal.Parse(DBGrid2.CurrentRow.Cells[10].Value.ToString()) == 0) { MessageBox.Show("该产品数量为0,您不能调整它的价格!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } MTN_PRODUCT_LIST frm = new MTN_PRODUCT_LIST(); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = mod.ProductId; row.Cells[1].Value = mod.ProductName; row.Cells[2].Value = mod.EndQty; row.Cells[3].Value = mod.EndPrice; row.Cells[4].Value = mod.EndPrice; row.Cells[5].Value = mod.EndMny; row.Cells[6].Value = mod.EndMny; row.Cells[7].Value = 0; row.Cells[8].Value = ""; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
// Метод используемый делегатом для добавления нового клиента в датагрид public void addRowsMethod(Socket socket) { try { DataGridViewRow dr = new DataGridViewRow(); dr.CreateCells(dataGridView1); dr.SetValues(new object[] { socket.ProtocolType.ToString(), socket.RemoteEndPoint.ToString() }); dataGridView1.Rows.AddRange(dr); dr.Dispose(); } catch { } }
/// <summary> /// 入力確認 /// </summary> /// <param name="TargetRow"></param> private void InputCheck(int TargetRow) { DataGridViewRow TargetdgvRow = this.dataGridViewList.Rows[TargetRow]; // 入力確認(原価名称) if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "") { TargetdgvRow.Cells[10].Value = "[原価名称]を入力してください。"; TargetdgvRow.Dispose(); return; } // 入力確認(原価) if (Convert.ToString(TargetdgvRow.Cells[6].Value) == "") { TargetdgvRow.Cells[10].Value = "[原価]を入力してください。"; TargetdgvRow.Dispose(); return; } TargetdgvRow.Cells[10].Value = ""; TargetdgvRow.Dispose(); }
public void WriteCSV(DataGridView gridIn, string outputFile) { //test to see if the DataGridView has any rows if (gridIn.RowCount > 0) { string value = ""; DataGridViewRow dr = new DataGridViewRow(); StreamWriter swOut = new StreamWriter(outputFile); for (int j = 0; j <= gridIn.Rows.Count - 1; j++) { if (j > 0) { swOut.WriteLine(); } dr = gridIn.Rows[j]; if (dr.Cells[0].Value == null) { continue; } for (int i = 0; i <= gridIn.Columns.Count - 1; i++) { if (i > 0) { swOut.Write(";"); } if (dr.Cells[i].Value == null) { value = ""; } else { value = dr.Cells[i].Value.ToString(); } //replace comma's with spaces value = value.Replace(',', ' '); //replace embedded newlines with spaces value = value.Replace(Environment.NewLine, " "); swOut.Write(value); } } dr.Dispose(); swOut.Close(); } }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { if (tabControl1.SelectedIndex == 1) { label10.Text = "Carnetul de note al elevului " + parent.nume; dataGridView1.Rows.Clear(); con.Open(); cmd = new SqlCommand("SELECT NotaEvaluare, DataEvaluare FROM Evaluari Where IdElev='" + parent.idUser + "'", con); cmdR = cmd.ExecuteReader(); while (cmdR.Read()) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridView1); row.Cells[1].Value = cmdR[0].ToString(); row.Cells[0].Value = cmdR[1].ToString(); dataGridView1.Rows.Add(row); row.Dispose(); } cmdR.Close(); con.Close(); } if (tabControl1.SelectedIndex == 2) { int x = 1; chart1.Series[0].Points.Clear(); chart1.Series[1].Points.Clear(); con.Open(); cmd = new SqlCommand("Select NotaEvaluare FROM Evaluari WHERE IdElev='" + parent.idUser + "'", con); cmdR = cmd.ExecuteReader(); while (cmdR.Read()) { chart1.Series[0].Points.AddXY(x, cmdR[0]); x++; } con.Close(); con.Open(); cmd = new SqlCommand("SELECT AVG(NotaEvaluare),COUNT(NotaEvaluare) FROM Evaluari WHERE IdElev IN (SELECT IdElev FROM Utilizatori WHERE ClasaUtilizator = '" + parent.clasaUser + "')", con); cmdR = cmd.ExecuteReader(); if (cmdR.Read()) { chart1.Series[1].Points.AddXY(1, cmdR[0]); chart1.Series[1].Points.AddXY(cmdR[1], cmdR[0]); } con.Close(); } }
/// <summary> /// Adds the row for the given set. /// </summary> /// <param name="set"></param> private void AddRow(SerializableSettingsImplantSet set) { DataGridViewRow tempRow = null; try { tempRow = new DataGridViewRow(); tempRow.CreateCells(setsGrid, set.Name); tempRow.Tag = set; DataGridViewRow row = tempRow; tempRow = null; setsGrid.Rows.Add(row); } finally { tempRow?.Dispose(); } }
private void removeToolStripMenuItem_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { int index = this.dataGridView1.SelectedRows[0].Index; if (index > -1 && index < AutoIgnores.Count) { AutoIgnores.RemoveItem(index); DataGridViewRow row = this.dataGridView1.Rows[index]; this.dataGridView1.Rows.RemoveAt(index); foreach (DataGridViewCell d in row.Cells) { d.Dispose(); } row.Dispose(); } } }
private void mnuAdd_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; MTN_PRODUCT_LIST frm = new MTN_PRODUCT_LIST(); frm.SelectVisible = true; if (frm.ShowDialog() == DialogResult.OK) { dalProductList dal = new dalProductList(); modProductList mod = dal.GetItem(Util.retValue1, out Util.emsg); if (mod != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = mod.ProductId; row.Cells[1].Value = mod.ProductName; row.Cells[2].Value = mod.Specify; row.Cells[3].Value = mod.UnitNo; row.Cells[4].Value = mod.Brand; row.Cells[5].Value = 1; row.Cells[6].Value = 0; row.Cells[7].Value = ""; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
private void removeToolStripMenuItem1_Click(object sender, EventArgs e) // remove2 { if (this.dataGridView2.SelectedRows.Count > 0) { int index = this.dataGridView2.SelectedRows[0].Index; if (index > -1 && index < Menus.Room.Count) { Menus.Room.RemoveAt(index); Menus.UpdateR(); DataGridViewRow row = this.dataGridView2.Rows[index]; this.dataGridView2.Rows.RemoveAt(index); foreach (DataGridViewCell d in row.Cells) { d.Dispose(); } row.Dispose(); } } }
private void Table_fanarts_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 5) { DataGridViewRow row = table_fanarts.Rows[e.RowIndex]; if (MessageBox.Show(string.Format("Do you want to delete this Fanart?"), "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { table_fanarts.Rows.Remove(table_fanarts.Rows[e.RowIndex]); MessageBox.Show("Deleted."); } row.Dispose(); } if (e.ColumnIndex == 6) { WebClient wc = new WebClient(); System.Drawing.Image img; DataGridViewRow row = table_fanarts.Rows[e.RowIndex]; try { byte[] bytes = wc.DownloadData(row.Cells[3].Value.ToString()); MemoryStream ms = new MemoryStream(bytes); img = System.Drawing.Image.FromStream(ms); } catch { byte[] bytes = wc.DownloadData("https://i.imgur.com/wvCqhzD.jpg"); MemoryStream ms = new MemoryStream(bytes); img = System.Drawing.Image.FromStream(ms); } row.Cells[0].Value = img; row.Dispose(); wc.Dispose(); table_fanarts.Refresh(); } }
private void txtProduct_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter) || e.KeyChar == Convert.ToChar(Keys.Space)) { dalProductSalePrice dalprice = new dalProductSalePrice(); dalProductList dal = new dalProductList(); BindingCollection <modProductList> list = dal.GetIListByBarcode(txtProduct.Text.Trim(), out Util.emsg); if (list != null && list.Count > 0) { if (list.Count == 1) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = list[0].ProductId; row.Cells[1].Value = list[0].ProductName; row.Cells[2].Value = list[0].Barcode; row.Cells[3].Value = list[0].UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(list[0].ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = list[0].Specify; DBGrid.Rows.Add(row); row.Dispose(); } else { frmViewList frm = new frmViewList(); frm.InitViewList("请选择商品:", list); frm.Selection = true; if (frm.ShowDialog() == DialogResult.OK) { var modPdt = list.Where(c => c.ProductId == Util.retValue1).First(); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = modPdt.ProductId; row.Cells[1].Value = modPdt.ProductName; row.Cells[2].Value = modPdt.Barcode; row.Cells[3].Value = modPdt.UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(modPdt.ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = modPdt.Specify; DBGrid.Rows.Add(row); row.Dispose(); } } SumData(); } else { modProductList mod = dal.GetItem(txtProduct.Text.Trim(), out Util.emsg); if (mod != null) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 40; row.Cells[0].Value = mod.ProductId; row.Cells[1].Value = mod.ProductName; row.Cells[2].Value = mod.Barcode; row.Cells[3].Value = mod.UnitNo; row.Cells[4].Value = 1; row.Cells[5].Value = dalprice.GetDefaultPrice(mod.ProductId, out Util.emsg); row.Cells[6].Value = decimal.Parse(row.Cells[5].Value.ToString()); row.Cells[8].Value = mod.Specify; DBGrid.Rows.Add(row); row.Dispose(); SumData(); } else { MessageBox.Show("没有找到商品!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (DBGrid.RowCount > 0) { DBGrid.CurrentCell = DBGrid.Rows[DBGrid.RowCount - 1].Cells[4]; } txtProduct.Text = string.Empty; txtProduct.Focus(); } }
private void mnuAdd_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; ACC_SUBJECT_LIST frm = new ACC_SUBJECT_LIST(); frm.ShowHideVisible(true); if (frm.ShowDialog() == DialogResult.OK) { if (ACC_SUBJECT_LIST._mod.SubjectId.IndexOf("9135") >= 0) { DataGridViewRow rowdef = new DataGridViewRow(); rowdef.CreateCells(DBGrid); rowdef.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; rowdef.Cells[1].Value = "本年利润"; rowdef.Cells[2].Value = ACC_SUBJECT_LIST._mod.SubjectName; rowdef.Cells[3].Value = ""; rowdef.Cells[4].Value = Util.Currency; rowdef.Cells[5].Value = "0"; rowdef.Cells[6].Value = 1; rowdef.Cells[7].Value = ""; rowdef.Cells[8].Value = ""; rowdef.Cells[9].Value = ""; rowdef.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); rowdef.Height = 40; DBGrid.Rows.Add(rowdef); rowdef.Dispose(); } else { DataGridViewRow row; switch (ACC_SUBJECT_LIST._mod.SubjectId) { case "1030": //现金银行 ACC_BANK_ACCOUNT frm2 = new ACC_BANK_ACCOUNT(); frm2.ShowHideSelection(true); if (frm2.ShowDialog() == DialogResult.OK) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName.Replace(".", "").Trim(); row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = ""; row.Cells[4].Value = Util.retValue2; row.Cells[5].Value = "0"; row.Cells[6].Value = clsLxms.GetExchangeRate(Util.retValue1); row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } break; case "1055": //应收帐款 MTN_CUSTOMER_LIST frmccust = new MTN_CUSTOMER_LIST(); frmccust.ShowHideSelection(true); if (frmccust.ShowDialog() == DialogResult.OK) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = Util.retValue2; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } break; case "5145": //应付帐款 MTN_VENDOR_LIST frmvendor = new MTN_VENDOR_LIST(); frmvendor.SelectVisible = true; if (frmvendor.ShowDialog() == DialogResult.OK) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = Util.retValue2; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } break; case "1060": //其它应收款 OTHER_RECEIVABLE_OBJECT frmor = new OTHER_RECEIVABLE_OBJECT(); frmor.SelectVisible = true; if (frmor.ShowDialog() == DialogResult.OK) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = ""; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } break; case "5155": //其它应付款 OTHER_PAYABLE_OBJECT frmop = new OTHER_PAYABLE_OBJECT(); frmop.SelectVisible = true; if (frmop.ShowDialog() == DialogResult.OK) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = ""; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } break; case "1075": //应收票据 case "5125": //应付票据 row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = Util.retValue1; row.Cells[3].Value = ""; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.AddDays(7).ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); break; default: row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = ACC_SUBJECT_LIST._mod.SubjectId; row.Cells[1].Value = ACC_SUBJECT_LIST._mod.SubjectName; row.Cells[2].Value = ""; row.Cells[3].Value = ""; row.Cells[4].Value = Util.Currency; row.Cells[5].Value = "0"; row.Cells[6].Value = 1; row.Cells[7].Value = ""; row.Cells[8].Value = ""; row.Cells[9].Value = ""; row.Cells[10].Value = DateTime.Today.ToString("MM-dd-yyyy"); row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
public void EditItem(string formid) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; modPriceAdjustForm mod = _dal.GetItem(formid, out Util.emsg); if (mod != null) { txtFormId.Text = formid; dtpFormDate.Value = mod.FormDate; txtRemark.Text = mod.Remark; if (mod.Status == 1) { status4.Image = Properties.Resources.audited; Util.ChangeStatus(this, true); DBGrid.ReadOnly = true; mnuNew.Enabled = false; mnuDelete.Enabled = false; toolSave.Enabled = false; } else { status4.Image = null; toolSave.Visible = true; Util.ChangeStatus(this, false); DBGrid.ReadOnly = false; mnuNew.Enabled = true; mnuDelete.Enabled = true; toolSave.Enabled = true; } DBGrid.Rows.Clear(); LoadDBGrid(); DBGrid2_DoubleClick(null, null); BindingCollection <modPriceAdjustDetail> list = _dal.GetDetail(formid, out Util.emsg); if (list == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { foreach (modPriceAdjustDetail modd in list) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = modd.ProductId; row.Cells[1].Value = modd.ProductName; row.Cells[2].Value = modd.Qty.ToString(); row.Cells[3].Value = modd.CurrentPrice; row.Cells[4].Value = modd.TruePrice; row.Cells[5].Value = modd.CurrentMny; row.Cells[6].Value = modd.TrueMny; row.Cells[7].Value = modd.Differ; row.Cells[8].Value = modd.Remark; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } GetDetailSum(); } //DBGrid.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// データグリッドビュー表示 /// </summary> private void CreateDataGridView() { int RowCount = this.dataGridViewList.Rows.Count; if (RowCount > 0) { // データグリッドビューすべての行を削除 for (int i = 1; i <= RowCount; i++) { this.dataGridViewList.Rows.RemoveAt(0); } } SqlHandling sh = new SqlHandling(); // SQL実行クラス string SetSQL = ""; SetSQL += "CostID, CostCode, Item, ItemDetail, "; SetSQL += "Unit, Cost, MemberCode, UpdateDate "; SetSQL += "FROM M_Cost "; SetSQL += "WHERE OfficeCode = '" + Convert.ToString(this.comboBoxOfficeCode.SelectedValue) + "' "; SetSQL += "ORDER BY CostCode, Cost"; DataTable dt = sh.SelectFullDescription(SetSQL); // SQL実行 DataRow dr = null; // レコード格納用 if (dt == null) { this.dataGridViewList.Rows.Add(1); this.dataGridViewList.Rows[0].Cells[1].Value = "A"; } else { this.dataGridViewList.Rows.Add(dt.Rows.Count); DataGridViewRow TargetRow = null; // 格納データグリッドビュー列格納用 for (int i = 0; i < this.dataGridViewList.Rows.Count; i++) { dr = dt.Rows[i]; TargetRow = this.dataGridViewList.Rows[i]; TargetRow.Cells[0].Value = Convert.ToString(dr["CostID"]); // 原価ID TargetRow.Cells[1].Value = Convert.ToString(dr["CostCode"]).Substring(0, 1); // 原価コード TargetRow.Cells[2].Value = Convert.ToString(dr["CostCode"]); // 原価コード TargetRow.Cells[3].Value = Convert.ToString(dr["Item"]); // 原価名称 TargetRow.Cells[4].Value = Convert.ToString(dr["ItemDetail"]); // 細別 TargetRow.Cells[5].Value = Convert.ToString(dr["Unit"]); // 単価 TargetRow.Cells[6].Value = CheckDecimal(Convert.ToString(dr["Cost"])); // 原価 TargetRow.Cells[7].Value = Convert.ToString(dr["MemberCode"]); // 社員番号 TargetRow.Cells[8].Value = CheckDatetTime(Convert.ToString(dr["UpdateDate"]), "yyyyMM/dd"); // 更新日 } TargetRow.Dispose(); } // 初期M_Cost情報を格納 dt = sh.SelectFullDescription(MaxCodeSqlMake()); if (dt == null) { CostInf = new COSTINFO[1]; CostInf[0].CostCodeH = "A"; CostInf[0].CostCodeNumL = 0; CostInf[0].CostCodeNumU = 0; } else { CostInf = new COSTINFO[dt.Rows.Count]; for (int i = 0; i < CostInf.Length; i++) { dr = dt.Rows[i]; CostInf[i].CostCodeH = Convert.ToString(dr["CodeH"]); CostInf[i].CostCodeNumL = Convert.ToInt32(dr["M_CodeML"]); CostInf[i].CostCodeNumU = Convert.ToInt32(dr["M_CodeMU"]); } } this.labelOfficeCode.Text = Convert.ToString(this.comboBoxOfficeCode.Text); // Wakamatsu 20170323 this.dataGridViewList.CurrentCell = null; }
private void LoadData() { DBGrid.Columns.Clear(); ArrayList arrHeader = new ArrayList(); ArrayList arrTitle = new ArrayList(); arrHeader.Add(clsTranslate.TranslateString("GroupId")); arrHeader.Add(clsTranslate.TranslateString("TaskCode")); arrHeader.Add(clsTranslate.TranslateString("TaskName")); arrTitle.Add(clsTranslate.TranslateString("GroupId")); arrTitle.Add(clsTranslate.TranslateString("TaskCode")); arrTitle.Add(clsTranslate.TranslateString("TaskName")); dalUserList blluser = new dalUserList(); BindingCollection <modUserList> listuser = blluser.GetIList(true, out Util.emsg); if (listuser != null && listuser.Count > 0) { foreach (modUserList mod in listuser) { arrHeader.Add(mod.UserId); arrTitle.Add(mod.UserName); } } for (int i = 0; i < arrHeader.Count; i++) { //if (i <= 1) //{ DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = arrTitle[i].ToString(); col.DataPropertyName = arrHeader[i].ToString(); col.Name = arrHeader[i].ToString(); if (i == 1) { col.Visible = false; } else if (i == 0 || i == 2) { col.Width = 120; } else { col.Width = 30; } col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; DBGrid.Columns.Add(col); col.Dispose(); //} //else //{ // DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn(); // col.HeaderText = arrTitle[i].ToString(); // col.DataPropertyName = arrHeader[i].ToString(); // col.Width = 70; // DBGrid.Columns.Add(col); // col.Dispose(); //} } DataGridViewRow row; dalTaskList bll = new dalTaskList(); BindingCollection <modTaskList> list = bll.GetIList(string.Empty, false, false, out Util.emsg); if (list != null && list.Count > 0) { foreach (modTaskList mod in list) { row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = clsTranslate.TranslateString(mod.GroupId); row.Cells[1].Value = mod.TaskCode; row.Cells[2].Value = clsTranslate.TranslateString(mod.TaskName); DBGrid.Rows.Add(row); row.Dispose(); } } for (int iCol = 3; iCol < DBGrid.ColumnCount; iCol++) { dalTaskGrant blltg = new dalTaskGrant(); BindingCollection <modTaskGrant> listtg = blltg.GetUserGrantData(false, false, DBGrid.Columns[iCol].Name, string.Empty, string.Empty, out Util.emsg); if (listtg != null && listtg.Count > 0) { foreach (modTaskGrant mod in listtg) { for (int iRow = 0; iRow < DBGrid.RowCount; iRow++) { if (mod.TaskCode.CompareTo(DBGrid.Rows[iRow].Cells[1].Value.ToString()) == 0) { DBGrid.Rows[iRow].Cells[iCol].Value = "√"; break; } } } } } DBGrid.Columns[2].Frozen = true; DBGrid.AlternatingRowsDefaultCellStyle.BackColor = Color.Empty; DBGrid.Columns[0].DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR; DBGrid.Columns[1].DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR; DBGrid.Columns[2].DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR; DBGrid.MergeColumnNames.Add(arrHeader[0].ToString()); DBGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True; }
/// <summary> /// データグリッドビュー変更処理 /// </summary> /// <param name="TargetPoint"></param> private void DataGridViewChange(Point TargetPoint) { DataGridViewRow TargetdgvRow = this.dataGridViewList.Rows[TargetPoint.Y]; switch (TargetPoint.X) { // Wakamatsu 20170302 case 2: // 原価コード if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[2].Value = CostKey.CostCodeH + CostKey.CostCodeNum; TargetdgvRow.Dispose(); return; } // 入力確認 string CheckCodeU = Convert.ToString(TargetdgvRow.Cells[2].Value).ToUpper(); string CheckResult = CostCodeCheck(CheckCodeU, TargetPoint.Y); if (CheckResult != "") { MessageBox.Show(CheckResult); TargetdgvRow.Cells[2].Value = CostKey.CostCodeH + CostKey.CostCodeNum; TargetdgvRow.Dispose(); return; } TargetdgvRow.Cells[1].Value = CheckCodeU.Substring(0, 1); TargetdgvRow.Cells[2].Value = CheckCodeU; string CheckCodeH = ""; if (CostKey.CostCodeH == "A" || CostKey.CostCodeH == "B") { if (CostKey.CostCodeH == "A") { CheckCodeH = "B"; } else { CheckCodeH = "A"; } if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B") { // 変更前も変更後も原価コードの先頭文字列が"A"または"B"の場合 for (int i = 0; i < this.dataGridViewList.Rows.Count; i++) { if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) == CheckCodeH + CostKey.CostCodeNum && Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == CostKey.MemberCode) { if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A") { CheckCodeH = "B"; } else { CheckCodeH = "A"; } this.dataGridViewList.Rows[i].Cells[1].Value = CheckCodeH; this.dataGridViewList.Rows[i].Cells[2].Value = CheckCodeH + Convert.ToString(TargetdgvRow.Cells[2].Value).Substring(1); } } } else { // 変更前の原価コードの先頭文字列が"A"または"B"で変更後の原価コードの先頭文字列が"A"または"B"でない場合 for (int i = 0; i < this.dataGridViewList.Rows.Count; i++) { if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) == CheckCodeH + CostKey.CostCodeNum && Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == CostKey.MemberCode) { this.dataGridViewList.Rows.RemoveAt(i); } } TargetdgvRow.Cells[7].Value = ""; } } else { if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B") { // 変更前の原価コードの先頭文字列が"A"または"B"でなく変更後の原価コードの先頭文字列が"A"または"B"場合 if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A") { CheckCodeH = "B"; } else { CheckCodeH = "A"; } TargetdgvRow.Cells[3].Value = ""; TargetdgvRow.Cells[6].Value = CheckDecimal("0"); TargetdgvRow.Cells[7].Value = ""; TargetdgvRow.Cells[10].Value = "[原価名称]を入力してください。"; this.dataGridViewList.Rows.Insert(TargetPoint.Y + 1); this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[1].Value = CheckCodeH; this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[2].Value = CheckCodeH + Convert.ToString(TargetdgvRow.Cells[2].Value).Substring(1); this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[3].Value = ""; this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[6].Value = CheckDecimal("0"); this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[7].Value = ""; this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[10].Value = "[原価名称]を入力してください。"; } } if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "K") { if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "" || Convert.ToString(TargetdgvRow.Cells[3].Value) == CODEL) { TargetdgvRow.Cells[3].Value = CODEK; } } else if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "L" && Convert.ToString(TargetdgvRow.Cells[3].Value) == "") { if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "" || Convert.ToString(TargetdgvRow.Cells[3].Value) == CODEK) { TargetdgvRow.Cells[3].Value = CODEL; } } break; // Wakamatsu 20170302 case 3: // 原価名称 if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[3].Value = CostKey.CostName; TargetdgvRow.Dispose(); return; } if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "") { // 社員番号を空欄とする TargetdgvRow.Cells[7].Value = ""; if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B") { // 対となる原価コード変更 PairCostControl("", ""); } } else { if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B") { // 原価名称編集後 ListFormDataOp lo = new ListFormDataOp(); // メンバー取得 MembersScData[] msdl = lo.SelectMembersScData(Convert.ToString(TargetdgvRow.Cells[3].Value), 0); MembersScData msd = null; if (msdl != null) { msd = FormMembersList.ReceiveItems(msdl); } if (msd == null) { // 選択されなかった場合 msd = new MembersScData(); msd.Name = ""; msd.MemberCode = ""; TargetdgvRow.Cells[3].Value = msd.Name; TargetdgvRow.Cells[7].Value = msd.MemberCode; } else { // 選択された社員情報を格納 TargetdgvRow.Cells[3].Value = msd.Name; TargetdgvRow.Cells[7].Value = msd.MemberCode; string OverlapCode = ""; // 重複原価コード格納用 string[] OverlapCodeList; // 重複原価コード格納用(配列) bool OverlapFlag = false; // 重複社員番号フラグ // 選択された場合 for (int i = 0; i < this.dataGridViewList.Rows.Count; i++) { if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[1].Value) == "A" || Convert.ToString(this.dataGridViewList.Rows[i].Cells[1].Value) == "B") { // 原価コードが"A"または"B"の場合 if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == msd.MemberCode) { // 社員番号が同じ場合 OverlapCode += Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) + ","; } } } // 社員番号重複確認 if (OverlapCode.Length != 0) { // 末尾の","を外す OverlapCode = OverlapCode.Substring(0, OverlapCode.Length - 1); } OverlapCodeList = OverlapCode.Split(','); if (OverlapCodeList.Length == 2) { // 社員番号の重複が2つの場合 if (OverlapCodeList[0].Substring(0, 1) == OverlapCodeList[1].Substring(0, 1)) { // 社員番号が重複している行の原価コードの先頭が同じ場合登録不可 OverlapFlag = true; } else if (OverlapCodeList[0].Substring(1) != OverlapCodeList[1].Substring(1)) { // 社員番号が重複している行の原価コードの先頭以外が異なる場合登録不可 OverlapFlag = true; } } else if (OverlapCodeList.Length > 2) { // 社員番号が重複している行が3行以上の場合登録不可 OverlapFlag = true; } if (OverlapFlag == true) { MessageBox.Show("原価コード:" + Convert.ToString(TargetdgvRow.Cells[2].Value) + "\r\n" + "原価名称:" + Convert.ToString(TargetdgvRow.Cells[3].Value) + "\r\n" + "すでに登録されている社員番号です。"); TargetdgvRow.Cells[3].Value = ""; TargetdgvRow.Cells[7].Value = ""; msd.Name = ""; msd.MemberCode = ""; } } if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "B" && msd.Name != "") { TargetdgvRow.Cells[3].Value += CODEB; } // 対となる原価コード変更 PairCostControl(msd.Name, msd.MemberCode); } } // 変更確認 if (Convert.ToString(TargetdgvRow.Cells[3].Value) != CostKey.CostName) { if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[9].Value = "U"; } } break; case 4: // 細別 // 変更確認 if (Convert.ToString(TargetdgvRow.Cells[4].Value) != CostKey.CostDetail) { if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[9].Value = "U"; } } break; case 5: // 単位 // 変更確認 if (Convert.ToString(TargetdgvRow.Cells[5].Value) != CostKey.CostUnit) { if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[9].Value = "U"; } } break; case 6: // 原価 TargetdgvRow.Cells[6].Value = CheckDecimal(Convert.ToString(TargetdgvRow.Cells[6].Value)); // 変更確認 if (Convert.ToString(TargetdgvRow.Cells[6].Value) != CostKey.SetCost) { if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I") { TargetdgvRow.Cells[9].Value = "U"; } } break; default: // その他 break; } // 入力確認 InputCheck(TargetPoint.Y); TargetdgvRow.Dispose(); }
private void LoadData() { if (cboAccName.ComboBox.SelectedValue == null || cboExpenseType.ComboBox.SelectedValue == null) { return; } DBGrid.Columns.Clear(); DataGridViewTextBoxColumn col0 = new DataGridViewTextBoxColumn(); col0.HeaderText = "月"; col0.DataPropertyName = "Month"; col0.Name = "Month"; col0.Width = 50; DBGrid.Columns.Add(col0); DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn(); col1.HeaderText = "日"; col1.DataPropertyName = "Day"; col1.Name = "Day"; col1.Width = 50; DBGrid.Columns.Add(col1); DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn(); col2.HeaderText = "凭证号"; col2.DataPropertyName = "AccSeq"; col2.Name = "AccSeq"; col2.Width = 50; DBGrid.Columns.Add(col2); DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn(); col3.HeaderText = "摘要"; col3.DataPropertyName = "Digest"; col3.Name = "Digest"; col3.Width = 220; DBGrid.Columns.Add(col3); DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn(); col4.HeaderText = "小计"; col4.DataPropertyName = "RowSum"; col4.Name = "RowSum"; col4.Width = 120; col4.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR; //col4.DefaultCellStyle.ForeColor = Color.Red; col4.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid.Columns.Add(col4); dalAccExpenseForm dal = new dalAccExpenseForm(); BindingCollection <modAccExpenseColumn> list = dal.GetExpenseColumn(cboAccName.ComboBox.SelectedValue.ToString(), cboExpenseType.ComboBox.SelectedValue.ToString(), out Util.emsg); if (list != null && list.Count > 0) { var p = list.Select(c => c.ExpenseName).Distinct(); foreach (string expenseName in p) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = expenseName; col.DataPropertyName = expenseName; col.Name = expenseName; col.Width = 100; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; DBGrid.Columns.Add(col); col.Dispose(); } var q = list.Select(c => new { Month = c.FormDate.Month, Day = c.FormDate.Day, AccSeq = c.AccSeq, Digest = c.Digest }).OrderBy(a => a.Month).OrderBy(a => a.Day).OrderBy(a => a.AccSeq).Distinct().ToList(); q.ForEach(item => { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Height = 36; row.Cells[0].Value = item.Month; row.Cells[1].Value = item.Day; row.Cells[2].Value = item.AccSeq; row.Cells[3].Value = item.Digest; decimal rowSum = 0; for (int i = 5; i < DBGrid.ColumnCount; i++) { var t = list.Where(a => a.FormDate.Day == item.Day && a.AccSeq == item.AccSeq && a.Digest == item.Digest && a.ExpenseName == DBGrid.Columns[i].Name).Select(c => c.ExpenseMny).FirstOrDefault(); if (t != 0) { row.Cells[i].Value = t; rowSum += t; } } row.Cells[4].Value = rowSum; DBGrid.Rows.Add(row); row.Dispose(); }); DataGridViewRow rowTotal = new DataGridViewRow(); rowTotal.CreateCells(DBGrid); rowTotal.Height = 36; rowTotal.Cells[2].Value = "合 计"; for (int i = 4; i < DBGrid.ColumnCount; i++) { decimal colSum = 0; for (int j = 0; j < DBGrid.RowCount; j++) { colSum += DBGrid.Rows[j].Cells[i].Value == null ? 0 : decimal.Parse(DBGrid.Rows[j].Cells[i].Value.ToString()); } rowTotal.Cells[i].Value = colSum; } rowTotal.DefaultCellStyle.BackColor = frmOptions.ALTERNATING_BACKCOLOR; DBGrid.Rows.Add(rowTotal); } else { if (!string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary> /// データグリッドビュー表示 /// </summary> private void CreateDataGridView() { Cursor.Current = Cursors.WaitCursor; // マウスカーソルを砂時計(Wait) int RowCount = this.dataGridViewList.Rows.Count; if (RowCount > 0) { // データグリッドビューすべての行を削除 for (int i = 1; i <= RowCount; i++) { this.dataGridViewList.Rows.RemoveAt(0); } } SqlHandling sh = new SqlHandling(); // SQL実行クラス DataTable dt = sh.SelectFullDescription(CreateSql()); // SQL実行 if (dt == null) { return; } this.dataGridViewList.Rows.Add(dt.Rows.Count); DataRow dr = null; // レコード格納用 DataGridViewRow TargetRow = null; // 格納データグリッドビュー列格納用 for (int i = 0; i < this.dataGridViewList.Rows.Count; i++) { dr = dt.Rows[i]; // 20190206 asakawa ADD 1Line dr = GetDataLastYear(dr); // 20190206 asakawa ADD END TargetRow = this.dataGridViewList.Rows[i]; TargetRow.Cells[0].Value = Convert.ToString(dr["OfficeName"]); // 部署 TargetRow.Cells[1].Value = Convert.ToString(dr["TaskCode"]); // 業務番号 TargetRow.Cells[2].Value = Convert.ToString(dr["TaskName"]); // 業務名 TargetRow.Cells[3].Value = Convert.ToString(dr["PartnerName"]); // 業者名 TargetRow.Cells[4].Value = CheckDatetTime(Convert.ToString(dr["StartDate"]), "yyyy/MM/dd"); // 工期開始 TargetRow.Cells[5].Value = CheckDatetTime(Convert.ToString(dr["EndDate"]), "yyyy/MM/dd"); // 工期完了 TargetRow.Cells[6].Value = Convert.ToString(dr["SalesName"]); // 営業担当者 TargetRow.Cells[7].Value = Convert.ToString(dr["LeaderName"]); // 業務担当者 TargetRow.Cells[8].Value = CheckDecimal(Convert.ToString(dr["LastOrder"])); // 前年度受注額 TargetRow.Cells[9].Value = CheckDecimal(Convert.ToString(dr["ThisOrder"])); // 本年度受注額 // 受注額計 if (Convert.ToString(TargetRow.Cells[8].Value) != "" || Convert.ToString(TargetRow.Cells[9].Value) != "") { TargetRow.Cells[10].Value = CheckDecimal(Convert.ToString(dr["TotalOrder"])); } TargetRow.Cells[11].Value = CheckDecimal(Convert.ToString(dr["LastVolume"])); // 前年度出来高 TargetRow.Cells[12].Value = CheckDecimal(Convert.ToString(dr["ThisVolume"])); // 本年度出来高 // 出来高計 if (Convert.ToString(TargetRow.Cells[11].Value) != "" || Convert.ToString(TargetRow.Cells[12].Value) != "") { TargetRow.Cells[13].Value = CheckDecimal(Convert.ToString(dr["TotalVolume"])); } TargetRow.Cells[14].Value = CheckDecimal(Convert.ToString(dr["LastCost"])); // 前年度原価 TargetRow.Cells[15].Value = CheckDecimal(Convert.ToString(dr["ThisCost"])); // 本年度原価 // 原価計 if (Convert.ToString(TargetRow.Cells[14].Value) != "" || Convert.ToString(TargetRow.Cells[15].Value) != "") { TargetRow.Cells[16].Value = CheckDecimal(Convert.ToString(dr["TotalCost"])); } // 残業務高 if (Convert.ToString(TargetRow.Cells[9].Value) != "" && Convert.ToString(TargetRow.Cells[12].Value) != "") { // Wakamatsu 20170309 //TargetRow.Cells[17].Value = DHandling.DecimaltoStr(Convert.ToDecimal(TargetRow.Cells[10].Value) - // Convert.ToDecimal(TargetRow.Cells[13].Value), "#,0"); TargetRow.Cells[17].Value = MinusConvert(SignConvert(TargetRow.Cells[10].Value) - SignConvert(TargetRow.Cells[13].Value)); } // Wakamatsu 20170309 TargetRow.Cells[18].Value = CheckDecimal(Convert.ToString(dr["CarryOverPlanned"])); // 繰越予定額 // 年度内完工高(本年度受注額 - 繰越予定額) if (Convert.ToString(TargetRow.Cells[9].Value) != "" && Convert.ToString(TargetRow.Cells[18].Value) != "") { // Wakamatsu 20170309 //TargetRow.Cells[19].Value = DHandling.DecimaltoStr(Convert.ToDecimal(TargetRow.Cells[9].Value) - // Convert.ToDecimal(TargetRow.Cells[18].Value), "#,0"); TargetRow.Cells[19].Value = MinusConvert(SignConvert(TargetRow.Cells[9].Value) - SignConvert(TargetRow.Cells[18].Value)); } // Wakamatsu 20170309 TargetRow.Cells[20].Value = CheckDecimal(Convert.ToString(dr["LastClaim"])); // 前年度請求額 TargetRow.Cells[21].Value = CheckDecimal(Convert.ToString(dr["ThisClaim"])); // 本年度請求額 // 請求額計 if (Convert.ToString(TargetRow.Cells[20].Value) != "" || Convert.ToString(TargetRow.Cells[21].Value) != "") { TargetRow.Cells[22].Value = CheckDecimal(Convert.ToString(dr["TotalClaim"])); } TargetRow.Cells[23].Value = CheckDecimal(Convert.ToString(dr["BalanceIncom"])); // 未収入金 TargetRow.Cells[24].Value = CheckDecimal(Convert.ToString(dr["BalanceClaim"])); // 残請求額 // Wakamatsu // 未成業務受入金額(請求単月-出来高) //if ( Convert.ToString(TargetRow.Cells[12].Value) != "" && // Convert.ToString(TargetRow.Cells[21].Value) != "") //{ // TargetRow.Cells[25].Value = (Convert.ToDecimal(TargetRow.Cells[22].Value) - // Convert.ToDecimal(TargetRow.Cells[13].Value)).ToString("#,0"); // if (Convert.ToDecimal(TargetRow.Cells[25].Value) <= 0) // TargetRow.Cells[25].Value = ""; //} // 未成業務受入金額(入金-出来高) // Wakamatsu 20170302 //if (Convert.ToString(TargetRow.Cells[12].Value) != "" && // Convert.ToString(dr["ThisPaid"]) != "") //{ // decimal PaidWork = 0; // if (decimal.TryParse(Convert.ToString(dr["TotalPaid"]), out PaidWork)) // { // TargetRow.Cells[25].Value = PaidWork - Convert.ToDecimal(TargetRow.Cells[13].Value); // if (Convert.ToDecimal(TargetRow.Cells[25].Value) <= 0) // TargetRow.Cells[25].Value = ""; // } //} TargetRow.Cells[25].Value = CheckDecimal(Convert.ToString(dr["Deposit2"])); // Wakamatsu 20170302 // Wakamatsu // 状況 switch (Convert.ToString(dr["TaskStat"])) { case "0": TargetRow.Cells[26].Value = "稼働"; break; case "1": TargetRow.Cells[26].Value = "完了"; break; case "2": TargetRow.Cells[26].Value = "休止中"; break; case "3": TargetRow.Cells[26].Value = "完全完了"; break; default: break; } // 業務内容確認書 // Wakamatsu //TargetRow.Cells[28].Value = CheckDecimal(Convert.ToString(dr["Sales"])); // 請負額 //TargetRow.Cells[28].Value = CheckDecimal(Convert.ToString(dr["Contract"])); // 請負額 //TargetRow.Cells[29].Value = CheckDecimal(Convert.ToString(dr["Budgets"])); // 予算額 // Wakamatsu TargetRow.Dispose(); } Cursor.Current = Cursors.Default; // マウスカーソルを戻す }
public void EditItem(string formid) { try { this.Cursor = Cursors.WaitCursor; _action = "EDIT"; DBGrid.ContextMenuStrip.Items.Add("-"); mnuNew = DBGrid.ContextMenuStrip.Items.Add(clsTranslate.TranslateString("New"), LXMS.Properties.Resources.OK, new System.EventHandler(this.mnuAdd_Click)); mnuDelete = DBGrid.ContextMenuStrip.Items.Add(clsTranslate.TranslateString("Delete"), LXMS.Properties.Resources.Delete, new System.EventHandler(this.mnuDelete_Click)); modAccCheckForm mod = _dal.GetItem(formid, out Util.emsg); if (mod != null) { txtFormId.Text = formid; dtpFormDate.Value = mod.FormDate; txtCheckId.Text = mod.CheckId.ToString(); txtSubjectName.Text = mod.SubjectName; txtCheckNo.Text = mod.CheckNo; txtCurrency.Text = mod.Currency; txtMny.Text = mod.Mny.ToString(); txtExchangeRate.Text = mod.ExchangeRate.ToString(); txtBankName.Text = mod.BankName; txtCheckType.Text = mod.CheckType; txtRemark.Text = mod.Remark; if (mod.Status == 1) { status4.Image = Properties.Resources.audited; Util.ChangeStatus(this, true); DBGrid.ReadOnly = true; btnCheckId.Enabled = false; mnuNew.Enabled = false; mnuDelete.Enabled = false; toolSave.Enabled = false; } else { status4.Image = null; toolSave.Visible = true; Util.ChangeStatus(this, false); txtFormId.ReadOnly = true; DBGrid.ReadOnly = false; btnCheckId.Enabled = true; mnuNew.Enabled = true; mnuDelete.Enabled = true; toolSave.Enabled = true; } txtCheckId.ReadOnly = true; txtCheckNo.ReadOnly = true; txtCheckType.ReadOnly = true; txtCurrency.ReadOnly = true; txtMny.ReadOnly = true; txtExchangeRate.ReadOnly = true; txtBankName.ReadOnly = true; txtSubjectName.ReadOnly = true; DBGrid.Rows.Clear(); LoadDBGrid(); BindingCollection <modAccCheckFormDetail> list = _dal.GetDetail(formid, out Util.emsg); if (list == null && !string.IsNullOrEmpty(Util.emsg)) { MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { foreach (modAccCheckFormDetail modd in list) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(DBGrid); row.Cells[0].Value = modd.SubjectId; row.Cells[1].Value = modd.SubjectName; row.Cells[2].Value = modd.DetailId; row.Cells[3].Value = modd.DetailName; row.Cells[4].Value = modd.Currency; row.Cells[5].Value = modd.Mny.ToString(); row.Cells[6].Value = modd.ExchangeRate.ToString(); row.Cells[7].Value = modd.CheckNo; row.Cells[8].Value = modd.CheckType; row.Cells[9].Value = modd.BankName; row.Cells[10].Value = modd.PromiseDate.ToString("MM-dd-yyyy"); row.Cells[11].Value = modd.Remark; row.Height = 40; DBGrid.Rows.Add(row); row.Dispose(); } GetDetailSum(); } //DBGrid.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } finally { this.Cursor = Cursors.Default; } }