//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 bool loadOsResultsContData(OsResultsData ord) { if (ord.OsResultsID == 0) { return(false); } //対象となる「項目」(Item)を抽出 BillingOp blo = new BillingOp(); //string sqlStr = "DISTINCT Item,* FROM D_OsResultsCont WHERE OsResultsID = " + Convert.ToString(ord.OsResultsID) ; string sqlStr = "* FROM D_OsResultsCont WHERE OsResultsID = " + Convert.ToString(ord.OsResultsID) + " AND RecordedDate = '" + ord.RecordedDate + "' AND Subject = '*'"; DataTable dt = blo.UsingSqlstring_Select(sqlStr); if (dt == null) { return(false); } if (dt.Rows.Count > iniRCnt) { dataGridView1.Rows.Add(dt.Rows.Count - iniRCnt); // GridView行不足分追加 } DataRow dr; itemsArray = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; //viewOsResultsContToDgv(ord.OsResultsID, Convert.ToString(dr["Item"]), dataGridView1.Rows[i]); viewOsResultsContToDgv(ord, Convert.ToString(dr["Item"]), dataGridView1.Rows[i]); } return(true); }
private bool loadAccountContData(AccountData acnd) { if (acnd.AccountID == 0) { return(false); } BillingOp blo = new BillingOp(); string wParam = " WHERE AccountID = " + acnd.AccountID + " ORDER BY LNo"; DataTable dt = blo.UsingParamater_Select("D_AccountCont", wParam); if (dt == null) { return(false); } readyDgv(dt.Rows.Count); DataRow dr; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; viewAccountContToDgv(dr, dataGridView1.Rows[i]); } return(true); }
// 既存データの読取表示 private bool loadExistingOsResultsData() { if (ted.TaskCode == null) { return(false); } // 選択された業務でその部署のデータすべてを処理対象とする。 BillingOp blo = new BillingOp(); //string wParam = " WHERE TaskCode = '" + ted.TaskCode +"'" // + " AND OfficeCode = '" + ted.OfficeCode + "' AND Department = '" + ted.Department + "'" // + " AND ContractForm = 0"; string wParam = " WHERE TaskEntryID = " + ted.TaskEntryID + " AND ContractForm = 0"; DataTable dt = blo.UsingParamater_Select("D_OsResults", wParam); if (dt == null) { return(false); } if (!(dt.Rows.Count > 0)) { return(false); } ord = new OsResultsData[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { ord[i] = new OsResultsData(dt.Rows[i]); } return(true); }
private void updateOsResultsContData(DataGridView dgvL, DataGridView dgvR, OsResultsData ord) { BillingOp blo = new BillingOp(); if (blo.DeleteOsResultsCont(ord.OsResultsID)) { blo.InsertOsResultsCont(dataGridViewL, dataGridViewR, ord); } }
private void loadOutsourceData(int idx) { // 下請け業者コードがある状態では、その外注内訳書データのみ得る。 // ない状態では、そのタスクエントリ、部署の外注内訳書データ全件を得る。 string wParam = " WHERE TaskEntryID = " + ted.TaskEntryID + " AND OfficeCode = '" + Convert.ToString(comboBoxOffice.SelectedValue) + "'" + " AND Department = '" + Convert.ToString(comboBoxWork.SelectedValue) + "'"; BillingOp blo = new BillingOp(); DataTable dt; if (ord != null && ord[idx].PartnerCode != null) { wParam += " AND PartnerCode = '" + ord[idx].PartnerCode + "'"; } if ((dt = blo.UsingParamater_Select("D_Outsource", wParam)) == null) { return; } osd = new OutsourceData[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { osd[i] = new OutsourceData(dt.Rows[i]); } if (ord == null) { ord = new OsResultsData[osd.Length]; for (int i = 0; i < osd.Length; i++) { ord[i] = new OsResultsData(); storeOutsourceToOsResultsData(osd[i], i); } } blo = new BillingOp(); wParam = " WHERE OutsourceID = " + osd[0].OutsourceID; dt = blo.UsingParamater_Select("D_OutsourceCont", wParam); dataGridView1.Rows.Clear(); dataGridView1.Rows.Add(iniRCnt); if (dt.Rows.Count > iniRCnt) { dataGridView1.Rows.Add(dt.Rows.Count - iniRCnt); } if (!viewOutsourceContToDgv(dt, dataGridView1, osd[0].PartnerCode)) { return; } reCalculateAll(dataGridView1); return; }
private void loadEstimateData() { BillingOp blo = new BillingOp(); string wParam = "WHERE TaskEntryID = " + Convert.ToString(ted.TaskEntryID) + " ORDER BY VersionNo DESC"; DataTable dt = blo.UsingParamater_Select("D_Estimate", wParam); if (dt == null) { DMessage.SelectInvalid(); return; } DataRow dr = dt.Rows[0]; EstimateData estd = new EstimateData(dr); blo = new BillingOp(); wParam = " WHERE EstimateID = " + Convert.ToString(estd.EstimateID); dt = blo.UsingParamater_Select("D_EstimateCont", wParam); if (dt == null) { DMessage.SelectInvalid(); return; } edit_Labels(); readyDgv(dt.Rows.Count); for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; dataGridView1.Rows[i].Cells["ItemCode"].Value = Convert.ToString(dr["ItemCode"]); dataGridView1.Rows[i].Cells["Item"].Value = Convert.ToString(dr["Item"]); dataGridView1.Rows[i].Cells["ItemDetail"].Value = Convert.ToString(dr["ItemDetail"]); dataGridView1.Rows[i].Cells["Unit"].Value = Convert.ToString(dr["Unit"]); if (Convert.ToString(dr["Unit"]) != "") { dataGridView1.Rows[i].Cells["CQuantity"].Value = decPointFormat(Convert.ToDecimal(dr["Quantity"])); dataGridView1.Rows[i].Cells["CCost"].Value = decFormat(Convert.ToDecimal(dr["Cost"])); dataGridView1.Rows[i].Cells["CAmount"].Value = decFormat(Convert.ToDecimal(dr["Cost"]) * Convert.ToDecimal(dr["Quantity"])); dataGridView1.Rows[i].Cells["Quantity"].Value = dataGridView1.Rows[i].Cells["CQuantity"].Value; dataGridView1.Rows[i].Cells["Amount"].Value = dataGridView1.Rows[i].Cells["CAmount"].Value; } } reCalculateAll(); return; }
private bool loadOsResultsSumData(OsResultsData ord) { if (ord.OsResultsID == 0) { return(false); } BillingOp blo = new BillingOp(); string wParam = " WHERE OsResultsID = " + Convert.ToString(ord.OsResultsID) + " AND RecordedDate = '" + (dateTimePickerRecDate.Value).EndOfMonth() + "' ORDER BY Subject"; DataTable dt = blo.UsingParamater_Select("D_OsResultsSum", wParam); if (dt == null) { return(false); } viewOsResultsSumToDgv(dt, dataGridViewT); 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"]); } }
// Load Existing Data 既存データの読取表示 private bool loadExistingAccountData() { string wParam = " WHERE "; wParam += (string.IsNullOrEmpty(ted.TaskCode.Trim())) ? " TaskEntryID = " + ted.TaskEntryID : " TaskCode = '" + ted.TaskCode + "'"; wParam += " AND InvoiceType = 1"; BillingOp blo = new BillingOp(); DataTable dt = blo.UsingParamater_Select("D_Account", wParam); if (dt == null) { return(false); } acnd = new AccountData[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { acnd[i] = new AccountData(dt.Rows[i]); } return(true); }
private void viewAccountContSumToDgv(DataRow idr, DataGridViewRow dgvRow) { string sqlStr = " SUM( ISNULL(Quantity,0) ) AS SQty,SUM( ISNULL(Amount,0) ) AS SAmt FROM D_AccountCont WHERE " + " AccountID = " + Convert.ToString(idr["AccountID"]) + " AND ItemCode = '" + Convert.ToString(idr["ItemCode"]) + "'" + " AND Item = '" + Convert.ToString(idr["Item"]) + "'" + " AND ItemDetail = '" + Convert.ToString(idr["ItemDetail"]) + "'" + " AND RecordedDate < '" + Convert.ToDateTime(idr["RecordedDate"]) + "'"; BillingOp blo = new BillingOp(); DataTable dt = blo.UsingSqlstring_Select(sqlStr); if (dt == null) { return; } DataRow dr = dt.Rows[0]; dgvRow.Cells["SQuantity"].Value = string.IsNullOrEmpty(Convert.ToString(dr["SQty"])) ? "0" : decPointFormat(Convert.ToDecimal(dr["SQty"])); dgvRow.Cells["SAmount"].Value = string.IsNullOrEmpty(Convert.ToString(dr["SAmt"])) ? "0" : decPointFormat(Convert.ToDecimal(dr["SAmt"])); }
private bool loadOsResultsContData(OsResultsData ord) { if (ord.OsResultsID == 0) { return(false); } BillingOp blo = new BillingOp(); string wParam = " WHERE OsResultsID = " + Convert.ToString(ord.OsResultsID) + " AND RecordedDate = '" + (dateTimePickerRecDate.Value).EndOfMonth() + "' ORDER BY PublishDate"; DataTable dt = blo.UsingParamater_Select("D_OsResultsCont", wParam); if (dt == null) { return(false); } int didx; DataRow dr; for (int i = 0; i < dt.Rows.Count; i++) { dr = dt.Rows[i]; DateTime pdt = DHandling.StripTime(Convert.ToDateTime(dr["PublishDate"])); didx = Convert.ToInt32(pdt.Day) - 1; if (didx > 15) { viewOsResultsContToDgv(dr, dataGridViewR.Rows[didx - 16], "R"); } else { viewOsResultsContToDgv(dr, dataGridViewL.Rows[didx], "L"); } } return(true); }
private void button_Click(object sender, EventArgs e) { nowMonth(); if (iniPro) { return; } Button btn = (Button)sender; BillingOp blo = new BillingOp(); switch (btn.Name) { case "buttonFromOutsource": Func <DialogResult> dialogNewLoad = DMessage.DialogNewLoad; if (dialogNewLoad() == DialogResult.No) { return; } loadOutsourceData(cpg); buttonFromOutsource.Enabled = false; labelMsg.Text = "外注内訳データを取り込みました。"; break; case "buttonPrevData": if (cpg > 0) { cpg--; viewData(cpg); } break; case "buttonNextData": if (cpg != (ord.Length - 1)) { cpg++; viewData(cpg); } break; case "buttonCopyAndNext": clearOsResultsContAmount(dataGridView1); OsResultsData[] newOrd = new OsResultsData[ord.Length + 1]; Array.Copy(ord, newOrd, Math.Min(ord.Length, newOrd.Length)); newOrd[newOrd.Length - 1] = (OsResultsData)ord[cpg].Clone(); newOrd[newOrd.Length - 1].OsResultsID = 0; DateTime wkdt = newOrd[newOrd.Length - 1].RecordedDate.AddMonths(1); newOrd[newOrd.Length - 1].RecordedDate = wkdt; ord = newOrd; dateTimePickerRecordedDate.Value = wkdt.EndOfMonth(); nowMonth(wkdt); buttonGrpDisabled(); buttonPrevData.Enabled = true; buttonNew.Enabled = true; cpg++; break; case "buttonClose": this.Close(); break; case "buttonReCalc": reCalculateAll(dataGridView1); break; case "buttonOverWrite": Func <DialogResult> dialogOverWrite = DMessage.DialogOverWrite; if (dialogOverWrite() == DialogResult.No) { return; } storeDateToOsResultsData(ord[cpg]); blo.UpdateOsResults(ord[cpg]); blo.DeleteAndInsertOsResultsCont(dataGridView1, ord[cpg]); labelMsg.Text = "上書しました。"; break; case "buttonNew": if (ord == null || ord[cpg].OsResultsID < 1) { if (ord == null) { ord = new OsResultsData[1]; cpg = 0; } editOsResultsData(cpg); ord[cpg].OsResultsID = blo.InsertOsResults(ord[cpg]); if (ord[cpg].OsResultsID < 1) { labelMsg.Text = "新規書込みできませんでした。"; return; } } storeDateToOsResultsData(ord[cpg]); blo.InsertOsResultsCont(dataGridView1, ord[cpg]); initialViewSetting(cpg); labelMsg.Text = "新規書込みしました。"; break; case "buttonDelete": Func <DialogResult> dialogDelete = DMessage.DialogDelete; if (dialogDelete() == DialogResult.No) { return; } blo.DeleteOsResultsCont(ord[cpg].OsResultsID); blo.DeleteOsResults(ord[cpg].OsResultsID); cpg--; initialViewSetting(cpg); labelMsg.Text = "削除しました。"; break; case "buttonCancel": Func <DialogResult> dialogCancel = DMessage.DialogCancel; if (dialogCancel() == DialogResult.No) { return; } dataGridView1.Rows.Clear(); dataGridView1.Rows.Add(iniRCnt); break; case "buttonPrint": createExcelFile("外注清算書(請負).xlsx", "OsAContract"); break; default: break; } }
private void button_Click(object sender, EventArgs e) { if (iniPro) { return; } Button btn = ( Button )sender; BillingOp blo = new BillingOp(); switch (btn.Name) { case "buttonFromEstimate": Func <DialogResult> dialogNewLoad = DMessage.DialogNewLoad; if (dialogNewLoad() == DialogResult.No) { return; } loadEstimateData(); labelMsg.Text = "見積書データを取り込みました。"; break; case "buttonPrevData": if (cpg != 0) { cpg--; viewData(cpg); } break; case "buttonNextData": if (cpg != (acnd.Length - 1)) { cpg++; viewData(cpg); } break; case "buttonCopyAndNext": clearAccountContDataView(); AccountData[] newAcnd = new AccountData[acnd.Length + 1]; Array.Copy(acnd, newAcnd, Math.Min(acnd.Length, newAcnd.Length)); newAcnd[newAcnd.Length - 1] = ( AccountData )acnd[cpg].Clone(); //newAcnd[newAcnd.Length - 1].AccountID = 0; acnd = newAcnd; buttonGrpDisabled(); buttonPrevData.Enabled = true; buttonNew.Enabled = true; cpg++; acnd[cpg].RecordedDate = dateTimePickerRecordedDate.Value.AddMonths(1); dateTimePickerRecordedDate.Value = acnd[cpg].RecordedDate; break; case "buttonReCalc": reCalculateAll(); labelMsg.Text = "再計算しました。"; break; case "buttonOverWrite": Func <DialogResult> dialogOverWrite = DMessage.DialogOverWrite; if (dialogOverWrite() == DialogResult.No) { return; } editAccountData(acnd[cpg], cpg); blo.Account_Update(acnd[cpg]); blo.AccountCont_Update(dataGridView1, acnd[cpg]); labelMsg.Text = "上書しました。"; break; case "buttonNew": if (acnd == null) { acnd = new AccountData[1]; cpg = 0; acnd[cpg] = new AccountData(); } editAccountData(acnd[cpg], cpg); acnd[cpg].AccountID = blo.Account_Insert(acnd[cpg]); if (acnd[cpg].AccountID < 1) { return; } if (!blo.AccountCont_Insert(dataGridView1, acnd[cpg])) { return; } initialProcessing(cpg); labelMsg.Text = "新規に書込みました。"; break; case "buttonDelete": Func <DialogResult> dialogDelete = DMessage.DialogDelete; if (dialogDelete() == DialogResult.No) { return; } //blo.AccountCont_Delete( acnd[cpg] ); blo.AccountCont_Delete(acnd[cpg].AccountID); blo.Account_Delete(acnd[cpg].AccountID); if (acnd.Length > 1) { if (cpg == (acnd.Length - 1)) { cpg--; } } initialProcessing(cpg); labelMsg.Text = "削除しました。"; break; case "buttonCancel": Func <DialogResult> dialogCancel = DMessage.DialogCancel; if (dialogCancel() == DialogResult.No) { return; } viewData(cpg); break; case "buttonPrint": CreateExcelFile(ted, dataGridView1, "請求書.xlsx", "Invoice"); break; case "buttonClose": this.Close(); break; default: break; } }
private void button_Click(object sender, EventArgs e) { if (iniPro) { return; } Button btn = ( Button )sender; BillingOp blo = new BillingOp(); switch (btn.Name) { case "buttonPrevData": if (cpg != 0) { cpg--; viewData(cpg); } break; case "buttonNextData": if (ord == null) { return; } if (cpg != (ord.Length - 1)) { cpg++; viewData(cpg); } break; case "buttonCopyAndNext": clearOsResultsContView(dataGridViewL, "L"); clearOsResultsContView(dataGridViewR, "R"); OsResultsData[] newOrd = new OsResultsData[ord.Length + 1]; Array.Copy(ord, newOrd, Math.Min(ord.Length, newOrd.Length)); newOrd[newOrd.Length - 1] = ( OsResultsData )ord[cpg].Clone(); newOrd[newOrd.Length - 1].OsResultsID = 0; ord = newOrd; buttonGrpDisabled(); buttonPrevData.Enabled = true; buttonNew.Enabled = true; cpg++; break; case "buttonReCalc": reCalculateAll(dataGridViewL, dataGridViewR, dataGridViewT); break; case "buttonOverWrite": Func <DialogResult> dialogOverWrite = DMessage.DialogOverWrite; if (dialogOverWrite() == DialogResult.No) { return; } if (string.IsNullOrEmpty(textBoxSubCo.Text)) { MessageBox.Show(noSubCo); return; } blo.UpdateOsResults(ord[cpg]); updateOsResultsContData(dataGridViewL, dataGridViewR, ord[cpg]); blo.UpdateOsResultsSum(dataGridViewT, ord[cpg]); labelMsg.Text = "上書しました。"; break; case "buttonNew": if (string.IsNullOrEmpty(textBoxSubCo.Text)) { MessageBox.Show(noSubCo); return; } if (ord == null || ord[cpg].OsResultsID < 1) { if (ord == null) { ord = new OsResultsData[1]; cpg = 0; ord[cpg] = new OsResultsData(); } storeViewToOsResultsData(ord[cpg]); ord[cpg].OsResultsID = blo.InsertOsResults(ord[cpg]); if (ord[cpg].OsResultsID < 1) { labelMsg.Text = "新規書込みできませんでした。"; return; } } if (!blo.InsertOsResultsCont(dataGridViewL, dataGridViewR, ord[cpg])) { return; } if (!blo.InsertOsResultsSum(dataGridViewT, ord[cpg])) { return; } initialViewSetting(cpg); labelMsg.Text = "新規書込みしました。"; break; case "buttonDelete": Func <DialogResult> dialogDelete = DMessage.DialogDelete; if (dialogDelete() == DialogResult.No) { return; } blo.DeleteOsResultsCont(ord[cpg].OsResultsID); blo.DeleteOsResults(ord[cpg].OsResultsID); cpg--; initialViewSetting(cpg); labelMsg.Text = "削除しました。"; break; case "buttonCancel": Func <DialogResult> dialogCancel = DMessage.DialogCancel; if (dialogCancel() == DialogResult.No) { return; } readyDataGridView(dataGridViewL, dataGridViewR, dataGridViewT); break; case "buttonPrint": CreateExcelFile("外注清算書(常傭).xlsx", "OsARegular"); break; case "buttonClose": this.Close(); break; default: break; } }