public bool UpdateOsWkDetail(OsWkDetailData wdd) { using (TransactionScope tran = new TransactionScope()) using (SqlConnection conn = new SqlConnection(ConnectionString)) { try { conn.Open(); SqlCommand cmd = new SqlCommand(updSql, conn); cmd = addCmdPara(cmd); cmd = addValue(cmd, wdd); if (TryExecute(conn, cmd) < 0) { return(false); } } catch (SqlException sqle) { MessageBox.Show("SQLエラー errorno " + Convert.ToString(sqle.Number) + " " + sqle.Message); conn.Close(); return(false); } conn.Close(); tran.Complete(); } return(true); }
//--------------------------------------------------------// // Method //--------------------------------------------------------// public object Clone() { OsWkDetailData cloneData = new OsWkDetailData(); cloneData.OsWkDetailID = this.OsWkDetailID; cloneData.PartnerCode = this.PartnerCode; cloneData.TaskCode = this.TaskCode; cloneData.ReportDate = this.ReportDate; cloneData.ItemCode = this.ItemCode; cloneData.Item = this.Item; cloneData.ItemDetail = this.ItemDetail; cloneData.Range = this.Range; cloneData.Quantity = this.Quantity; cloneData.Unit = this.Unit; cloneData.Cost = this.Cost; cloneData.Subject = this.Subject; cloneData.OsWkReportID = this.OsWkReportID; cloneData.LNo = this.LNo; cloneData.PNo = this.PNo; cloneData.SlipNo = this.SlipNo; cloneData.RecType = this.RecType; cloneData.CostReportID = this.CostReportID; return(cloneData); }
public bool UpdatePartOsWkDetail(int slipNo, int costReportID, decimal qty, decimal cost) { OsWkDetailData wdd = loadOsWkDetail(slipNo, costReportID); wdd.Quantity = qty; wdd.Cost = cost; return(UpdateOsWkDetail(wdd)); }
private OsWkDetailData loadOsWkDetail(int slipNo, int costReportID) { SqlHandling sh = new SqlHandling("D_OsWkDetail"); DataTable dt = sh.SelectAllData("WHERE SlipNo = " + slipNo + " AND CostReportID = " + costReportID); if (dt == null || dt.Rows.Count < 1) { return(null); } OsWkDetailData wdd = new OsWkDetailData(dt.Rows[0]); return(wdd); }
public bool StoreOsWkReportAndDetail(OsWkDetailData[] wdtl) { crd = new CostReportData(); using (TransactionScope tran = new TransactionScope()) using (SqlConnection conn = new SqlConnection(ConnectionString)) { try { conn.Open(); SqlCommand cmd = new SqlCommand(insSql + seliDSql, conn); cmd = addParaRep(cmd); cmd = addValueRep(cmd); if ((OsWkReportID = TryExScalar(conn, cmd)) < 0) { return(false); } cmd = new SqlCommand(OsWkDetailData.sqlInsDtl, conn); cmd = OsWkDetailData.addCmdPara(cmd); for (int i = 0; i < wdtl.Length; i++) { wdtl[i].OsWkReportID = OsWkReportID; cmd = OsWkDetailData.addValue(cmd, wdtl[i]); if (TryExecute(conn, cmd) < 0) { return(false); } } } catch (SqlException sqle) { MessageBox.Show("SQLエラー errorno " + Convert.ToString(sqle.Number) + " " + sqle.Message); conn.Close(); return(false); } conn.Close(); tran.Complete(); } return(true); }
public static SqlCommand addValue(SqlCommand cmd, OsWkDetailData wdtl) { cmd.Parameters["@pCod"].Value = wdtl.PartnerCode; cmd.Parameters["@tCod"].Value = wdtl.TaskCode; cmd.Parameters["@rDat"].Value = wdtl.ReportDate; cmd.Parameters["@iCod"].Value = wdtl.ItemCode; cmd.Parameters["@item"].Value = wdtl.Item; cmd.Parameters["@iDtl"].Value = wdtl.ItemDetail; cmd.Parameters["@rang"].Value = wdtl.Range; cmd.Parameters["@qty"].Value = wdtl.Quantity; cmd.Parameters["@unit"].Value = wdtl.Unit; cmd.Parameters["@cost"].Value = wdtl.Cost; cmd.Parameters["@subj"].Value = wdtl.Subject; cmd.Parameters["@oRID"].Value = wdtl.OsWkReportID; cmd.Parameters["@lNo"].Value = wdtl.LNo; cmd.Parameters["@pNo"].Value = wdtl.PNo; cmd.Parameters["@slip"].Value = wdtl.SlipNo; cmd.Parameters["@rTyp"].Value = wdtl.RecType; cmd.Parameters["@cRID"].Value = wdtl.CostReportID; return(cmd); }
private void editCostReportData(OsWkDetailData wdtl) { TaskCode = wdtl.TaskCode; OfficeCode = wdtl.OfficeCode; Department = wdtl.Department; ReportDate = wdtl.ReportDate; ItemCode = wdtl.ItemCode; Item = wdtl.Item; UnitPrice = wdtl.Cost; Quantity = wdtl.Quantity; Cost = (wdtl.Cost == 0) ? 0 : wdtl.Quantity * wdtl.Cost; Unit = (wdtl.Unit == null) ? "":wdtl.Unit; SalesMCode = wdtl.SalesMCode; CustoCode = wdtl.CustoCode; SubCoCode = wdtl.PartnerCode; Subject = wdtl.Subject; MemberCode = wdtl.LeaderMCode; LeaderMCode = wdtl.LeaderMCode; AccountCode = "OSWR"; Note = ""; CoTaskCode = wdtl.CoTaskCode; Publisher = wdtl.OfficeCode + wdtl.Department; }