private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { //tiliu if (e.ClickedItem.Name == "copy") { CopyUtils.copyResult(gridView1, focuseName); } else if (e.ClickedItem.Name == "tiliu") { DataRow row = gridView1.GetFocusedDataRow( ); if (row == null) { return; } decimal ztl = string.IsNullOrEmpty(row ["WAH024"].ToString( )) == true ? 0 : Convert.ToDecimal(row ["WAH024"]); if (ztl == 0) { return; } DataRow [] rows = tableView.Select("WAH023='" + row ["WAH023"] + "' AND WAH015<=0"); if (rows == null || rows.Length < 1) { return; } DataRow [] rowes = tableView.Select("WAH023='" + row ["WAH023"] + "' AND WAH015>0"); decimal otherNum = 0M; if (rowes != null && rowes.Length > 0) { foreach (DataRow ro in rowes) { otherNum += Convert.ToDecimal(ro ["WAH015"]); } } int num = rows.Length; decimal everyNum = (ztl - otherNum) / (num * Convert.ToDecimal(1.0)); foreach (DataRow r in rows) { r ["WAH015"] = everyNum; } } }
private void contextMenuStrip1_ItemClicked(object sender, System.Windows.Forms.ToolStripItemClickedEventArgs e) { CopyUtils.copyResult(gridView1, focuseName); }
private void contextMenuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { CopyUtils.copyResult(gridView4, focuseName); }
//复制一行 private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { //if ( e . ClickedItem . Name == "ItemOne" ) //{ // if ( rowes == null ) // { // XtraMessageBox . Show ( "请选择需要复制的行" ); // return; // } // _body . PRE001 = rowes [ "PRE001" ] . ToString ( ); // _body . PRE002 = rowes [ "PRE002" ] . ToString ( ); // _body . PRE003 = rowes [ "PRE003" ] . ToString ( ); // _body . PRE004 = rowes [ "PRE004" ] . ToString ( ); // if ( rowes [ "PRE005" ] == null ) // _body . PRE005 = null; // else // _body . PRE005 = Convert . ToDateTime ( rowes [ "PRE005" ] . ToString ( ) ); // if ( rowes [ "PRE006" ] == null ) // _body . PRE006 = null; // else // _body . PRE006 = Convert . ToDateTime ( rowes [ "PRE006" ] . ToString ( ) ); // if ( rowes [ "PRE007" ] == null ) // _body . PRE007 = null; // else // _body . PRE007 = Convert . ToInt32 ( rowes [ "PRE007" ] . ToString ( ) ); // if ( rowes [ "PRE008" ] == null ) // _body . PRE008 = null; // else // _body . PRE008 = Convert . ToInt32 ( rowes [ "PRE008" ] . ToString ( ) ); // if ( rowes [ "PRE009" ] == null || rowes [ "PRE009" ].ToString() == string.Empty ) // _body . PRE009 = null; // else // _body . PRE009 = Convert . ToInt32 ( rowes [ "PRE009" ] . ToString ( ) ); // if ( rowes [ "PRE010" ] == null ) // _body . PRE010 = null; // else // _body . PRE010 = Convert . ToInt32 ( rowes [ "PRE010" ] . ToString ( ) ); // object obj = tableView . Compute ( "MAX(PRE005)" ,"PRE002='" + _body . PRE002 + "' AND PRE003='" + _body . PRE003 + "' AND PRE004='" + _body . PRE004 + "'" ); // if ( obj != null ) // { // _body . PRE005 = Convert . ToDateTime ( obj ) . AddDays ( 1 ); // DataRow row = tableView . NewRow ( ); // row [ "PRE001" ] = _body . PRE001; // row [ "PRE002" ] = _body . PRE002; // row [ "PRE003" ] = _body . PRE003; // row [ "PRE004" ] = _body . PRE004; // row [ "PRE005" ] = _body . PRE005; // row [ "PRE006" ] = _body . PRE006; // row [ "PRE007" ] = _body . PRE007; // row [ "PRE008" ] = _body . PRE008; // if ( _body . PRE009 == null ) // row [ "PRE009" ] = DBNull . Value; // else // row [ "PRE009" ] = _body . PRE009; // row [ "PRE010" ] = _body . PRE010; // row [ "PRE" ] = rowes [ "PRE" ]; // tableView . Rows . Add ( row ); // } //} // else if (e.ClickedItem.Name == "ItemTwo") { CopyUtils.copyResult(gridView1, focuseName); } }