private bool viewOutsourceContToDgv(DataTable dt, DataGridView dgv, string partnerCode) { PartnersData pd = new PartnersData(); labelPartner.Text = pd.SelectPartnerName(partnerCode); DataRow dr; decimal sum = 0; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; sum += Convert.ToDecimal(dr["Quantity"]); // 各月の数量の和 = 前月累計 dgv.Rows[i].Cells["ItemCode"].Value = Convert.ToString(dr["ItemCode"]); dgv.Rows[i].Cells["Item"].Value = Convert.ToString(dr["Item"]); if (Convert.ToString(dr["Item"]) == null || Convert.ToString(dr["Item"]) == "") { dgv.Rows[i].Cells["Item"].Value = Convert.ToString(dr["ItemDetail"]); } dgv.Rows[i].Cells["PQuantity"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Quantity"]), "0.00"); dgv.Rows[i].Cells["Unit"].Value = Convert.ToString(dr["Unit"]); dgv.Rows[i].Cells["Cost"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Cost"]), "#,0"); dgv.Rows[i].Cells["PAmount"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Quantity"]) * Convert.ToDecimal(dr["Cost"]), "#,0"); dgv.Rows[i].Cells["ContID"].Value = 0; } return(true); }
private void verticalCalc(DataGridView dgv) { Calculation calc = new Calculation(ted); calc.VCalcOutsource(dgv); labelSum.Text = DHandling.DecimaltoStr(calc.Sum, "#,0"); }
//private void viewLastMonthOsResultsContToDgv(int osResultsID, string item, DataGridViewRow dgvRow) //{ // // 過去データ // string wParam = " WHERE OsResultsID = " + Convert.ToString(osResultsID) // + " AND RecordedDate < '" + Convert.ToDateTime((dateTimePickerRecordedDate.Value).EndOfMonth()) // + "' AND Item = '" + item + "'"; // BillingOp blo = new BillingOp(); // DataTable dt = blo.UsingParamater_Select("D_OsResultsCont", wParam); // if (dt == null) return; // DataRow dr; // decimal sum = 0; // for (int i = 0; i < dt.Rows.Count; i++) // { // dr = dt.Rows[i]; // sum += Convert.ToDecimal(dr["Quantity"]); // 各月の数量の和 = 前月累計 // } // dr = dt.Rows[0]; // viewOsResultsContItemToDgv(dgvRow, dr); // dgvRow.Cells["LQuantity"].Value = DHandling.DecimaltoStr(sum, "0.00"); // dgvRow.Cells["LAmount"].Value = DHandling.DecimaltoStr(sum * Convert.ToDecimal(dr["Cost"]), "0.00"); // dgvRow.Cells["ContID"].Value = 0; //} private void viewLastMonthOsResultsContToDgv(OsResultsData ord, string item, DataGridViewRow dgvRow) { // 過去データ string wParam = " WHERE TaskEntryID = " + ord.TaskEntryID + " AND PartnerCode = '" + ord.PartnerCode + "' " + "AND RecordedDate < '" + ord.RecordedDate + "' AND Item = '" + item + "' AND Subject = '*'"; BillingOp blo = new BillingOp(); DataTable dt = blo.UsingParamater_Select("D_OsResultsCont", wParam); if (dt == null) { return; } DataRow dr; decimal sum = 0; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; sum += Convert.ToDecimal(dr["Quantity"]); // 各月の数量の和 = 前月累計 } dr = dt.Rows[0]; viewOsResultsContItemToDgv(dgvRow, dr); dgvRow.Cells["LQuantity"].Value = DHandling.DecimaltoStr(sum, "0.00"); dgvRow.Cells["LAmount"].Value = DHandling.DecimaltoStr(sum * Convert.ToDecimal(dr["Cost"]), "#,0"); dgvRow.Cells["ContID"].Value = 0; }
private void viewOutsourceData(int idx) { comboBoxOffice.SelectedValue = osd[idx].OfficeCode; comboBoxWork.SelectedValue = osd[idx].Department; labelOrderNo.Text = osd[idx].OrderNo; comboBoxPartner.SelectedValue = osd[idx].PartnerCode; comboBoxPayRoule.SelectedValue = osd[idx].PayRoule; labelSum.Text = DHandling.DecimaltoStr(osd[idx].Amount, "#,0"); if (DHandling.CheckDate(osd[idx].OrderDate)) { dateTimePickerOrderDate.Value = osd[idx].OrderDate; } if (DHandling.CheckDate(osd[idx].StartDate)) { dateTimePickerOStart.Value = osd[idx].StartDate; } if (DHandling.CheckDate(osd[idx].EndDate)) { dateTimePickerOEnd.Value = osd[idx].EndDate; } if (DHandling.CheckDate(osd[idx].InspectDate)) { dateTimePickerInspectDate.Value = osd[idx].InspectDate; } if (DHandling.CheckDate(osd[idx].ReceiptDate)) { dateTimePickerReceiptDate.Value = osd[idx].ReceiptDate; } textBoxDeliveryPoint.Text = osd[idx].Place; textBoxNote.Text = osd[idx].Note; }
private void FormCostList_Load(object sender, EventArgs e) { UiHandling ui = new UiHandling(dataGridView1); ui.DgvReadyNoRHeader(); // 列幅設定、入力不可設定 for (int i = 0; i < dataGridView1.ColumnCount; i++) { dataGridView1.Columns[i].ReadOnly = true; } //if (cmd.GetLength(0) > 1) dataGridView1.Rows.Add(cmd.GetLength(0) - 1); if (cmd.Length > 1) { dataGridView1.Rows.Add(cmd.Length - 1); } //for (int i = 0; i < cmd.GetLength(0); i++) for (int i = 0; i < cmd.Length; i++) { dataGridView1.Rows[i].Cells[0].Value = cmd[i].CostCode; dataGridView1.Rows[i].Cells[1].Value = cmd[i].Item.Replace("(支払い)", ""); dataGridView1.Rows[i].Cells[2].Value = cmd[i].ItemDetail; dataGridView1.Rows[i].Cells[3].Value = cmd[i].Unit; dataGridView1.Rows[i].Cells[4].Value = (cmd[i].Cost == 0) ? "": DHandling.DecimaltoStr(cmd[i].Cost, "0.00"); dataGridView1.Rows[i].Cells[5].Value = cmd[i].CostID; } }
private void viewOsResultsContItemToDgv(DataGridViewRow dgvRow, DataRow dr) { dgvRow.Cells["ItemCode"].Value = Convert.ToString(dr["ItemCode"]); dgvRow.Cells["Item"].Value = Convert.ToString(dr["Item"]); dgvRow.Cells["PQuantity"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["PQuantity"]), "0.00"); dgvRow.Cells["Unit"].Value = Convert.ToString(dr["Unit"]); dgvRow.Cells["Cost"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Cost"]), "#,0"); dgvRow.Cells["PAmount"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["PQuantity"]) * Convert.ToDecimal(dr["Cost"]), "#,0"); }
// DataGridViewの全体計算(横計算&縦計算) private bool reCalculateAll(DataGridView dgvL, DataGridView dgvR, DataGridView dgvT) { if (!checkInputContData(dgvL)) { return(false); } decimal[] qty = new decimal[subjCnt]; for (int i = 0; i < dgvL.RowCount; i++) { for (int j = 0; j < subjCnt; j++) { if (dgvL.Rows[i].Cells["QuantityL" + j.ToString()].Value != null) { qty[j] += DHandling.ToRegDecimal(Convert.ToString(dgvL.Rows[i].Cells["QuantityL" + j.ToString()].Value)); } } } for (int i = 0; i < dgvR.RowCount; i++) { for (int j = 0; j < subjCnt; j++) { if (dgvR.Rows[i].Cells["QuantityR" + j.ToString()].Value != null) { qty[j] += DHandling.ToRegDecimal(Convert.ToString(dgvR.Rows[i].Cells["QuantityR" + j.ToString()].Value)); } } } this.labelSum = new Label[] { this.labelSumQty0, this.labelSumQty1, this.labelSumQty2, this.labelSumQty3, this.labelSumQty4, this.labelSumQty5 }; for (int j = 0; j < subjCnt; j++) { labelSum[j].Text = DHandling.DecimaltoStr(qty[j], "0.00"); dgvT.Rows[j].Cells["Quantity"].Value = DHandling.DecimaltoStr(qty[j], "0.00"); } if (!checkInputSumData(dgvT)) { return(false); } decimal cost; for (int i = 0; i < subjCnt; i++) { if (dgvT.Rows[i].Cells["Cost"].Value != null) { cost = DHandling.ToRegDecimal(Convert.ToString(dgvT.Rows[i].Cells["Cost"].Value)); dgvT.Rows[i].Cells["Amount"].Value = DHandling.DecimaltoStr(cost * qty[i], "0.00"); } } return(true); }
// View Data private void viewOsResultsContToDgv(DataRow dr, DataGridViewRow dgvRow, string pos) { DateTime pdt = (Convert.ToDateTime(dr["PublishDate"])).StripTime(); dgvRow.Cells["ItemCode" + pos].Value = Convert.ToString(dr["ItemCode"]); dgvRow.Cells["Item" + pos].Value = Convert.ToString(dr["Item"]); int subNo = Convert.ToInt32(dr["Subject"]); dgvRow.Cells["Quantity" + pos + subNo.ToString()].Value = (Convert.ToDecimal(dr["Quantity"]) == 0) ? "" : DHandling.DecimaltoStr(Convert.ToDecimal(dr["Quantity"]), "0.00"); dgvRow.Cells["PublishDate" + pos].Value = Convert.ToString(Convert.ToDateTime(dr["PublishDate"])); }
private bool viewOutsourceContToDgv(DataTable dt, DataGridView dgv) { if (dt == null) { return(false); } DataRow dr; decimal qty = 0; decimal cost = 0; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; dgv.Rows[i].Cells["ItemCode"].Value = Convert.ToString(dr["ItemCode"]); dgv.Rows[i].Cells["Item"].Value = Convert.ToString(dr["Item"]); dgv.Rows[i].Cells["ItemDetail"].Value = Convert.ToString(dr["ItemDetail"]); if (plnd == null || plnd.PlanningID == 0) { if (Convert.ToDecimal(dr["Cost"]) == 0) { qty = 0; } cost = Convert.ToDecimal(dr["Cost"]); } else { if (Convert.ToDecimal(dr["Cost1"]) == 0) { qty = 0; } cost = Convert.ToDecimal(dr["Cost1"]); } if (cost != 0) { qty = Convert.ToDecimal(dr["Quantity"]); } if (Convert.ToString(dr["Unit"]) != "") { dgv.Rows[i].Cells["Quantity"].Value = qty; dgv.Rows[i].Cells["Unit"].Value = Convert.ToString(dr["Unit"]); dgv.Rows[i].Cells["Cost"].Value = DHandling.DecimaltoStr(cost, "#,0"); dgv.Rows[i].Cells["Amount"].Value = DHandling.DecimaltoStr(qty * cost, "#,0"); } } return(true); }
//private void viewThisMonthOsResultsContToDgv(int osResultsID, string item, DataGridViewRow dgvRow) //{ // // 当月データ // string wParam = " WHERE OsResultsID = " + Convert.ToString(osResultsID) // + " AND RecordedDate = '" + Convert.ToDateTime((dateTimePickerRecordedDate.Value).EndOfMonth()) // + "' AND Item = '" + item + "'"; // BillingOp blo = new BillingOp(); // DataTable dt = blo.UsingParamater_Select("D_OsResultsCont", wParam); // if (dt == null) // { // dgvRow.Cells["Quantity"].Value = "0.00"; // dgvRow.Cells["ContID"].Value = 0; // } // else // { // DataRow dr = dt.Rows[0]; // viewOsResultsContItemToDgv(dgvRow, dr); // dgvRow.Cells["Quantity"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Quantity"]), "0.00"); // dgvRow.Cells["ContID"].Value = Convert.ToInt32(dr["OsResultsContID"]); // } //} private void viewThisMonthOsResultsContToDgv(OsResultsData ord, string item, DataGridViewRow dgvRow) { // 当月データ string wParam = " WHERE TaskEntryID = " + ord.TaskEntryID + " AND PartnerCode = '" + ord.PartnerCode + "' " + "AND RecordedDate = '" + ord.RecordedDate + "' AND Item = '" + item + "' AND Subject = '*'"; BillingOp blo = new BillingOp(); DataTable dt = blo.UsingParamater_Select("D_OsResultsCont", wParam); if (dt == null) { dgvRow.Cells["Quantity"].Value = "0.00"; dgvRow.Cells["ContID"].Value = 0; } else { DataRow dr = dt.Rows[0]; viewOsResultsContItemToDgv(dgvRow, dr); dgvRow.Cells["Quantity"].Value = DHandling.DecimaltoStr(Convert.ToDecimal(dr["Quantity"]), "0.00"); dgvRow.Cells["ContID"].Value = Convert.ToInt32(dr["OsResultsContID"]); } }
private void viewOsResultsSumToDgv(DataTable dt, DataGridView dgv) { DataRow dr; int rno; decimal qty; decimal cost; decimal total = 0; for (int i = 0; i < sumRCnt - 1; i++) { dr = dt.Rows[i]; rno = Convert.ToInt32(dr["Subject"]); dgv.Rows[rno].Cells["ItemDetail"].Value = Convert.ToString(dr["ItemDetail"]); qty = Convert.ToDecimal(dr["Quantity"]); dgv.Rows[rno].Cells["Quantity"].Value = DHandling.DecimaltoStr(qty, "0.00"); cost = Convert.ToDecimal(dr["Cost"]); dgv.Rows[rno].Cells["Cost"].Value = DHandling.DecimaltoStr(cost, "0.00"); dgv.Rows[rno].Cells["Amount"].Value = DHandling.DecimaltoStr(qty * cost, "#,00"); dgv.Rows[rno].Cells["Note"].Value = Convert.ToString(dr["Note"]); total += qty * cost; } dgv.Rows[sumRCnt - 1].Cells["Amount"].Value = DHandling.DecimaltoStr(total, "#,00"); }
private static string decFormat(decimal decNum) { return(DHandling.DecimaltoStr(decNum, "#,0")); }
// DataGridViewの全体計算(横計算&縦計算) private bool reCalculateAll(DataGridView dgv) { if (!checkInputData(dgv)) { return(false); } decimal cost; decimal[] qty = new decimal[5]; decimal[] amt = new decimal[5]; decimal[] vSum = new decimal[5]; int lastLine = 0; for (int i = 0; i < dgv.RowCount; i++) { if (dgv.Rows[i].Cells["Cost"].Value != null) { cost = DHandling.ToRegDecimal(Convert.ToString(dgv.Rows[i].Cells["Cost"].Value)); // 計画 qty[0] = DHandling.ToRegDecimal(Convert.ToString(dgv.Rows[i].Cells["PQuantity"].Value)); amt[0] = cost * qty[0]; dgv.Rows[i].Cells["PAmount"].Value = DHandling.DecimaltoStr(amt[0], "#,0"); // 前月累計 qty[1] = DHandling.ToRegDecimal(Convert.ToString(dgv.Rows[i].Cells["LQuantity"].Value)); amt[1] = DHandling.ToRegDecimal(Convert.ToString(dgv.Rows[i].Cells["LAmount"].Value)); // 当月出来高 qty[2] = DHandling.ToRegDecimal(Convert.ToString(dgv.Rows[i].Cells["Quantity"].Value)); amt[2] = cost * qty[2]; dgv.Rows[i].Cells["Amount"].Value = DHandling.DecimaltoStr(amt[2], "#,0"); // 当月累計 qty[3] = qty[1] + qty[2]; amt[3] = amt[1] + amt[2]; dgv.Rows[i].Cells["SQuantity"].Value = DHandling.DecimaltoStr(qty[3], "#,0.00"); dgv.Rows[i].Cells["SAmount"].Value = DHandling.DecimaltoStr(amt[3], "#,0"); // 残高 qty[4] = qty[0] - qty[3]; amt[4] = amt[0] - amt[3]; dataGridView1.Rows[i].Cells["RQuantity"].Value = DHandling.DecimaltoStr(qty[4], "#,0.00"); dataGridView1.Rows[i].Cells["RAmount"].Value = DHandling.DecimaltoStr(amt[4], "#,0"); for (int j = 0; j < vSum.Length; j++) { vSum[j] += amt[j]; } lastLine = i; } } if ((vSum[0] + vSum[1] + vSum[2] + vSum[3] + vSum[4]) == 0) { return(true); } if ((lastLine += 2) > dgv.RowCount) { dgv.Rows.Add(2); } string[] itmAry = new string[] { "PAmount", "LAmount", "Amount", "SAmount", "RAmount" }; dgv.Rows[lastLine].Cells["Item"].Value = Sign.SumTotal; for (int i = 0; i < itmAry.Length; i++) { dgv.Rows[lastLine].Cells[itmAry[i]].Value = DHandling.DecimaltoStr(vSum[i], "#,0"); } return(true); }
private static string decPointFormat(decimal decNum) { return(DHandling.DecimaltoStr(decNum, "0.00")); }
private void edit_TextBox() { textBoxTaxRate.Text = DHandling.DecimaltoStr(ted.TaxRate * 100, "0.0"); textBoxExpenses.Text = DHandling.DecimaltoStr(ted.Expenses * 100, "0.0"); }
//----------------------------------------------------------------------------// // Property // //----------------------------------------------------------------------------// //----------------------------------------------------------------------------// // Method // //----------------------------------------------------------------------------// private void FormVolumeCostDetailList_Load(object sender, EventArgs e) { UiHandling ui = new UiHandling(dataGridView1); ui.DgvReadyNoRHeader(); dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; dataGridView1.AllowUserToDeleteRows = false; // 列幅設定、入力不可設定 for (int i = 0; i < dataGridView1.ColumnCount; i++) { dataGridView1.Columns[i].ReadOnly = true; } if (crd.GetLength(0) > 1) { dataGridView1.Rows.Add(crd.GetLength(0) - 1); } //年月日 DateTime dtReportDateBefore = DateTime.MinValue; string strReportDateBefore = dtReportDateBefore.ToString("yyyy/MM/dd"); //伝票番号 string strSlipNoBefore = ""; //累計(小計) decimal decCumulative = 0; //累計(合計) decimal decTotalCumulative = 0; int intGridCnt = 0; for (int i = 0; i < crd.GetLength(0); i++) { if (intGridCnt != 0) { if (strSlipNoBefore != crd[i].SlipNo.ToString()) { dataGridView1.Rows.Add(); dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value = ""; //年月日 dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value = ""; //伝票No dataGridView1.Rows[intGridCnt].Cells["CostCode"].Value = ""; //原価コード dataGridView1.Rows[intGridCnt].Cells["Item"].Value = ""; //品名 dataGridView1.Rows[intGridCnt].Cells["Unit"].Value = ""; //単位 dataGridView1.Rows[intGridCnt].Cells["UnitPrice"].Value = ""; //単価 dataGridView1.Rows[intGridCnt].Cells["Quantity"].Value = "伝票計"; //数量 dataGridView1.Rows[intGridCnt].Cells["Cost"].Value = DHandling.DecimaltoStr(decCumulative, "#,0"); //金額(小計) decTotalCumulative = decTotalCumulative + decCumulative; dataGridView1.Rows[intGridCnt].Cells["Cumulative"].Value = DHandling.DecimaltoStr(decTotalCumulative, "#,0"); //累計 decCumulative = 0; intGridCnt++; } } if (i == crd.GetLength(0) - 1)//最後の場合、伝票計、合計の行を追加しておく { dataGridView1.Rows.Add(); dataGridView1.Rows.Add(); } dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value = ""; if (crd[i].ReportDate != null) { if (strReportDateBefore != crd[i].ReportDate.ToString("yyyy/MM/dd")) { dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value = crd[i].ReportDate.ToString("yyyy/MM/dd"); //年月日 strReportDateBefore = dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value.ToString(); } } dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value = ""; if (crd[i].SlipNo.ToString() != null && crd[i].SlipNo.ToString() != "") { if (strSlipNoBefore != crd[i].SlipNo.ToString()) { dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value = crd[i].SlipNo.ToString(); strSlipNoBefore = dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value.ToString(); } } dataGridView1.Rows[intGridCnt].Cells["CostCode"].Value = crd[i].ItemCode; //原価コード dataGridView1.Rows[intGridCnt].Cells["Item"].Value = crd[i].Item; //品名 dataGridView1.Rows[intGridCnt].Cells["Unit"].Value = crd[i].Unit; //単位 dataGridView1.Rows[intGridCnt].Cells["UnitPrice"].Value = (crd[i].UnitPrice == 0) ? "" : DHandling.DecimaltoStr(crd[i].UnitPrice, "#,0"); //単価 dataGridView1.Rows[intGridCnt].Cells["Quantity"].Value = (crd[i].Quantity == 0) ? "" : DHandling.DecimaltoStr(crd[i].Quantity, "#,0.00"); //数量 dataGridView1.Rows[intGridCnt].Cells["Cost"].Value = (crd[i].Cost == 0) ? "0" : DHandling.DecimaltoStr(crd[i].Cost, "#,0"); //金額 decCumulative = decCumulative + crd[i].Cost; dataGridView1.Rows[intGridCnt].Cells["Cumulative"].Value = "N"; intGridCnt++; } if (crd.GetLength(0) > 0) { dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value = ""; //年月日 dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value = ""; //伝票No dataGridView1.Rows[intGridCnt].Cells["CostCode"].Value = ""; //原価コード dataGridView1.Rows[intGridCnt].Cells["Item"].Value = ""; //品名 dataGridView1.Rows[intGridCnt].Cells["Unit"].Value = ""; //単位 dataGridView1.Rows[intGridCnt].Cells["UnitPrice"].Value = ""; //単価 dataGridView1.Rows[intGridCnt].Cells["Quantity"].Value = "伝票計"; //数量 dataGridView1.Rows[intGridCnt].Cells["Cost"].Value = DHandling.DecimaltoStr(decCumulative, "#,0"); //金額(小計) decTotalCumulative = decTotalCumulative + decCumulative; dataGridView1.Rows[intGridCnt].Cells["Cumulative"].Value = DHandling.DecimaltoStr(decTotalCumulative, "#,0"); //累計 decCumulative = 0; intGridCnt++; dataGridView1.Rows[intGridCnt].Cells["ReportDate"].Value = ""; //年月日 dataGridView1.Rows[intGridCnt].Cells["SlipNo"].Value = ""; //伝票No dataGridView1.Rows[intGridCnt].Cells["CostCode"].Value = ""; //原価コード dataGridView1.Rows[intGridCnt].Cells["Item"].Value = "【合計】"; //品名 dataGridView1.Rows[intGridCnt].Cells["Unit"].Value = ""; //単位 dataGridView1.Rows[intGridCnt].Cells["UnitPrice"].Value = ""; //単価 dataGridView1.Rows[intGridCnt].Cells["Quantity"].Value = ""; //数量 dataGridView1.Rows[intGridCnt].Cells["Cost"].Value = DHandling.DecimaltoStr(decTotalCumulative, "#,0"); //金額(小計) dataGridView1.Rows[intGridCnt].Cells["Cumulative"].Value = DHandling.DecimaltoStr(decTotalCumulative, "#,0"); //累計 } }