private void beliDtlDataGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e) { e.Row.Cells["qty"].Value = "0"; e.Row.Cells["harga"].Value = "0"; e.Row.Cells["discp"].Value = "0"; e.Row.Cells["disc"].Value = "0"; e.Row.Cells["total"].Value = "0"; } private void beliDtlDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { int iColumn = beliDtlDataGridView.CurrentCell.ColumnIndex; int iRow = beliDtlDataGridView.CurrentCell.RowIndex; if (iColumn == 2) { if (iRow >= 0 && !MultiSatuan) { try { beliDtlDataGridView.CurrentCell = beliDtlDataGridView.Rows[iRow].Cells[4]; SendKeys.Send("{up}"); } catch (InvalidOperationException ex) { return; } } else { try { beliDtlDataGridView.CurrentCell = beliDtlDataGridView.Rows[iRow].Cells[3]; SendKeys.Send("{up}"); } catch (InvalidOperationException ex) { return; } } } else { //new line if (iColumn == 8) { try { beliDtlDataGridView.CurrentCell = beliDtlDataGridView.Rows[iRow + 1].Cells[0]; } catch (InvalidOperationException ex) { return; } } else { SendKeys.Send("{up}"); SendKeys.Send("{right}"); } } Hitung(); } private void Hitung() { if (beliDtlDataGridView.Rows.Count > 1) { var result2 = beliDtlDataGridView.Rows.Cast<DataGridViewRow>() .Where(r => r.Cells["total"].Value != null) .Sum(r => Double.Parse(r.Cells["total"].Value.ToString())); this.grandTextBox.Text = string.Format("{0:N00}", result2.ToString()); this.discTextBox.Text = (Convert.ToDecimal(MyTools.IsNull(this.discpTextBox.Text)) * Convert.ToDecimal(result2.ToString()) / 100).ToString(); this.dppTextBox.Text = (Convert.ToDecimal(result2.ToString()) - Convert.ToDecimal(MyTools.IsNull(discTextBox.Text))).ToString(); this.pPnTextBox.Text = (Convert.ToDecimal(MyTools.IsNull(dppTextBox.Text)) / 10).ToString(); this.totalTextBox.Text = (Convert.ToDecimal(MyTools.IsNull(dppTextBox.Text)) + Convert.ToDecimal(MyTools.IsNull(pPnTextBox.Text))).ToString(); } else { this.grandTextBox.Text = "0"; this.discTextBox.Text = "0"; this.dppTextBox.Text = "0"; this.pPnTextBox.Text = "0"; this.totalTextBox.Text = "0"; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)