Bus project: (1) production during management

xiaoxiao2021-03-06  82

1. Add a year (12) record: After adding a button, you will automatically add 12 records on the webgrid (just displayed on the control, but there is no saving database), the generation is as follows: Private void Bind (WebGrid DG ) {If (chkadd.checked == false) {dataset dstmp = new dataset (); if (! Dstmp.tables.contains ("webgrid") {dstmp.tables.add (SqlDst.Tables ["WebGrid"]. Clone ());} wgridtmp.datasource = dstmp;} DG.DataSource = Sqldst; Dg.DataMember = "WebGrid"; Dg.Database ();} private void add () {chkadd.checked = true; if (SqlDST. Tables ["WebGrid"]. Defaultview.count> 0) {response.write ("Record is not empty, can not be added!"));} Else {string year = system.datetime.today.year .toString (); // Add 12 default records to SQLDST to make another modification for (int i = 1; i <13; i ) {DATAROW DR = Sqldst.Tables ["WebGrid"]. Newrow (); DR ["Period_BH"] = YEAR I.TOSTRING ("D2"); DR ["Period_Start"] = Convert.TodateTime (Year "-" i.tostring ("D2") "-" "01") .ToshortdateString (); if (i <12) {DR ["period_end"] = convert.todatetime (YEAR "-" (i 1) .tostring ("D2") "-" "01"). AddDays (-1) .toshortdateString (); else {DR ["period_en D "] = convert.todatetime (Year " - 12-31 "). ToshortdateString ();} DR [" period_chk "] =" "; DR [" period_chkdate "] = NULL; DR [" period_chkbz "] = 0; DR ["" "" "" "", "" "" "" "" "" "" ""

}

// DataSet DSX = (DataSet) WGrid.DataSource; DataSet DST = (Dataset) WGRIDTMP.DataSource The data source is saved by WGRIDTMP. Dst.merge (SqlDst.Tables ["WebGrid"]. getChanges (Data.DataRowState.added), false, system.data.missingschemaAction.dd); // dst.merge (DSx.Tables ["WebGrid"]. GetChanges (Data.DataRowState.added), false, system.dd); wgridtmp.datasource = dst; settoolbar (this.toolbar1, false); setwgrid (this.wgrid, "edit"); /////// SqlDap.Update (SqlDSt, "WebGrid");}} The above code is just a 12 records added to SQLDST, so the WebGrid is rebounded to display the data display on the webgrid, of course, there is no data yet. Save the database because the data is saved after modification.

2, do the corresponding modification: Modification can only be modifications to the enable flag and termination, but the corresponding changes during the starting period change during the termination period, because the processing made by the background is only updated in SQLDST, so To change the data from WebGrid, you will be modified in the front desk to achieve data and display synchronization (1), background processing: private void wgrid_updaterow (Object sender, isnet.Webui.webgrid.Roweventargs e) {this.wgrid.roottable.columns [6 ] .Edittype = isnet.Webui.webgrid.edittype.checkbox; string Olddate; DataSet DSX = (Dataset) Wgrid.DataSource; int J = E.ROW.POSITION; int K = E.ROW.POSITION; DATAROW DD = DSX. Tables ["WebGrid"]. Rows [J]; String Start = DD ["Period_Start"]. TOSTRING (); string end = DD ["period_end"]. Tostring (); system.timespan ss = convert.todatetime (end ). Subtract (START.TODATETIME (START); int = Convert.Toint32 (SS. TOTALDAYS); // During the accounting period IF within 20-40 days ((QJ> 20) && (QJ <40)) {datarow Drqbz = dsx.tables ["WebGrid"]. Rows [J]; IF (DRQYBZ ["Period_qybz"]. TOSTRING ()! = "false") {// Settings Enable Month for (INT i = 0; i <12 ; i ) {DATAROW DR = DSX.Tables ["WebGrid"]. Rows [i]; if (i! = j) {DR ["period_qybz"] = 0;} else { DR ["period_qybz"] = 1;}} for (int m = 0; M <12; M ) {DATAROW DR1 = DSX.TABLES ["WebGrid"]. Rows [M]; DR1 ["PERIOD_CHK"] = " "; DR1 [" period_chkbz "] = 0; DR1 [" Period_chkdate "] = null;} // Add data for the previous record before the month (INT L = 0; L

Period_chkdate "] = system.datetime.today;}} // January is the whole moon if (j == 0) {DATAROW DR = dsx.tables [" WebGrid "]. Rows [0]; string datestart = DR [" Period_start "]. TOSTRING (); string year = datestart.substring (0, 4); DR [" period_end "] = convert.todatetime (Year " - 01-31 ");} else {for (int i = 0; I <(11-k); i ) {DATAROW DR1 = DSX.TABLES ["WebGrid"]. Rows [J]; DATAROW DR2 = DSX.TABLES ["WebGrid"]. Rows [J 1];

Olddate = DR1 ["Period_end"]. TOSTRING (); // This start period to add one day during the termination period of last month, and add a month DR2 during the term ending of last month, DR2 ["Period_Start"] = Convert.TodateTime (Olddate) .adddays (1); DR2 ["period_end"] = convert.todatetime (olddate) .addmonths (1); J ;} // December is the whole moon DATAROW DR = DSX.Tables ["WebGrid"] .ROWS [11]; String Datestart = DR ["period_start"]. Tostring (); string year = datestart.substring (0, 4); DR ["period_end"] = convert.todatetime (YEAR "- 12-31" );}} Dataset DST = (Dataset) WGRIDTMP.DataSource; if (chkadd.checked == true) {// Handling DST.TABLES ["WebGrid"]. Rows.clear (); for (); INT i = 0; I 0) { Var rows = htbl.rows; if (Cell2.childNodes [0] .CHECKED ==

True) {for (var i = 0; i 20 && Bz <40) {for (var i = 0; i Cell0.innertext) {var startdate = new Date (); var enddate = new date (); startdate = strtodate (wggetcellbyname (rows [i-1], "period_end"); startdate.setdate (StartDate.Getdate () 1); var typeear; type = startdate.getFullYear (); var startmonth; var startday; startmonth = ntostr (startdate.getMonth () 1); startday = ntostr (startdate.getDate ());. wgGetCellByName (rows [i], "period_start") innerText = startdate.getfullyear () "-" "-" startday; // wggetcellbyname (rows [i], "

转载请注明原文地址:https://www.9cbs.com/read-107110.html

New Post(0)