在C#中,SelectBox控件中,SelectedIndex="-1"是什么意思

在C#中,SelectBox控件中,SelectedIndex="-1"是什么意思

2个回答

意思是当前不选中任何一项

这里是表示什么也没有选中,如果选中的话selectedindex就是选中的index,就是序号数字1,2,3...等,你可以在selectindexchanging事件中测试一下,response.write(listBox.selectedindex)下,看看就知道了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
c#中SelectBox控件中的ValueField和DisplayField属性各是什么意思?
例如:<ext:SelectBox ID="SelectBox1" runat="server" ValueField="FullName" DisplayField="FullName" SelectedIndex="-1" EmptyText="请选择类型名称"> </ext:SelectBox> 这句话中的ValueField和DisplayField各是什么意思
C#如何通过单击combox控件里的选项来更改picturebox控件的图片
C#如何通过单击combox控件里的选项来更改picturebox控件的图片如下图形式,这是别人的程序,我自己不会做这样的 ![图片说明](https://img-ask.csdn.net/upload/201911/20/1574233570_87422.png)![图片说明](https://img-ask.csdn.net/upload/201911/20/1574233625_730546.png) 编程新手,请大神指点!最好写出代码 ``` private void Form1_Load(object sender, EventArgs e) { comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; string[] str = new string[] { "单相双柱式", "三相三柱式", "三相五柱式", "单相单柱旁轭式", "三相壳式", "单相卷铁心式", "三相平面式卷铁心", "单相双柱旁轭式铁心" }; comboBox1.DataSource = str; comboBox1.SelectedIndex = 0; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } ```
C#.net中 公用string字符串的赋值失败问题
**我要做的是选择底下GridView的内容 然后点击提交按钮后 把GridView中的课程ID提交到数据库保存下来** ![图片说明](https://img-ask.csdn.net/upload/201907/24/1563967328_266399.png) **问题出在这个公用字符串CID1 在GRIDView中选择时 CID1 能成功记录所选的信息 (图一断点验证)** ![图片说明](https://img-ask.csdn.net/upload/201907/24/1563967249_929930.png) **但是点击提交按钮后CID1变成空(图二断点验证)** ![图片说明](https://img-ask.csdn.net/upload/201907/24/1563967297_993480.png) **之前问过类似的问题,有个前辈是说点击了asp:button后 页面重新加载 刷新CID1 经过改造我现在这些操作过程是直接选择GRIDVIEW中的内容 再点击提交 中间没有点击按钮的操作 怎么会刷新呢 然后在网上查好像是要用ispostback来做 但是ispostback 只能用在方法里使用 在我定义这个字符串的位置不能够使用 希望前辈们能教教我 如何解决这个问题 或者能教教我如何点击GRIDVIEW中的内容 如何把CELL[0]中的内容传到底下submit的方法**里 **下面是后端代码**: ``` using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class HTML_ChooseCourse : System.Web.UI.Page { string CID1=""; protected void Page_Load(object sender, EventArgs e) { } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { //记录GridView中选择的内容,到下面提交时要用到 int index = GridView1.SelectedIndex; this.LabTuesday.Text = GridView1.Rows[index].Cells[1].Text; CID1=GridView1.Rows[index].Cells[0].Text.ToString(); } public static void Messagebox(string message) { string strScript = "<script type=\"text/javascript\" language=\"javascript\">alert('" + message + "')</script>"; System.Web.UI.Page thisPage = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; thisPage.ClientScript.RegisterStartupScript(thisPage.GetType(), "ShowMsgBox", strScript); } protected void BtnSubmit_Click(object sender, EventArgs e) { if ( this.LabTuesday.Text != "") { string connectionstr = "Data Source=DESKTOP-79153UB;Initial Catalog=db_StudentManage;Integrated Security=True"; SqlConnection connection = new SqlConnection(connectionstr); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; //将上面记录的信息记录到数据库中 上面选择GRIDVIEW中的信息 记录下的 CID1 到这个方法就无内容了 command.CommandText = string.Format("insert into tb_ChooseCourse values ('{0}','{1}','周二')", CID1.ToString(),Session["ID"].ToString()); int count1 = command.ExecuteNonQuery(); if (count1== 1) Messagebox("提交成功"); else Messagebox("提交失败,请重试!"); connection.Close(); } else Messagebox("有信息为空,请继续选课!"); } } ``` **下面是前端代码:** ``` <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChooseCourse1.aspx.cs" Inherits="HTML_ChooseCourse" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>选课</title> <style> .TopDiv { border: 0px solid black; width:100%; height: 60px; position: absolute; left: 20px; top: 20px; text-align:center; } .MiddleDiv { border: 0px solid black; width: 680px; height: 290px; position: absolute; left:320px; top: 180px; } .SecondDiv { border: 0px solid black; width: 894px; height: 50px; position: absolute; left:320px; top: 100px; } .btn { border-style: none; border-color: inherit; border-width: medium; background-color: #62a8ea; line-height: 45px; color: white; cursor: pointer; font-size: 16px; font-weight: bold; } </style> </head> <body style="background-color:#E6E6E6"> <form id="form1" runat="server"> <div class="TopDiv" style="font-family:幼圆;font-size:50px"> 选课 </div> <div class="SecondDiv"> <table style="background-color:#E6E6E6"> <tr> <td><asp:Button ID="BtnTuesday" CssClass="btn" runat="server" Text="周二" Height="50px" Width="90px" Font-Underline="False" OnClientClick="return false" /></td> <td style="font-family:幼圆;background-color:#E6E6E6;text-align:center"><asp:Label ID="LabTuesday" runat="server" Height="50px" Width="490px" BackColor="Silver" ></asp:Label></td> <td><asp:Button ID="BtnSubmit" CssClass="btn" runat="server" Text="提交" Height="50px" Width="90px" OnClick="BtnSubmit_Click"/></td> </tr> </table> </div> <div class="MiddleDiv"> <asp:GridView style="text-align:center;font-family:幼圆;" Height="370px" Width="676px" ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CId" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" > <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:BoundField DataField="CId" HeaderText="课程ID" ReadOnly="True" SortExpression="CId" /> <asp:BoundField DataField="CName" HeaderText="课程姓名" SortExpression="CName" /> <asp:BoundField DataField="TID" HeaderText="负责教师ID" SortExpression="TID" /> <asp:CommandField HeaderText="操作" ShowSelectButton="True" /> </Columns> <EditRowStyle BackColor="#999999" /> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#E9E7E2" /> <SortedAscendingHeaderStyle BackColor="#506C8C" /> <SortedDescendingCellStyle BackColor="#FFFDF8" /> <SortedDescendingHeaderStyle BackColor="#6F8DAE" /> </asp:GridView> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:db_StudentManageConnectionString %>" DeleteCommand="DELETE FROM [tb_Course] WHERE [CId] = @original_CId AND (([CName] = @original_CName) OR ([CName] IS NULL AND @original_CName IS NULL)) AND (([TID] = @original_TID) OR ([TID] IS NULL AND @original_TID IS NULL))" InsertCommand="INSERT INTO [tb_Course] ([CId], [CName], [TID]) VALUES (@CId, @CName, @TID)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tb_Course]" UpdateCommand="UPDATE [tb_Course] SET [CName] = @CName, [TID] = @TID WHERE [CId] = @original_CId AND (([CName] = @original_CName) OR ([CName] IS NULL AND @original_CName IS NULL)) AND (([TID] = @original_TID) OR ([TID] IS NULL AND @original_TID IS NULL))"> <DeleteParameters> <asp:Parameter Name="original_CId" Type="String" /> <asp:Parameter Name="original_CName" Type="String" /> <asp:Parameter Name="original_TID" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="CId" Type="String" /> <asp:Parameter Name="CName" Type="String" /> <asp:Parameter Name="TID" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="CName" Type="String" /> <asp:Parameter Name="TID" Type="String" /> <asp:Parameter Name="original_CId" Type="String" /> <asp:Parameter Name="original_CName" Type="String" /> <asp:Parameter Name="original_TID" Type="String" /> </UpdateParameters> </asp:SqlDataSource> </div> </form> </body> </html> ```
C#.net中 string字符串的赋值失败问题
**麻烦前辈们指点一下,我这个做的功能是点击GRIDVIEW中自带的选择功能后将选定行的第一个格子的内容赋值给上面的CID1,CID2,然后在下面有个提交功能要用到这个CID1和CID2。但是CID1,CID2的值到下面提交功能就为空。 ** ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563692024_17358.png) **这张图到第一个断点时CD1和CD3都成功赋值** ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563692153_129327.png) **到第二个断点时,CD2和CD4成功赋值,但是此时CD1的值为空。** ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563692252_383766.png) **再到下面用到CD1和CD2的提交功能设定的断点时CD1和CD2的值都为空** **我有试过直接赋值给CID1和CID2而不用CID3和CID4,这样的还是结果一样。** **CD1和CD2的赋值到提交功能的使用中间并没有经过任何赋值的步骤。** ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563697563_369495.png) **这是那两个BTN的前端** ![图片说明](https://img-ask.csdn.net/upload/201907/21/1563697598_315243.png) **这是那两个IF的筛选条件也是BTN的功能赋值** **下面是后端代码:** ``` using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class HTML_ChooseCourse : System.Web.UI.Page { string CID1=""; string CID2=""; protected void Page_Load(object sender, EventArgs e) { } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index = GridView1.SelectedIndex; if (this.BtnTuesday.Enabled == false && this.BtnThursday.Enabled == true) { this.LabTuesday.Text = GridView1.Rows[index].Cells[1].Text; string CID3 =GridView1.Rows[index].Cells[0].Text.ToString(); CID1 = CID3; } if (this.BtnTuesday.Enabled == true & this.BtnThursday.Enabled == false) { this.LabThursday.Text = GridView1.Rows[index].Cells[1].Text; string CID4 = GridView1.Rows[index].Cells[0].Text.ToString(); CID2 = CID4; } if (this.BtnTuesday.Enabled == true & this.BtnThursday.Enabled == true) { Messagebox(" 您还没选择周次"); } } protected void BtnTuesday_Click(object sender, EventArgs e) { this.BtnTuesday.Enabled = false; this.BtnTuesday.Font.Underline = true; this.BtnThursday.Enabled = true; this.BtnThursday.Font.Underline = false; } protected void BtnThursday_Click(object sender, EventArgs e) { this.BtnThursday.Enabled = false; this.BtnThursday.Font.Underline = true; this.BtnTuesday.Enabled = true; this.BtnTuesday.Font.Underline = false; } public static void Messagebox(string message) { string strScript = "<script type=\"text/javascript\" language=\"javascript\">alert('" + message + "')</script>"; System.Web.UI.Page thisPage = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; thisPage.ClientScript.RegisterStartupScript(thisPage.GetType(), "ShowMsgBox", strScript); } protected void BtnSubmit_Click(object sender, EventArgs e) { if (this.LabThursday.Text != "" && this.LabTuesday.Text != "") { string connectionstr = "Data Source=DESKTOP-79153UB;Initial Catalog=db_StudentManage;Integrated Security=True"; SqlConnection connection = new SqlConnection(connectionstr); connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = string.Format("insert into tb_ChooseCourse values ('{0}','{1}','周一')", CID1.ToString(),Session["ID"].ToString()); int count1 = command.ExecuteNonQuery(); command.CommandText = string.Format("insert into tb_ChooseCourse values ('{0}','{1}','周二')", CID2.ToString(), Session["ID"].ToString()); int count2 = command.ExecuteNonQuery(); int count3=count1+count2; if (count3 == 2) Messagebox("提交成功"); else Messagebox("提交失败,请重试!"); } else Messagebox("有信息为空,请继续选课!"); } } } ``` 下面是前端代码: ``` <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChooseCourse.aspx.cs" Inherits="HTML_ChooseCourse" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>选课</title> <style> .TopDiv { border: 0px solid black; width:100%; height: 60px; position: absolute; left: 20px; top: 20px; text-align:center; } .MiddleDiv { border: 0px solid black; width: 680px; height: 290px; position: absolute; left:320px; top: 180px; } .SecondDiv { border: 0px solid black; width: 894px; height: 50px; position: absolute; left:320px; top: 100px; } .btn { border-style: none; border-color: inherit; border-width: medium; background-color: #62a8ea; line-height: 45px; color: white; cursor: pointer; font-size: 16px; font-weight: bold; } </style> </head> <body style="background-color:#E6E6E6"> <form id="form1" runat="server"> <div class="TopDiv" style="font-family:幼圆;font-size:50px"> 选课 </div> <div class="SecondDiv"> <table style="background-color:#E6E6E6"> <tr> <td><asp:Button ID="BtnTuesday" CssClass="btn" runat="server" OnClick="BtnTuesday_Click" Text="周二" Height="50px" Width="90px" Font-Underline="False" /></td> <td style="font-family:幼圆;background-color:#E6E6E6;text-align:center"><asp:Label ID="LabTuesday" runat="server" Height="50px" Width="200px" BackColor="Silver" ></asp:Label></td> <td><asp:Button ID="BtnThursday" CssClass="btn" runat="server" OnClick="BtnThursday_Click" Text="周四" Height="50px" Width="90px"/></td> <td style="font-family:幼圆;background-color:#E6E6E6;text-align:center"><asp:Label ID="LabThursday" runat="server" Height="50px" Width="200px" BackColor="Silver"></asp:Label></td> <td><asp:Button ID="BtnSubmit" CssClass="btn" runat="server" Text="提交" Height="50px" Width="90px" OnClick="BtnSubmit_Click"/></td> </tr> </table> </div> <div class="MiddleDiv"> <asp:GridView style="text-align:center;font-family:幼圆;" Height="370px" Width="676px" ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CId" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnSelectedIndexChanging="GridView1_SelectedIndexChanging"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:BoundField DataField="CId" HeaderText="课程ID" ReadOnly="True" SortExpression="CId" /> <asp:BoundField DataField="CName" HeaderText="课程姓名" SortExpression="CName" /> <asp:BoundField DataField="TID" HeaderText="负责教师ID" SortExpression="TID" /> <asp:CommandField HeaderText="操作" ShowSelectButton="True" /> </Columns> <EditRowStyle BackColor="#999999" /> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#E9E7E2" /> <SortedAscendingHeaderStyle BackColor="#506C8C" /> <SortedDescendingCellStyle BackColor="#FFFDF8" /> <SortedDescendingHeaderStyle BackColor="#6F8DAE" /> </asp:GridView> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:db_StudentManageConnectionString %>" DeleteCommand="DELETE FROM [tb_Course] WHERE [CId] = @original_CId AND (([CName] = @original_CName) OR ([CName] IS NULL AND @original_CName IS NULL)) AND (([TID] = @original_TID) OR ([TID] IS NULL AND @original_TID IS NULL))" InsertCommand="INSERT INTO [tb_Course] ([CId], [CName], [TID]) VALUES (@CId, @CName, @TID)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tb_Course]" UpdateCommand="UPDATE [tb_Course] SET [CName] = @CName, [TID] = @TID WHERE [CId] = @original_CId AND (([CName] = @original_CName) OR ([CName] IS NULL AND @original_CName IS NULL)) AND (([TID] = @original_TID) OR ([TID] IS NULL AND @original_TID IS NULL))"> <DeleteParameters> <asp:Parameter Name="original_CId" Type="String" /> <asp:Parameter Name="original_CName" Type="String" /> <asp:Parameter Name="original_TID" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="CId" Type="String" /> <asp:Parameter Name="CName" Type="String" /> <asp:Parameter Name="TID" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="CName" Type="String" /> <asp:Parameter Name="TID" Type="String" /> <asp:Parameter Name="original_CId" Type="String" /> <asp:Parameter Name="original_CName" Type="String" /> <asp:Parameter Name="original_TID" Type="String" /> </UpdateParameters> </asp:SqlDataSource> </div> </form> </body> </html> ```
c#在用winfrom时 怎样实现模糊搜索
void LoadLrc() { string songPath=listSongs[listBox1.SelectedIndex]; string[] songPath1 = songPath.Split(new char []{'.'}, StringSplitOptions.RemoveEmptyEntries); string void LoadLrc() { string songPath=listSongs[listBox1.SelectedIndex]; string[] songPath1 = songPath.Split(new char []{'.'}, StringSplitOptions.RemoveEmptyEntries); string songPath2=; if (File.Exists(songPath2)) { string []lrcText = File.ReadAllLines(songPath ,Encoding .Default ); FormatLrc(lrcText); } else { lblLrc.Text = "-------------歌词未找到-------------"; } }=; if (File.Exists(songPath2)) { string []lrcText = File.ReadAllLines(songPath ,Encoding .Default ); FormatLrc(lrcText); } else { lblLrc.Text = "-------------歌词未找到-------------"; } } 我想让 songPath2 的搜索结果为 ****songPath1【0】****.lrc 该怎么写呀 谢谢
c#对数据表格控件已选行记录的调用
public partial class FrmMainfo : Form { public FrmMainfo() { InitializeComponent(); } string connStr = ConfigurationManager.ConnectionStrings["str"].ConnectionString; private void button2_Click(object sender, EventArgs e) { FrmMadetail frmmadetail = new FrmMadetail(); frmmadetail.Show(); } private void FrmMainfo_Load(object sender, EventArgs e) { comboBox2.SelectedIndex = 0; comboBox3.SelectedIndex = 0; string sql = "select Id,sbmc,sbbh,sbfl,sblx,ggxh,azwz,sccj,sybm,sycj from Information"; SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); dataGridView1.DataSource = dt; } public class DvgData { public string id = ""; public string ID { get { return id; } set { id = value; } } } private void dataGridView1ListHeadText() { dataGridView1.Columns[0].HeaderText = "编号"; dataGridView1.Columns[1].HeaderText = "设备名称"; dataGridView1.Columns[2].HeaderText = "设备编号"; dataGridView1.Columns[3].HeaderText = "设备分类"; dataGridView1.Columns[4].HeaderText = "设备类型"; dataGridView1.Columns[5].HeaderText ="规格型号"; dataGridView1.Columns[6].HeaderText ="安装位置"; dataGridView1.Columns[7].HeaderText ="生产厂家"; dataGridView1.Columns[8].HeaderText = "使用部门"; dataGridView1.Columns[9].HeaderText = "使用车间"; dataGridView1.Columns[10].HeaderText = "外形尺寸"; dataGridView1.Columns[10].Visible = false; dataGridView1.Columns[11].HeaderText = "总重"; dataGridView1.Columns[11].Visible = false; dataGridView1.Columns[12].HeaderText = "总功率"; dataGridView1.Columns[12].Visible = false; dataGridView1.Columns[13].HeaderText = "出厂编号"; dataGridView1.Columns[13].Visible = false; dataGridView1.Columns[14].HeaderText = "制造日期"; dataGridView1.Columns[14].Visible = false; dataGridView1.Columns[15].HeaderText = "使用日期"; dataGridView1.Columns[15].Visible = false; dataGridView1.Columns[16].HeaderText = "购入日期"; dataGridView1.Columns[16].Visible = false; } private void button1_Click(object sender, EventArgs e) { string azwz = ""; //定义一个string 类型的变量 azwz = comboBox3.SelectedItem.ToString(); string sbfl=""; sbfl = comboBox2.SelectedItem.ToString(); string sqf = "select * from Information where azwz = '" +azwz.Trim() + "'and sbfl = '" +sbfl.Trim() + "'"; SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(sqf, conn); conn.Open(); DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); dataGridView1.DataSource = dt; this.dataGridView1ListHeadText(); } private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > 0) { int id = (int)dataGridView1.Rows[e.RowIndex].Cells[0].Value;//记录选中的ID号 } } } } public partial class FrmMadetail : Form { public FrmMadetail() { InitializeComponent(); } string connStr = ConfigurationManager.ConnectionStrings["str"].ConnectionString; FrmMainfo frmmainfo = new FrmMainfo(); private void FrmMadetail_Load(object sender, EventArgs e) { string sqf = "select * from Information where ID = 1"; SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(sqf, conn); conn.Open(); DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); textBox1.Text = dt.Rows[0][1].ToString(); textBox2.Text = dt.Rows[0][2].ToString(); textBox3.Text = dt.Rows[0][3].ToString(); textBox4.Text = dt.Rows[0][4].ToString(); } 本人小白一个 现在需要把第一个窗体数据表格控件 选中的行 INT 记录下来 接着在 另外一个窗体LOAD事件中 利用这个记录值 用SQL语句进行查询 这个代码要如何实现呢 谢谢大家 初来咋到 全部自学啊 很辛苦
VBScript 运行时错误 类型不匹配: '[string: ""]' line 12
<%Option Explicit%> <!--#include file="commondb.asp"--> <!--#include file="cartcookie.asp"--> <% dim cartstr cartstr = getCartFromCookie() if (cartstr=NULL or cartstr ="") then response.redirect "Cart.asp" response.end end if dim payName,payPhone,payEmail,payAddress if (session("userautoid")<=0) then(12行在这里) payName="" payPhone="" payEmail="" payAddress="" else dim dbc,query,rs shopopendatabase dbc query = "select * from myUser where autoid = " & session("userautoid") set rs = dbc.execute(query) If not rs.EOF Then payName=rs("realname") payPhone=rs("phone") payEmail=rs("userid") payAddress=rs("Address") end if closerecordset rs shopclosedatabase dbc end if %> <html> <head> <title>绿植鲜花礼品店</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link rel="stylesheet" href="lvzhi.css" type="text/css"> <STYLE type=text/css>TD { FONT-SIZE: 12px; FONT-FAMILY: "宋体" } </STYLE> <script language="javascript"> function setReceiverFormVisible(vGet) { if(vGet=='1'){ document.all.receiverinfo_form.style.display='none'; }else{ document.all.receiverinfo_form.style.display='block'; } } function checkinput() { var payName=document.mymainform.MypayName.value; if (payName=="") { alert("付款人名称不能为空!"); document.mymainform.MypayName.focus(); return false; } var payPhone=document.mymainform.payPhone.value; if (payPhone=="") { alert("付款人电话不能为空!"); document.mymainform.payPhone.focus(); return false; } if(document.mymainform.myrec2.checked==true) { var recName=document.mymainform.recName.value; if (recName=="") { alert("收货人名称不能为空!"); document.mymainform.recName.focus(); return false; } var recPhone=document.mymainform.recPhone.value; if (recPhone=="") { alert("收货人电话不能为空!"); document.mymainform.recPhone.focus(); return false; } } return true; } </script> </head> <body bgcolor="#FFFFFF" topmargin="0"> <!--#include file="top.html"--> <br> <% ShowCart("yes") %> <form name=mymainform id=mymainform action="CheckConfirm.asp" method=post onSubmit="return checkinput();"> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="title"> <td colspan="7"><b>付款人信息</b>(姓名,电话必填项,客服确认后收款发货)</td> </tr> <tr class="bg2"> <td colspan="7" align="center"> <input type=radio name=myrec value="1" id=myrec1 onClick="setReceiverFormVisible('1')" checked> 付款人收货(付款与收货同一个人) <input type=radio name=myrec value="2" id=myrec2 onClick="setReceiverFormVisible('2')"> 其他人收货(付款送给其他人) </td> </tr> </table> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="bg1"> <td width="14%">您的姓名: </td> <td width="36%"> <input type="text" id="MypayName" name="MypayName" size=20 maxlength=40 value="<%=payName%>"> </td> <td width="14%">联系电话: </td> <td width="36%"> <input type="text" id="payPhone" name="payPhone" size=20 maxlength=40 value="<%=payPhone%>"> </td> </tr> <tr class="bg1"> <td width="14%">邮箱Email: </td> <td width="36%"> <input type="text" id="payName" name="payEmail" size=20 maxlength=40 value="<%=payEmail%>"> </td> <td width="14%">详细地址: </td> <td width="36%"> <input type="text" id="payName" name="payAddress" size=20 maxlength=40 value="<%=payAddress%>"> </td> </tr> <tr class="bg1"> <td width="14%">送货时间: </td> <td width="86%" colspan=3> <select id="sendMonth" name="sendMonth"> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> <option value=5>5</option> <option value=6>6</option> <option value=7>7</option> <option value=8>8</option> <option value=9>9</option> <option value=10>10</option> <option value=11>11</option> <option value=12>12</option> </select>月 <select id="sendDay" name="sendDay"> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> <option value=5>5</option> <option value=6>6</option> <option value=7>7</option> <option value=8>8</option> <option value=9>9</option> <option value=10>10</option> <option value=11>11</option> <option value=12>12</option> <option value=13>13</option> <option value=14>14</option> <option value=15>15</option> <option value=16>16</option> <option value=17>17</option> <option value=18>18</option> <option value=19>19</option> <option value=20>20</option> <option value=21>21</option> <option value=22>22</option> <option value=23>23</option> <option value=24>24</option> <option value=25>25</option> <option value=26>26</option> <option value=27>27</option> <option value=28>28</option> <option value=29>29</option> <option value=30>30</option> <option value=31>31</option> </select>日 &nbsp;(最好提前1天预定,当天加急配送的,请电话13910250117确定) <% dim sendMonth,sendDay,mysend mysend=DateAdd("d",1,now()) sendMonth=Month(mysend) sendDay=day(mysend) %> <script language="javascript"> document.mymainform.sendMonth.selectedIndex=<%=(sendMonth-1)%> document.mymainform.sendDay.selectedIndex=<%=(sendDay-1)%> </script> </td> </tr> <tr class="bg1"> <td width="14%">特定说明: </td> <td width="86%" colspan=3> <input type="text" id="payMemo" name="payMemo" size=80 maxlength=140 value=""> </td> </tr> </table> <br> <!--其他人收货--> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="title"> <td><b>其他人收货<font color="#FF0000">(选择其他人收货时候显示这栏内容)</font></b></td> <% if (session("userautoid")>0) then %> <td>你曾经送过的朋友: <select id=recsex name=recsex class="buy_box"> <option value=m>1</option> <option value=f>2</option> </select> </td> <% end if %> </tr> </table> <div style="display:none" id="receiverinfo_form"> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="bg1"> <td width="15%">姓  名:</td> <td width="40%"> <input type="text" id="recName" name="recName" size=20 maxlength=40 value=""> </td> <td width="15%"> 称 呼: </td> <td width="30%"> <select id=recsay name=recsay class="buy_box"> <option value=0>小姐</option> <option value=1>女士</option> <option value=2>先生</option> </select> </td> </tr> <tr class="bg1"> <td width="15%">城 市: </td> <td width="40%"> 兰州市(目前只送兰州) </td> <td width="15%"> 收货人联系电话: </td> <td width="30%"> <input type="text" id="recPhone" name="recPhone" size=20 maxlength=40 value=""> </td> </tr> <tr class="bg1"> <td width="15%"> 收货人详细地址: </td> <td colspan="3" > <input type="text" id="recAddress" name="recAddress" size=60 maxlength=80 value=""> </td> </tr> <tr class="bg1"> <td width="15%"> 特殊说明: </td> <td colspan="3" > <input type="text" id="recMemo" name="recMemo" size=60 maxlength=80 value=""> (送贺卡赠言内容等信息) </td> </tr> <tr class="bg1"> <td>电子邮件: </td width="15%"> <td width="40%"> <input id=recemail name=recemail type=text value=""> </td> <td width="15%"> 送货名义: </td> <td width="30%"> <input type=radio name=whosend value="1">你的姓名送 <input type=radio name=whosend value="2" checked >匿名,某人送 </td> </tr> </table> </div> <TABLE width=760 cellspacing=0 cellpadding=0 border=0> <TR> <TD height=3></TD> </TR> </TABLE> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="title"> <td colspan="7" ><b>送货范围及费用说明(目前只配送兰州市地区)</b></td> </tr> </table> <table width="760" border="0" cellspacing="1" cellpadding="3" bgcolor="#4a4a4a" align="center"> <tr class="bg1"> <td><input type=radio name="send" value="1" checked > 付款人和收货人相同,兰州市内收送货费10元</td> </tr> <tr class="bg1"> <td><input type=radio name="send" value="2" > 付款人和收货人不同,不过付款人和收货人都在兰州市内,另加收上门收款费用5元</td> </tr> <tr class="bg1"> <td><input type=radio name="send" value="3" > 郊区和特定地区,一般暂定20元,其他地区电话确定送货费用。</td> </tr> <tr class="bg1"> <td><input type=radio name="send" value="4" > 加急配送请电话联系确定,配送费用协商定,一般定为30元</td> </tr> </table> <TABLE width=760 cellspacing=0 cellpadding=0 border=0> <TR> <TD height=3></TD> </TR> </TABLE> <input type=hidden name=direct value="direct"> <TABLE width=760 cellspacing=1 cellpadding=3 border=0 bgcolor="#4a4a4a" align="center"> <tr class="title"> <td align="center" background="images/colorback.gif"> <INPUT TYPE="submit" value="&nbsp;确&nbsp;认&nbsp;并&nbsp;提&nbsp;交&nbsp;" class="button" name="submit2"> </td> </tr> </table> </form> <!--#include file="bottom.html"--> </body> </html>
Jquery Mobile Ajax ASP.NET控件 无刷新页面查询,添加,修改,删除
Jquery Mobile Ajax 技术用ASP.NET控件怎么实现无刷新页面查询,添加,修改,删除功能? 现在刷新一次才能执行JavaScript代码,否则没反应,有时候样式也没了。 我写的代码如下: ``` <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="css/jquery.mobile-1.4.5.css" /> <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" /> <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.4.5.min.js"></script> </head> <body> <form id="form1" runat="server"> <div data-role="page" data-quicklinks="true"> <div data-role="header"><h1>标题</h1></div> <div role="main"> <ul data-role="listview"> <li><a href="TestSql.aspx?key=1">AAA</a></li> <li><a href="TestSql.aspx?key=2">BBB</a></li> </ul> </div> <div data-role="footer" data-position="fixed"><h4>©2013-2015</h4></div> </div> </form> </body> </html> ``` ``` <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestSql.aspx.cs" Inherits="TestSql" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="css/jquery.mobile-1.4.5.css" /> <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" /> <script src="js/jquery.js"></script> <script src="js/jquery.mobile-1.4.5.min.js"></script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div data-role="page"> <div data-role="header"><h1>标题</h1><a href="Default.aspx" data-icon="arrow-r"><% =GetCityName() %></a></div> <div id="tabs" data-role="tabs"> <div data-role="navbar"> <ul> <li><a href="#one" data-ajax="false">第一</a></li> <li><a href="#two" data-ajax="false">第二</a></li> </ul> </div> <div class="ui-body-d ui-content" id="one"> <asp:DropDownList data-native-menu="false" ID="ddlSort" runat="server" OnSelectedIndexChanged="ddlSort_SelectedIndexChanged"></asp:DropDownList> <asp:DropDownList data-native-menu="false" ID="ddlCity" runat="server"></asp:DropDownList> <asp:Button ID="btnSearch" runat="server" Text="查询" CssClass="ui-btn-active" /> </div> <div id="two"> <ul data-role="listview" data-inset="true"> <li><a href="#">A</a></li> <li><a href="#">B</a></li> <li><a href="#">C</a></li> <li><a href="#">D</a></li> <li><a href="#">E</a></li> </ul> </div> </div> <div data-role="footer" data-position="fixed"><h4>©2013-2015</h4></div> </div> </ContentTemplate> </asp:UpdatePanel> </form> </body> </html> ``` ``` using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class TestSql : System.Web.UI.Page { SqlEditForOleDb ed = new SqlEditForOleDb(); string CityNumber = string.Empty; int StationSortIndex = 0; string StationSortName = string.Empty; int StationIndex = 0; string StationName = string.Empty; protected void Page_Load(object sender, EventArgs e) { try { CityNumber = Request.QueryString["key"].ToString(); Session["CityID"] = CityNumber; if (CityNumber == string.Empty) { Response.Redirect("Default.aspx"); } } catch { Response.Redirect("Default.aspx"); } ddlSort.AutoPostBack = true; ddlCity.AutoPostBack = true; if (!IsPostBack) { ddlSort.Items.Add("A"); ddlSort.Items.Add("B"); ddlSort.Items.Add("C"); ddlSort.Items.Add("D"); ddlSort.Items.Add("E"); ddlCity.Enabled = false; } else if (ddlSort.SelectedIndex == 0) { ddlCity.Enabled = false; } StationSortName = ddlSort.Text; StationSortIndex = ddlSort.SelectedIndex; StationName = ddlCity.Text; StationIndex = ddlCity.SelectedIndex; } public string GetCityName() { string str = string.Empty; try { str = ed.Search("SELECT 名称 FROM 城市 WHERE ID = " + CityNumber).Rows[0][0].ToString(); } catch { } return str; } public string GetCityID() { string str = string.Empty; try { str = Session["CityID"].ToString(); } catch { } return str; } protected void ddlSort_SelectedIndexChanged(object sender, EventArgs e) { ddlCity.Items.Clear(); if (ddlSort.SelectedIndex == 0) { ddlCity.Enabled = false; } else { ddlCity.Enabled = true; DataTable dtStation = new DataTable(); dtStation = ed.Search("SELECT DISTINCT 城市.名称 FROM 城市 WHERE 城市.名称 like '" + StationSortName + "%'"); for (int i = 0; i < dtStation.Rows.Count; i++) { ddlCity.Items.Add(dtStation.Rows[i][0].ToString()); } } } } ```
关于在C# Winform中的方法事件中使用大量if-else问题
winform运行比较顺利,但if-else代码太多 诸如如下情况 实现功能按钮:private void Button_Click(object sender,EventArgs e) { if ( listBox1.SelectedIndex==0) { a = int.Parse(DataText.Text);listBox1.SelectedIndex = 0; listBox1.Items[0] = "a的值为" + a + " 。"} else if ( listBox1.SelectedIndex==1) { b = int.Parse(DataText.Text);listBox1.SelectedIndex = 1; listBox1.Items[1] = "b的值为" + b + " 。"} else if ( listBox1.SelectedIndex==2) { c = int.Parse(DataText.Text);listBox1.SelectedIndex = 2; listBox1.Items[2] = "c的值为" +c+ " 。"} ............... } 一共这里有100多个if-else 还有一个滚动条显示数据按钮 也是如此(这个有转换算法) private void hScrollBar1_Scroll(object sender, ScrollEventArgs e) { if(richBox1.Text=="a的最大值为100,最小值为0") { int data1 = (int)hScrollBar1.Value;int data2 = data1 * 5;TextBox1.Text = data2.ToString(); } else if(richBox1.Text=="b的最大值为100,最小值为0") { int data1 = (int)hScrollBar1.Value;int data2 = data1 /10;TextBox1.Text = data2.ToString(); } ......一共也是100多个 但这样写代码比较冗长。之前看过张子阳的委托,最后还是无法实现要求(看了改写后总是显示最后一个程序)。也用面向对象的建立接口多态写法也写过,但因为控件太多,导致new的对象太多,程序经常卡壳。求大神指点。。。或者给予一个正确的面向对象写法(在控制台里就写成功过,但是在winform里一次也没用面向对象法解决这个问题)。(づ。◕‿‿◕。)づ
c#编写的串口助手打开串口32单片机立刻黑屏,急求
using Microsoft.Win32; using System; using System.IO.Ports; using System.Windows.Forms; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; namespace WindowsFormsApp { public partial class Form1 : Form { //SerialPort sp = null;//声明一个串口类 bool isOpen = false;//打开串口标志位 bool isSetProperty = false;//属性设置标志位 bool isHex = false;//十六进制显示标志位 public Form1() { InitializeComponent(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;//设置该属性为false } //我们在form载入时,扫描识别存在的串口。 private void Form1_Load(object sender, EventArgs e) { this.MaximumSize = this.Size; this.MinimumSize = this.Size; this.MaximizeBox = false; RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm"); if (keyCom != null) { string[] sSubKeys = keyCom.GetValueNames(); cbxCOMPort.Items.Clear(); foreach (string sName in sSubKeys) { string sValue = (string)keyCom.GetValue(sName); cbxCOMPort.Items.Add(sValue); } if (cbxCOMPort.Items.Count > 0) cbxCOMPort.SelectedIndex = 0; else { cbxCOMPort.Text = ""; MessageBox.Show("没有找到可用串口!", "错误提示"); } } cbxBaudRate.SelectedIndex = 4; cbxStopBits.SelectedIndex = 1; cbxDataBits.SelectedIndex = 0; cbxParity.SelectedIndex = 0; rbnChar.Checked = true; } private void btnCheckCOM_Click(object sender, EventArgs e)//检测哪些串口可用 { RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm"); if (keyCom != null) { string[] sSubKeys = keyCom.GetValueNames(); cbxCOMPort.Items.Clear(); foreach (string sName in sSubKeys) { string sValue = (string)keyCom.GetValue(sName); cbxCOMPort.Items.Add(sValue); } if (cbxCOMPort.Items.Count > 0) cbxCOMPort.SelectedIndex = 0; else { cbxCOMPort.Text =""; MessageBox.Show("没有找到可用串口!", "错误提示"); } } } private bool CheckPortSetting()//检查串口是否设置 { if (cbxCOMPort.Text.Trim() == "") return false; if (cbxBaudRate.Text.Trim() == "") return false; if (cbxDataBits.Text.Trim() == "") return false; if (cbxParity.Text.Trim() == "") return false; if (cbxStopBits.Text.Trim() == "") return false; return true; } private bool CheckSendData() { if (tbxSendData.Text.Trim() == "") return false; return true; } private void SetPortProperty()//设置串口的属性 { serialPort.PortName = cbxCOMPort.Text.Trim();//设置串口名 serialPort.BaudRate = Convert.ToInt32(cbxBaudRate.Text.Trim());//设置串口的波特率 float f = Convert.ToSingle(cbxStopBits.Text.Trim());//设置停止位 if (f == 0) { serialPort.StopBits = StopBits.None; } else if (f == 1.5) { serialPort.StopBits = StopBits.OnePointFive; } else if (f == 1) { serialPort.StopBits = StopBits.One; } else if (f == 2) { serialPort.StopBits = StopBits.Two; } else { serialPort.StopBits = StopBits.One; } serialPort.DataBits = Convert.ToInt16(cbxDataBits.Text.Trim());//设置数据位 string s = cbxParity.Text.Trim(); //设置奇偶校验位 if (s.CompareTo("无") == 0) { serialPort.Parity = Parity.None; } else if (s.CompareTo("奇校验") == 0) { serialPort.Parity = Parity.Odd; } else if (s.CompareTo("偶校验") == 0) { serialPort.Parity = Parity.Even; } else { serialPort.Parity = Parity.None; } serialPort.ReadTimeout = -1;//设置超时读取时间 serialPort.RtsEnable = true; //定义DataReceived 事件,当串口收到数据后触发事件 serialPort.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived); if (rbnHex.Checked) { isHex = true; } else { isHex = false; } } private void btnOpenCom_Click(object sender, EventArgs e) { if (!isOpen) { if (!CheckPortSetting())//检测串口设置 { MessageBox.Show("串口未设置!", "错误提示"); return; } if (!isSetProperty)//串口未设置则设置串口 { SetPortProperty(); isSetProperty = true; } try { serialPort.Open(); //打开串口 btnOpenCom.Text = "关闭串口"; cbxCOMPort.Enabled = false;//关闭使能 cbxBaudRate.Enabled = false; cbxStopBits.Enabled = false; cbxParity.Enabled = false; cbxDataBits.Enabled = false; rbnChar.Enabled = false; rbnHex.Enabled = false; isOpen = true; serialPort.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);//串口接收处理函数 } catch { MessageBox.Show("串口打开失败!"); } } else { try { serialPort.Close(); //关闭串口 btnOpenCom.Text = "打开串口"; cbxCOMPort.Enabled = true;//打开使能 cbxBaudRate.Enabled = true; isOpen = false; } catch { MessageBox.Show("串口关闭失败!"); } } } //private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e) //{ // string str = serialPort.ReadExisting();//字符串方式读 // tbxRecvData.Text = "";//先清除上一次的数据 // tbxRecvData.Text += str; //} private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e) { System.Threading.Thread.Sleep(100);//延时 100ms 等待接收完数据 //this.Invoke 就是跨线程访问 ui 的方法,也是本文的范例 this.Invoke((EventHandler)(delegate { if (isHex == false) { tbxRecvData.Text += serialPort.ReadLine(); } else { Byte[] ReceivedData = new Byte[serialPort.BytesToRead]; //创建接收字节数组 serialPort.Read(ReceivedData, 0, ReceivedData.Length); //读取所接收到的数据 String RecvDataText = null; for (int i = 0; i < ReceivedData.Length - 1; i++) { RecvDataText += ("0x" + ReceivedData[i].ToString("X2") + " "); } tbxRecvData.Text += RecvDataText; } serialPort.DiscardInBuffer();//丢弃接收缓冲区数据 })); } private void btnSend_Click(object sender, EventArgs e) { //发送数据 if (serialPort.IsOpen) {//如果串口开启 if (tbxSendData.Text.Trim() != "")//如果框内不为空则 { serialPort.Write(tbxSendData.Text.Trim());//写数据 } else { MessageBox.Show("发送框没有数据"); } } else { MessageBox.Show("串口未打开"); } } private void btnCleanData_Click(object sender, EventArgs e) { tbxRecvData.Text = ""; tbxSendData.Text = ""; } } } 打开串口没有提示失败,但是单片机就不运行了。
下拉 菜单 验证 我的要求是 必须选择 一个企业类型
下拉选择的 怎么进行表单验证 if ($("#enterpriseType ").get(0).selectedIndex==1){ alert("请选择企业类型 "); return false; } 这是我做的 但是不起作用 页面有一个下一步按钮 我就在下一步函数里执行这段代码 但是不起作用 <span><select name="enterpriseType" id="enterpriseType" ><option value="--请选择--">--请选择--</option><option value="代理商"<c:if test="${bean.enterpriseType=='代理商'}">selected="selected"</c:if>>代理商</option><option value="制造商"<c:if test="${bean.enterpriseType=='制造商'}">selected="selected"</c:if>>制造商</option><select></span> 我的要求是 必须选择 一个企业类型
进销存管理系统C#中,什么存在二义性,inputDataGridArray[0]这里不懂怎么改
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.SqlClient; namespace 进销存管理系统 { public partial class StockTable : Form { private LinkDataBase link = new LinkDataBase(); private DataTable newTable; //保存从”供货商信息维护”窗体中选择后传过来的数据,它们将被放入DataGrid的相 应表格中 public static string[] inputDataGridArray = new string[]{null,null,null}; //保存从”供货商信息维护”窗体中选择后传过来的数据,它们将被赋值给供货商号和名称 //的控件Text属性 //确定要赋的值为文本,故用空字符初始化 public static string[] inputDataGridArray = new string[] {"",""}; private DateTime gridMouseDownTime;//记录单击DateGrid时的时间 public StockTable() { InitializeComponent(); this.selectDataBase(); this.DataGridStateControl(); this.cmb_StokerID.Items.Add(""); } public void setWareData() { dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,0]=inputDataGridArray[0]; dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,4]=inputDataGridArray[1]; dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,5]=inputDataGridArray[2]; dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,7]=17; } private void setTextData() { this .cmb_StokerID.IntegralHeight = false; this .cmb_StokerID.DroppedDown = false; this .cmb_StokerID.Items[0] = inputDataGridArray[0]; this .cmb_StokerID.SelectedIndex= 0; this.txt_StokerName.Text= inputDataGridArray [1]; this .cmb_StokerID.IntegralHeight = true ; } private void selectDataBase() { this .txt_StockDate.Text = System .DateTime .Today.ToShortDateString (); string tempStrSQL = "select distinct 姓名from 用户清单"; DataTable tempDataTable = link.SelectDataBase(tempStrSQL); for (int i =0;i<tempDataTable .Rows .Count ;i++) this .cmb_Oprater.Items.Add(tempDataTable.Rows [i][0]); this.cmb_Oprater.SelectedIndex = 0; } private void DataGridStateControl() { newTable = new DataTable (); newTable.Columns.Add("货号(双击)",typeof (string )); newTable.Columns.Add("数量",typeof (decimal )); newTable.Columns.Add("单价",typeof (decimal )); newTable.Columns.Add("仓库",typeof(string )); newTable.Columns.Add("品名",typeof (string )); newTable.Columns.Add("单位",typeof (string )); newTable.Columns.Add("金额",typeof (decimal ),"数量单价?"); newTable.Columns.Add("税率",typeof (decimal )); newTable.Columns.Add("不含税额",typeof (decimal ),"金额/1.17"); newTable.Columns.Add("税额",typeof (decimal ),"金额-不含税额"); this .dgrd_StockTable.DataSource= newTable; newTable.Rows.Add(newTable.NewRow()); DataGridTableStyle ts = new DataGridTableStyle (); DataGridTextBoxColumn aColumnTextColumn; ts.AllowSorting = false ; ts.AlternatingBackColor = Color .LightGray ; ts.MappingName = newTable.TableName; int numCols = newTable.Columns.Count; for (int i =0;i <numCols ;i++) { aColumnTextColumn = new DataGridTextBoxColumn (); if (i!=0&&i!=1&&i!=2&&i!=3) { aColumnTextColumn .ReadOnly = true ; } if (i==0) { aColumnTextColumn .TextBox .MouseDown += new MouseEventHandler (TextBoxMouseDownHandler); } if (i==4) { aColumnTextColumn .Width =160; } if (i==3) { string sendStrSQL ="select distinct仓库from 库存库a order by 仓库ASC"; DataTable tempTable = this .link.SelectDataBase(sendStrSQL ); } else { aColumnTextColumn .MappingName = newTable.Columns[i].ColumnName; aColumnTextColumn .HeaderText = newTable.Columns[i].ColumnName; aColumnTextColumn .NullText= ""; aColumnTextColumn .Format= "N"; ts .GridColumnStyles.Add(aColumnTextColumn ); } } this .dgrd_StockTable.TableStyles.Add(ts); } private void toolBar1_Button_Click(object sender,System .Windows .Forms . ToolBarButtonClickEventArgs e) { if (e.Button .ToolTipText =="保存修改?") { clickedSaveIcon(); } else if (e.Button .ToolTipText =="删除数据") { try { if (newTable.Rows.Count>0) { this .newTable.Rows.RemoveAt(this .dgrd_StockTable.CurrentCell.RowNumber); this .controlCalculate(); } if (newTable.Rows.Count-1<=0) newTable.Rows.Add(newTable.NewRow()); } catch { return; } } else if (e.Button.ToolTipText==" 打印报表") { } } //------------创建窗体,共用户选择供货商------------ private void cmd_Stoker_DropDown(object sender ,System.EventArgs e) { StokerDataManage newFrm= new StokerDataManage(); newFrm.setDataGridReadOnly(); newFrm.ShowDialog(); setTextData(); SendKeys.Send("{Tab}"); //向活动应用程序发送Tab键,跳到下一控件 }
c#操作文件写入与打开的解决方法
public partial class read_write_file : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { // String ss = " Log CreateDate : 2017年4月9日 0:39:38";//35 //String ss = "-";//1 // string aa = "abcdef"; // int a = aa.indexOf("bc");//a会等于1 string ss = GeneralString(100, "-"); Response.Write(ss.LastIndexOf("-")); // Response.Write(GeneralString(35,"-")); } private static string GeneralString(int n, string par) { System.Text.StringBuilder a = new System.Text.StringBuilder(); for (int i = 0; i < n; i++) { a.Append(par); } return a.ToString(); } protected void Button1_Click(object sender, EventArgs e) { } protected void Button1_Click1(object sender, EventArgs e) { //Response.Write("<script type=\"text/JavaScript\">alert(" + this.ListBox1.SelectedItem.ToString() + ");</script> "); int index = ListBox1.SelectedIndex; string ss = ListBox1.Items[index].Value; // Response.Write("<script type=\"text/JavaScript\">alert('"+ss+ "');</script> "); //bool ListBoxState = false;//未选中的时候该值为false // foreach (ListItem item in this.ListBox1.Items) { // if (item.Selected) // { //ListBoxState = true;//有某一项被选中时该值就为true // Response.Write(item.Text); // } // } //if (ListBox1.SelectedIndex != -1) //{ // // MessageBox.Show(listBox1.SelectedItem.ToString()); // //MessageBox.Show(this.ListBox1.SelectedItem.ToString()); // // 原来MessageBox.Show(es.Message); 这句话在发布的服务器上无法执行,替换成如下语句 // Response.Write("<script type=\"text/JavaScript\">alert(" + this.ListBox1.SelectedItem.ToString() + ");</script> "); //} } } protected void Button2_Click(object sender, EventArgs e) { String file_path = TextBox1.Text; String str_wirte = TextBox2.Text.Trim(); if (!File.Exists(file_path))///不存在创建 { Response.Write("<font color='red'>" + file_path + "不存在,请检查!</font>"); } else if (str_wirte=="" || str_wirte ==null) {//内容不能为空 Response.Write("<font color='red'>输入内容不能为空,请检查!</font>"); } else { using (StreamWriter w = File.AppendText(file_path)) { Log(str_wirte, w); } Button3_Click( sender, e); }; } public void Log(String logMessage, TextWriter w) {//写入函数 w.Write("\r\n Log CreateDate : "); w.Write("{0} {1}",DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString()); w.Write("\0 ==>"); w.WriteLine(" {0}", logMessage); w.WriteLine(GeneralString(100,"_")); } public void DumpLog(StreamReader r) { //循环输出到lisitbox // While not at the end of the file, read and write lines. String line; int i = 1; while ((line = r.ReadLine()) != null) { //Console.WriteLine(line); if (line != "" && line.LastIndexOf("_")!= 99) { ListBox1.Items.Add(i + line); i++; } else if(line.LastIndexOf("_") == 99) { ListBox1.Items.Add(line); } } r.Close(); } protected void Button3_Click(object sender, EventArgs e) { String file_path = TextBox1.Text; ListBox1.Items.Clear(); if (!File.Exists(file_path))///不存在创建 { Response.Write("<font color='red'>" + file_path + "不存在,请检查!</font>"); } else { using (StreamReader r = File.OpenText(file_path)) { DumpLog(r); } } } protected void Button4_Click(object sender, EventArgs e) { if (ListBox1.Items.Count > 0)//删除之前记得判断是否有选中项 { //获取当前选项的索引号 int index = ListBox1.SelectedIndex; //ListBox1.ClearSelection(); ListItem item = ListBox1.Items[index]; ListBox1.Items.Remove(item); } } protected void Button6_Click(object sender, EventArgs e) { } protected void Button5_Click(object sender, EventArgs e) { } protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { } protected void ListBox1_TextChanged(object sender, EventArgs e) { //ListBox1.SelectedItem.Text =文本 //ListBox1.SelectedItem.Value 值 TextBox3.Text = "当前选择列表索引值:" + ListBox1.SelectedItem.Text; } //private void listBox1_DoubleClick(object sender, EventArgs e) //{ // MessageBox.Show(this.ListBox1.SelectedItem.ToString()); //} protected void listBox1_MouseClick(object sender, EventArgs e) { // int index = ListBox1.ine.X, e.Y); //int index = ListBox1.SelectedIndex; //Response.Write("<script type=\"text/JavaScript\">alert(" + this.ListBox1.SelectedItem.ToString() + ");</script> "); // if (ListBox1.SelectedIndex != -1) // { // // MessageBox.Show(listBox1.SelectedItem.ToString()); // //MessageBox.Show(this.ListBox1.SelectedItem.ToString()); // // 原来MessageBox.Show(es.Message); 这句话在发布的服务器上无法执行,替换成如下语句 //Response.Write("<script type=\"text/JavaScript\">alert(" + this.ListBox1.SelectedItem.ToString() + ");</script> "); } }
以下C++代码如何翻译成C#代码?
``` typedef int s32,BOOL32; #if defined(_WIN64) || defined(WIN64) ||defined (__LP64__) || defined (__64BIT__) || defined (_LP64) || (__WORDSIZE == 64) typedef unsigned int u32; #define KD_PTR void* #else typedef unsigned long u32; #define KD_PTR u32 #endif typedef unsigned char u8; typedef unsigned short u16; typedef short s16; typedef char s8; ``` ``` typedef enum eTransType { emTransChnCOMPort = 0, // 设备COM口透明数据 emTransChnCameraTaskConfig = 1, // 摄像机任务配置数据 emTransChnExtData = 2, // 透明数据,支持请求应答通知三态模型 }TransChnType; typedef struct tagTransData { tagTransData() { memset(m_byTransBuffer,0,sizeof(m_byTransBuffer)); m_wTransBufferLen = 0; m_byAppType = 0; } u8 m_byTransBuffer[MAX_TRANSCHAN_DATA_LEN+1]; u16 m_wTransBufferLen; s8 m_byAppType; } TTransChnData; typedef struct tagTransData_V2 { tagTransData_V2() { memset(m_byTransBuffer,0,sizeof(m_byTransBuffer)); m_wTransBufferLen = 0; m_byAppType = 0; m_TransChnType = emTransChnCOMPort; } u8 m_byTransBuffer[MAX_TRANSCHAN_DATA_LEN+1]; u16 m_wTransBufferLen; u16 m_byAppType; // 透明通道消息类型 TransChnType m_TransChnType; // 透明通道类型 } TTransChnData_V2; typedef struct tagTransData_V3 { tagTransData_V3() { m_pTransBuffer = NULL; m_wTransBufferLen = 0; m_byAppType = 0; m_TransChnType = emTransChnCOMPort; } u8 *m_pTransBuffer; u16 m_wTransBufferLen; // 透明串口数据大小最大值是8KB u16 m_byAppType; // 透明通道消息类型 TransChnType m_TransChnType; // 透明通道类型 } TTransChnData_V3; typedef struct tagTransDataRsp { tagTransDataRsp() { m_pTransBuffer = NULL; m_wTransBufferLen = 0; m_byAppType = 0; memset(m_szUserName, 0, sizeof(m_szUserName)); m_nPtzLevel = 0; m_dwBeginTime = 0; m_dwEndTime = 0; m_bHasNotify = FALSE; m_nErrorCode = 0; memset(m_szErrorDesc, 0, sizeof(m_szErrorDesc)); } u8 *m_pTransBuffer; // 透明通道应答数据,大小至少为8KB。内存由上层应用维护。 u16 m_wTransBufferLen; // 透明通道应答数据大小 u16 m_byAppType; // 透明通道消息类型 char m_szUserName[MAX_NAME_LEN + 1]; int m_nPtzLevel; u32 m_dwBeginTime; u32 m_dwEndTime; BOOL32 m_bHasNotify; int m_nErrorCode; char m_szErrorDesc[MAX_DESC_LEN + 1]; } TTransChnDataRsp; ``` ``` KDM_MCUSDK_API BOOL32 STDCALL Kdm_SendTransData(IN void *pMcuHandle, IN DEVCHN tDevChn, IN TTransChnData *pTransData, OUT u32 *pErrorCode); KDM_MCUSDK_API BOOL32 STDCALL Kdm_SendTransData_V2(IN void *pMcuHandle, IN DEVCHN tDevChn, IN TTransChnData_V2 *pTransData, OUT u32 *pErrorCode); KDM_MCUSDK_API BOOL32 STDCALL Kdm_SendTransData_V3(IN void *pMcuHandle, IN DEVCHN tDevChn, IN TTransChnData_V3 *pTransData, OUT TTransChnDataRsp *pTransDataRsp, OUT u32 *pErrorCode); ``` ``` void CMainFrame::SaveSensorConfigInfo() { u32 dwErrorCode = 0; TCHAR szContent[MAX_PATH] = {0}; CStdString strTemp; strTemp = m_pConfigNvrIDEdit->GetText(); strcpy(m_tSensorCfgParam.achTemID, strTemp.GetData()); strTemp = m_pConfigWidthEdit->GetText(); strcpy(m_tSensorCfgParam.achJieMianKuanDu, strTemp.GetData()); for (int nIndex = 0; nIndex < NVR_MAX_SENSOR_OSD_LINE_NUM; ++nIndex) { strTemp = m_pArrayConfigLineEdit[nIndex]->GetText(); strcpy(m_tSensorCfgParam.achOsdLine[nIndex], strTemp.GetData()); } strTemp = m_pConfigOSDXEdit->GetText(); m_tSensorCfgParam.nOsdX = atoi(strTemp.GetData()); strTemp = m_pConfigOSDYEdit->GetText(); m_tSensorCfgParam.nOsdY = atoi(strTemp.GetData()); strTemp = m_pConfigFtpAddressEdit->GetText(); strcpy(m_tSensorCfgParam.achFtpServerIp, strTemp.GetData()); strTemp = m_pConfigFtpPortEdit->GetText(); m_tSensorCfgParam.wFtpServerPort = atoi(strTemp.GetData()); strTemp = m_pConfigFtpUsrnameEdit->GetText(); strcpy(m_tSensorCfgParam.achFtpServerUsr, strTemp.GetData()); strTemp = m_pConfigFtpPasswordEdit->GetText(); strcpy(m_tSensorCfgParam.achFtpServerPwd, strTemp.GetData()); strTemp = m_pConfigHttpAddressEdit->GetText(); strcpy(m_tSensorCfgParam.achHttpServerIp, strTemp.GetData()); strTemp = m_pConfigHttpPortEdit->GetText(); m_tSensorCfgParam.wHttpServerPort = atoi(strTemp.GetData()); strTemp = m_pConfigHttpUploadURLEdit->GetText(); strcpy(m_tSensorCfgParam.achHttpUpLoadUrl, strTemp.GetData()); strTemp = m_pConfigHttpKeepURLEdit->GetText(); strcpy(m_tSensorCfgParam.achHttpKeepAliveUrl, strTemp.GetData()); int nSel = m_pPlatformNvrCombo->GetCurSel(); if (nSel != -1) { int nTag = m_pPlatformNvrCombo->GetItemAt(nSel)->GetTag(); // 透明传输 DEVCHN devChn; memset(&devChn, 0, sizeof(devChn)); devChn.deviceID = m_vcDevInfo[nTag].deviceID; devChn.domainID = m_vcDevInfo[nTag].domainID; TNvrTransData tNvrTransData; memset(&tNvrTransData, 0, sizeof(tNvrTransData)); tNvrTransData.wNvrMsgType = PLAT_NVR_CONFIG_SENSOR_REQ; tNvrTransData.wNvrBuffLen = sizeof(m_tSensorCfgParam); memcpy(tNvrTransData.m_abyNvrBuff, &m_tSensorCfgParam, sizeof(m_tSensorCfgParam)); TTransChnData_V3 tTransChnData_V3; memset(&tTransChnData_V3, 0, sizeof(tTransChnData_V3)); tTransChnData_V3.m_pTransBuffer = (u8*)&tNvrTransData; tTransChnData_V3.m_wTransBufferLen = sizeof(tNvrTransData); tTransChnData_V3.m_TransChnType = emTransChnExtData; TTransChnDataRsp tTransChnDataRsp; memset(&tTransChnDataRsp, 0, sizeof(tTransChnDataRsp)); tTransChnDataRsp.m_pTransBuffer = m_byteTransChnDataBuffer; tTransChnDataRsp.m_wTransBufferLen = sizeof(m_byteTransChnDataBuffer); BOOL32 bRet = Kdm_SendTransData_V3(m_pMcuSdkHandle, devChn, &tTransChnData_V3, &tTransChnDataRsp, &dwErrorCode); if (!bRet) { sprintf(szContent, "保存设备配置数据失败,errcode:%u", dwErrorCode); GM.DuiMessageBox(m_hWnd, szContent, "kedacom", MB_OK); } else { memset(&tNvrTransData, 0, sizeof(tNvrTransData)); memcpy(&tNvrTransData, m_byteTransChnDataBuffer, sizeof(tNvrTransData)); if (tNvrTransData.wErrorCode != 0) { sprintf(szContent, "保存设备配置数据失败,errcode:%u", tNvrTransData.wErrorCode); GM.DuiMessageBox(m_hWnd, szContent, "kedacom", MB_OK); } } } } ``` 尝试修改为以下C#代码,运行成功,但是执行时候报错: ``` [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] public struct tagTransData { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 513)] public byte[] m_byTransBuffer; public ushort m_wTransBufferLen; public char m_byAppType; } [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] public struct tagTransData_V2 { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 513)] public byte[] m_byTransBuffer; public ushort m_wTransBufferLen; public ushort m_byAppType; // 透明通道消息类型 public eTransType m_TransChnType; // 透明通道类型 } [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] public unsafe struct tagTransData_V3 { public byte* m_pTransBuffer; public ushort m_wTransBufferLen; // 透明串口数据大小最大值是8KB public ushort m_byAppType; // 透明通道消息类型 public eTransType m_TransChnType; // 透明通道类型 } [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] public unsafe struct tagTransDataRsp { public byte* m_pTransBuffer; // 透明通道应答数据,大小至少为8KB。内存由上层应用维护。 public ushort m_wTransBufferLen; // 透明通道应答数据大小 public ushort m_byAppType; // 透明通道消息类型 public char* m_szUserName; public int m_nPtzLevel; public uint m_dwBeginTime; public uint m_dwEndTime; public uint m_bHasNotify; public int m_nErrorCode; public char* m_szErrorDesc; } ``` ``` [DllImport(@"mcusdk.dll")] public extern static uint Kdm_SendTransData(IntPtr pMcuHandle, DEVCHN tDevChn, tagTransData pTransData, ref uint pErrorCode); [DllImport(@"mcusdk.dll")] public extern static uint Kdm_SendTransData_V2(IntPtr pMcuHandle, DEVCHN tDevChn, tagTransData_V2 TransData, ref uint pErrorCode); [DllImport(@"mcusdk.dll")] public extern static uint Kdm_SendTransData_V3(IntPtr pMcuHandle, DEVCHN tDevChn, tagTransData_V3 pTransData, ref tagTransDataRsp pTransDataRsp, ref uint pErrorCode); ``` ``` private unsafe void btnSave_Click(object sender, EventArgs e) { uint dwErrorCode = 0; TSensorCfgParam m_tSensorCfgParam=new TSensorCfgParam(); sbyte[] szContent = new sbyte[DefineConstants.MAX_PATH]; m_tSensorCfgParam.achTemID = txtNVRID.Text; m_tSensorCfgParam.achJieMianKuanDu = txtWidth.Text; //for (int nIndex = 0; nIndex < NVR_MAX_SENSOR_OSD_LINE_NUM; ++nIndex) //{ // strTemp = m_pArrayConfigLineEdit[nIndex].GetText(); // m_tSensorCfgParam.achOsdLine[nIndex] = strTemp.GetData(); //} //strTemp = m_pConfigOSDXEdit.GetText(); //m_tSensorCfgParam.nOsdX = Convert.ToInt32(strTemp.GetData()); //strTemp = m_pConfigOSDYEdit.GetText(); //m_tSensorCfgParam.nOsdY = Convert.ToInt32(strTemp.GetData()); //strTemp = m_pConfigFtpAddressEdit.GetText(); //m_tSensorCfgParam.achFtpServerIp = strTemp.GetData(); //strTemp = m_pConfigFtpPortEdit.GetText(); //m_tSensorCfgParam.wFtpServerPort = Convert.ToInt32(strTemp.GetData()); //strTemp = m_pConfigFtpUsrnameEdit.GetText(); //m_tSensorCfgParam.achFtpServerUsr = strTemp.GetData(); //strTemp = m_pConfigFtpPasswordEdit.GetText(); //m_tSensorCfgParam.achFtpServerPwd = strTemp.GetData(); //strTemp = m_pConfigHttpAddressEdit.GetText(); //m_tSensorCfgParam.achHttpServerIp = strTemp.GetData(); //strTemp = m_pConfigHttpPortEdit.GetText(); //m_tSensorCfgParam.wHttpServerPort = Convert.ToInt32(strTemp.GetData()); //strTemp = m_pConfigHttpUploadURLEdit.GetText(); //m_tSensorCfgParam.achHttpUpLoadUrl = strTemp.GetData(); //strTemp = m_pConfigHttpKeepURLEdit.GetText(); //m_tSensorCfgParam.achHttpKeepAliveUrl = strTemp.GetData(); int nSel = lbDevice.SelectedIndex; if (nSel != -1) { //int nTag = m_pPlatformNvrCombo.GetItemAt(nSel).GetTag(); // 透明传输 DEVCHN devChn = new DEVCHN(); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memset' has no equivalent in C#: //Comm.memset(devChn, 0, sizeof(DEVCHN)); devChn.deviceID = deviceList[nSel].deviceID; devChn.domainID = deviceList[nSel].domainID; TNvrTransData tNvrTransData = new TNvrTransData(); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memset' has no equivalent in C#: //Comm.memset(tNvrTransData, 0, sizeof(TNvrTransData)); tNvrTransData.wNvrMsgType = DefineConstants.PLAT_NVR_CONFIG_SENSOR_REQ; //tNvrTransData.wNvrBuffLen = sizeof(m_tSensorCfgParam); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memcpy' has no equivalent in C#: //Comm.memcpy(tNvrTransData.m_abyNvrBuff, m_tSensorCfgParam, sizeof(m_tSensorCfgParam)); tagTransData_V3 tTransChnData_V3 = new tagTransData_V3(); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memset' has no equivalent in C#: //Comm.memset(tTransChnData_V3, 0, sizeof(TTransChnData_V3)); tTransChnData_V3.m_pTransBuffer = (byte)&tNvrTransData; //tTransChnData_V3.m_pTransBuffer = (byte*) ref (tNvrTransData)[0]; //tTransChnData_V3.m_wTransBufferLen = sizeof(TNvrTransData); tTransChnData_V3.m_TransChnType = eTransType.emTransChnExtData; tagTransDataRsp tTransChnDataRsp = new tagTransDataRsp(); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memset' has no equivalent in C#: //Comm.memset(tTransChnDataRsp, 0, sizeof(tagTransDataRsp)); m_byteTransChnDataBuffer = new byte[8 * 1024]; tTransChnDataRsp.m_pTransBuffer = (byte*)m_byteTransChnDataBuffer[0]; //tTransChnDataRsp.m_wTransBufferLen = sizeof(m_byteTransChnDataBuffer); uint bRet = myAPI.Kdm_SendTransData_V3(mcuHandle, devChn, tTransChnData_V3, ref tTransChnDataRsp, ref dwErrorCode); if (bRet == 0) { //szContent = string.Format("保存设备配置数据失败,errcode:{0:D}", dwErrorCode); //GM.DuiMessageBox(m_hWnd, szContent, "kedacom", MB_OK); } else { //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memset' has no equivalent in C#: //memset(tNvrTransData, 0, sizeof(TNvrTransData)); //C++ TO C# CONVERTER CRACKED BY X-CRACKER 2017 TODO TASK: The memory management function 'memcpy' has no equivalent in C#: //memcpy(tNvrTransData, m_byteTransChnDataBuffer, sizeof(TNvrTransData)); if (tNvrTransData.wErrorCode != 0) { //szContent = string.Format("保存设备配置数据失败,errcode:{0:D}", tNvrTransData.wErrorCode); //GM.DuiMessageBox(m_hWnd, szContent, "kedacom", MB_OK); } } } } ``` 求大神翻译
<input type="button" value="check it" onclick="sendRequest();" /> 点击提示缺少对象
<input type="button" value="check it" onclick="sendRequest();" /> [color=red]点击后提示缺少对象什么原因[/color]<script language=javascript"> var XMLHttpReq; var url=null; var type=null; //创建XMLHttpRequest对象 function createXMLHttpRequest() { if(window.XMLHttpRequest) { //Mozilla 浏览器 XMLHttpReq = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE浏览器 try { XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } } //发送请求函数 function sendRequest() { createXMLHttpRequest(); var url = "/GetnameInfo"; XMLHttpReq.open("GET", url, true); XMLHttpReq.onreadystatechange = getYg_name;//指定响应函数 XMLHttpReq.send(null); // 发送请求 } // 处理返回信息函数 function getYg_name() { if (XMLHttpReq.readyState == 4) { // 判断对象状态 if (XMLHttpReq.status == 200) { // 信息已经成功返回,开始处理信息 var count = XMLHttpReq.responseXML.getElementsByTagName("count")[0].firstChild.nodeValue; for(var i=0;i<count;i++) { var name = XMLHttpReq.responseXML.getElementsByTagName("name")[i].firstChild.nodeValue; var ygid=XMLHttpReq.responseXML.getElementsByTagName("ygid")[i].firstChild.nodeValue; var op = new Option(name[i].childNodes[i].nodeValue,ygid[i].childNodes[0].nodeValue); selectObj.options.add(op); } } } } else { //页面不正常 window.alert("您所请求的页面有异常。"); } } } function nameinfo() { this.options[selectedIndex].text } </script> <body > <table bgcolor="#F1E1FF" width="100%" height="5%"> <tr> <td> <center> <font size="12" color="RED">员工基本信息</font> </center> </td> </tr> </table> <form name="form1"> <table> <tr> <td bgcolor="#ACD6FF"> <font size="12">部门</font> </td> <td id='tdname'> <font size="6">姓 名</font> <select name="sbox" id="selectid" style="width: 150px" onchange="nameinfo()" /> <input type="text" id="tx1" value="" name="tx1" /> </td> </tr> <tr> <td id="td1"> <br> <input type="button" id="but1" value="开发部" onclick="sendRequest();" style="width: 120px; height: 30px; background-Color: #9cc5f8"> <br> <input type="button" id="but2" value="人事部" style="width: 120px; height: 30px; background-Color: #9cc5f8"> <br> <input type="button" id="but3" value="财务部" style="width: 120px; height: 30px; background-Color: #9cc5f8"> <br> <input type="button" id="but4" value="业务部" style="width: 120px; height: 30px; background-Color: #9cc5f8"> </td> <td></td> </tr> </table> </form> </body>
C#程序调用SQL SERVER存储过程的output参数始终为空,求助?
C#中的如下两条语句调用存储过程output参数始终为空(dataGridView1能正确调用到想要的select数据,但是存储过程的两个输出参数值不能传递给两个texBox.Text),不知为何? textBox1.Text = parameters[2].Value.ToString(); textBox2.Text = nowpage + "/" + parameters[3].Value.ToString(); 存储过程代码: ``` USE [tushu] GO /****** Object: StoredProcedure [dbo].[fenye] Script Date: 12/05/2015 11:03:20 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[fenye] @pagenow int, @pagesize int, @countrow int output, @countpage int output AS IF(@pagesize=10) BEGIN declare @startRow int, @endRow int set @startRow = (@pagenow - 1) * @pagesize +1 set @endRow = @startRow + @pagesize -1 select checkbox,id,shuming,zuozhe,xueduan,nianji,beizhu from book where id between @startRow and @endRow order by id desc select @countrow=count(*) from book SET @countpage=(@countrow/@pagesize)+1 END ``` C#代码片段: ``` private void chaxun_Click(object sender, EventArgs e) { //查询条件默认 xueduan.SelectedIndex = 0; nianji.SelectedIndex = 0; hangshu.SelectedIndex = 0;//每页行数,默认10条每页 //tiaopage.Text = ""; //数据统计 //int counthang = 0; //int countpage = 0; int nowpage = 1; int sizepage = 10; int tiaopage = int.Parse(tiaozhuan.Text.Trim()); string xueDuan = xueduan.Text; string nianJi = nianji.Text; string shuMing = shuming.Text.Trim();//自动剔除收尾空格 string condatabase = ConfigurationManager.ConnectionStrings["mysql"].ConnectionString; string sql = "exec fenye @pagenow,@pagesize,NULL,NULL";//@countrow,@countpage SqlConnection conn = new SqlConnection(condatabase); dataGridView1.Rows.Clear(); try { SqlCommand cmmd = new SqlCommand(sql, conn);//执行SQL查询 // 创建参数 IDataParameter[] parameters = { new SqlParameter("@pagenow", SqlDbType.Int) , new SqlParameter("@pagesize", SqlDbType.Int) , new SqlParameter("@countrow", SqlDbType.Int) , new SqlParameter("@countpage", SqlDbType.Int) }; // 设置参数类型 parameters[0].Value = nowpage; parameters[1].Value = sizepage; // 设置为输出参数 parameters[2].Direction = ParameterDirection.Output; //设置为输出参数 parameters[3].Direction = ParameterDirection.Output; // 添加参数 cmmd.Parameters.Add(parameters[0]); cmmd.Parameters.Add(parameters[1]); cmmd.Parameters.Add(parameters[2]); cmmd.Parameters.Add(parameters[3]); conn.Open(); System.Data.DataTable dt = new System.Data.DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmmd); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { this.dataGridView1.Rows.Add(dt.Rows[i][0], dt.Rows[i][1], dt.Rows[i][2], dt.Rows[i][3], dt.Rows[i][4], dt.Rows[i][5], dt.Rows[i][6]); } if (dataGridView1.RowCount != 0) { dataGridView1.Rows[0].Cells[0].Selected = false;//设置列表首行默认不选中 } textBox1.Text = parameters[2].Value.ToString(); textBox2.Text = nowpage + "/" + parameters[3].Value.ToString(); } catch (Exception yichang) { MessageBox.Show(yichang.Message); } finally { conn.Close();//关闭数据库连接 } } ```
C# 无法触发窗口弹出 show方法不生效
要做一个基于UDP的群聊加私聊程序,群聊已经实现了,私聊也已经单独实现了,但是我想让着两个窗体有联系,就想QQ一样,PC1发消息的时候,PC2 自动弹出消息窗口。 登录窗体: using System.Net; namespace NetMeetingExample { public partial class FormLogin : Form { public FormLogin() { InitializeComponent(); } private void Login_Load(object sender, EventArgs e) { this.textBox1.Text = Dns.GetHostName().ToString(); } public static string nicheng; public static string group; private void button1_Click(object sender, EventArgs e) { nicheng = textBox1.Text; group =comboBox1.Text; //this.Opacity = 0; this.DialogResult = DialogResult.OK; } private void button2_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } } } 群聊窗体: using System.Net; using System.Net.Sockets; using System.Threading; namespace NetMeetingExample { public partial class FormMeeting : Form { private enum ListBoxOperation { AddItem, RemoveItem }; private delegate void SetListBoxItemCallback( ListBox listbox, string text, ListBoxOperation operation); SetListBoxItemCallback listBoxCallback; //使用的IP地址 private IPAddress broderCastIp = IPAddress.Parse("224.100.0.1"); //使用的接收端口号 public static int port = 8001; private UdpClient udpClient; public FormMeeting() { if (FormLogin.group=="101021") { broderCastIp = IPAddress.Parse("224.100.0.1"); } if (FormLogin.group == "101022") { broderCastIp = IPAddress.Parse("224.100.0.2"); } if (FormLogin.group == "101023") { broderCastIp = IPAddress.Parse("224.100.0.3"); } if (FormLogin.group == "101024") { broderCastIp = IPAddress.Parse("224.100.0.4"); } InitializeComponent(); listBoxCallback = new SetListBoxItemCallback(SetListBoxItem); this.Text = FormLogin.group; } private void SetListBoxItem(ListBox listbox, string text, ListBoxOperation operation) { string[] cc;//= splitString[1].Split('@'); if (listbox.InvokeRequired == true) { this.Invoke(listBoxCallback, listbox, text, operation); } else { if (operation == ListBoxOperation.AddItem) { if (listbox == listBoxAddress) { if (listbox.Items.Contains(text) == false) if (text != "") { { cc=text.Split('@'); string oo = cc[0]; listBoxMessage.Items.Add(oo+"进入。"); listbox.Items.Add(text); } } } else { if (text != "[]进入。") { listbox.Items.Add(text); // SetListBoxItem(listBoxMessage, // string.Format("[{0}]进入。",cc[0]), ListBoxOperation.AddItem); } } listbox.SelectedIndex = listbox.Items.Count - 1; listbox.ClearSelected(); } else if (operation == ListBoxOperation.RemoveItem) { cc = text.Split('@'); // SetListBoxItem(listBoxMessage, // string.Format("[{0}]退出。", cc[0]), ListBoxOperation.AddItem); // // listBoxMessage.Items.Add(string.Format("[{0}]退出。", cc[0])); string oo = cc[0]; listBoxMessage.Items.Add(oo+"退出。"); listbox.Items.Remove(text); } } } public static void SendMessage(IPAddress ip, string sendString) { UdpClient myUdpClient = new UdpClient(); //允许发送和接收广播数据报 // myUdpClient.EnableBroadcast = true; //必须使用组播地址范围内的地址 IPEndPoint iep = new IPEndPoint(ip, port); //将发送内容转换为字节数组 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(sendString); try { //向子网发送信息 myUdpClient.Send(bytes, bytes.Length, iep); } catch (Exception err) { MessageBox.Show(err.Message, "发送失败"); } finally { myUdpClient.Close(); } } public static IPAddress ipp; private void FormMeeting_Load(object sender, EventArgs e) { listBoxMessage.HorizontalScrollbar = true; buttonLogin.Enabled = true; buttonLogout.Enabled = false; groupBoxRoom.Enabled = false; IPAddress[] iph = Dns.GetHostAddresses(Dns.GetHostName()); ipp = iph[iph.Length-2]; } /// <summary> /// 接收线程 /// </summary> private void ReceiveMessage() { udpClient = new UdpClient(port); //必须使用组播地址范围内的地址 udpClient.JoinMulticastGroup(broderCastIp); udpClient.Ttl = 50; IPEndPoint remote = null; while (true) { try { //关闭udpClient时此句会产生异常 byte[] bytes = udpClient.Receive(ref remote); string str = Encoding.UTF8.GetString(bytes, 0, bytes.Length); string[] splitString = str.Split(','); int s = splitString[0].Length; //string[] splithostname; // splithostname= splitString[1].Split('@'); string[] mhost; mhost = splitString[1].Split('@'); switch (splitString[0]) { case "Login": //进入会议室 // SetListBoxItem(listBoxMessage, // string.Format("[{0}]进入。", splithostname[0]), ListBoxOperation.AddItem); SetListBoxItem(listBoxAddress, splitString[1], ListBoxOperation.AddItem); string userListString = "List," ; for (int i = 0; i < listBoxAddress.Items.Count; i++) { userListString += "," + listBoxAddress.Items[i].ToString(); } SendMessage(remote.Address, userListString); break; case "List": //参加会议人员名单 for (int i = 1; i < splitString.Length; i++) { SetListBoxItem(listBoxAddress, splitString[i], ListBoxOperation.AddItem); // SetListBoxItem(listBoxMessage, // string.Format("[{0}]进入。", splithostname[0]), ListBoxOperation.AddItem); } break; case "Message": //发言内容 SetListBoxItem(listBoxMessage, string.Format("[{0}]说:{1}", mhost[0], mhost[1]), ListBoxOperation.AddItem); break; case "Logout": //退出会议室 // SetListBoxItem(listBoxMessage, // string.Format("[{0}]退出。", FormLogin.nicheng), // ListBoxOperation.AddItem); // SetListBoxItem(listBoxMessage, // string.Format("[{0}]退出。", splithostname[0]), ListBoxOperation.AddItem); SetListBoxItem(listBoxAddress, FormLogin.nicheng + "@" + remote.Address.ToString(), ListBoxOperation.RemoveItem); break; case "mi": FormChat fc = new FormChat(); fc.Owner = this; fc.Show(); // MessageBox.Show("sfs"); break; } } catch { //退出循环,结束线程 break; } } } private void textBoxMessage_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Return) { if (textBoxMessage.Text.Trim().Length > 0) { SendMessage(broderCastIp, "Message," + FormLogin.nicheng+"@"+ textBoxMessage.Text); textBoxMessage.Text = ""; } } } //窗体已关闭并指定关闭原因前触发的事件 private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (buttonLogout.Enabled == true) { MessageBox.Show("请先离开会议室,然后再退出!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); //不关闭窗体 e.Cancel = true; } } //单击进入会议室按钮触发的事件 private void buttonLogin_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; Thread myThread = new Thread(ReceiveMessage); myThread.Start(); //等待接收线程准备完毕 Thread.Sleep(1000); SendMessage(broderCastIp, "Login,"); buttonLogin.Enabled = false; buttonLogout.Enabled = true; groupBoxRoom.Enabled = true; // SetListBoxItem(listBoxMessage, // string.Format("[{0}]进入。", FormLogin.nicheng), ListBoxOperation.AddItem); SetListBoxItem(listBoxAddress, FormLogin.nicheng + "@" +ipp.ToString(), ListBoxOperation.AddItem); string userListString = "List," + FormLogin.nicheng + "@" + ipp.ToString(); SendMessage(broderCastIp , userListString); Cursor.Current = Cursors.Default; } //单击退出会议室按钮触发的事件 private void buttonLogout_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; SendMessage(broderCastIp, "Logout,"); udpClient.DropMulticastGroup(this.broderCastIp); //等待接收线程处理完毕 Thread.Sleep(1000); //结束接收线程 udpClient.Close(); buttonLogin.Enabled = true; buttonLogout.Enabled = false; groupBoxRoom.Enabled = false; Cursor.Current = Cursors.Default; } private void button1_Click(object sender, EventArgs e) { // string add = "sdfsdf-192.168.22.3"; //string[] omg = add.Split('@'); // MessageBox.Show(omg[1].ToString()); //FormChat FC = new FormChat(); // FC.Owner = this; // FC.Show(); } public static string[] omg; private void listBoxAddress_MouseDoubleClick(object sender, MouseEventArgs e) { string add = listBoxAddress.SelectedItem.ToString(); omg = add.Split('@'); FormChat fc = new FormChat(); fc.Owner = this; fc.Show(); } } } 私聊窗体 using System.Net; using System.Net.Sockets; using System.Threading; namespace NetMeetingExample { public partial class FormChat : Form { /// <summary>接收用</summary> private UdpClient receiveUdpClient; /// <summary>发送用</summary> private UdpClient sendUdpClient; /// <summary>和本机绑定的端口号</summary> private const int port = 18001; /// <summary>本机IP</summary> IPAddress ip; /// <summary>远程主机IP</summary> IPAddress remoteIp; public FormChat() { InitializeComponent(); IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); ip = ips[ips.Length - 1]; //为了在同一台机器调试,此IP也作为默认远程IP // remoteIp = ip; remoteIp = IPAddress.Parse(FormMeeting.omg[1]); textBoxRemoteIP.Text = FormMeeting.omg[1]; textBoxSend.Text = "你好!"; } private void buttonSend_Click(object sender, EventArgs e) { Thread t = new Thread(SendMessage); t.IsBackground = true; t.Start(textBoxSend.Text); } private void FormChat_Load(object sender, EventArgs e) { //创建一个线程接收远程主机发来的信息 Thread myThread = new Thread(ReceiveData); //将线程设为后台运行 myThread.IsBackground = true; myThread.Start(); textBoxSend.Focus(); } private void SendMessage(object obj) { string message = (string)obj; sendUdpClient = new UdpClient(0); byte[] bytes = System.Text.Encoding.Unicode.GetBytes(message); IPEndPoint iep = new IPEndPoint(remoteIp, port); try { sendUdpClient.Send(bytes, bytes.Length, iep); AddItem(listBoxStatus, string.Format("向{0}发送:{1}", iep, message)); ClearTextBox(); } catch (Exception ex) { AddItem(listBoxStatus, "发送出错:" + ex.Message); } } private void ReceiveData() { IPEndPoint local = new IPEndPoint(ip, port); receiveUdpClient = new UdpClient(local); IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0); while (true) { try { //关闭udpClient时此句会产生异常 byte[] receiveBytes = receiveUdpClient.Receive(ref remote); string receiveMessage = Encoding.Unicode.GetString( receiveBytes, 0, receiveBytes.Length); AddItem(listBoxReceive, string.Format("来自{0}:{1}", remote, receiveMessage)); } catch { break; } } } delegate void AddListBoxItemDelegate(ListBox listbox, string text); private void AddItem(ListBox listbox, string text) { if (listbox.InvokeRequired) { AddListBoxItemDelegate d = AddItem; listbox.Invoke(d, new object[] { listbox, text }); } else { listbox.Items.Add(text); listbox.SelectedIndex = listbox.Items.Count - 1; listbox.ClearSelected(); } } delegate void ClearTextBoxDelegate(); private void ClearTextBox() { if (textBoxSend.InvokeRequired) { ClearTextBoxDelegate d = ClearTextBox; textBoxSend.Invoke(d); } else { textBoxSend.Clear(); textBoxSend.Focus(); } } private void button1_Click(object sender, EventArgs e) { FormMeeting.SendMessage(remoteIp, "mi," + "hello~"); // SendMessage(broderCastIp, "Message," + textBoxMessage.Text); } } } Program.cs static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FormLogin fl = new FormLogin(); if (fl.ShowDialog() == DialogResult.OK) { Application.Run(new FormMeeting()); } else { Application.Exit(); } 在私聊窗体里单击BUTTON1会向对端发送“mi”命令从而触发对端的窗体弹出,函数能进去,但窗体就是不弹出,另外将弹出写在button_click下,然后在mi下执行button的_click事件也不能触发,,但是单独单击却能打开,函数是能进来的 求高人解决。。。。。。。。。。
关于WebBrowser 读取 JS数据问题 ??
``` <script type="text/javascript"> var s = selects; var a = document.getElementById('futures_exchange'); var b = document.getElementById('futures_variety'); var c = document.getElementById('futures_contract'); s.bind(b, cv); s.bind(c, cc); s.parent(a, b); s.parent(b, c); s.selected(a, { value: exchange }); s.selected(b, { value: variety }); if (c[1] == undefined || contract != "") { s.selected(c, { value: contract }); } else { s.selected(c, { value: c[1].value }); } s._addEvent(a, "change", function () { var exValue = a[a.selectedIndex].value; exValue if (exValue == "069001005") { } else if (exValue == "069001007") { } else if (exValue == "069001008") { } document.getElementById("inputDate").value = date; }); // 跳转页面 function gotoJcgc(obj) { window.location.href = obj.getAttribute("value") + "?ex=" + a[a.selectedIndex].value + "&va=" + b[b.selectedIndex].value + "&ct=" + c[c.selectedIndex].value; } // 查询事件 function searchData(blOnload) { document.getElementById("PageNav").style.display = "none"; var dataUrl = "http://datainterface.eastmoney.com/EM_DataCenter/JS.aspx?type=QHCC&sty=QHSYCC&stat=3&fd=" + document.getElementById('inputDate').value + "&mkt=" + a[a.selectedIndex].value + "&code=" + c[c.selectedIndex].value + "&sc=" + b[b.selectedIndex].value; FuturesJS.getData(dataUrl, "qhlhList", blOnload, date); } window.onload = function () { document.getElementById("inputDate").value = date; // 编辑查询条件并获取数据 searchData(true); } </script> ``` 请问我用delphi 或C#怎样写才能得到返回的data数据???
jsp无法加载高影仪插件(Object)
想请教个问题:我采用jsp调用高影仪进行拍摄,有个奇怪的现行,我用IE浏览器打开编写好的jsp页面,可以正常调用高影仪进行拍摄;但是我将同样的jsp页面放在tomcat容器中运行,调不起来了。通过eclipse进行调试,提示每个函数,麻烦各位大神帮我看看,具体的代码如下: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <OBJECT id="CamSDKOCX" style="MARGIN-LEFT:5px; WIDTH: 100%; HEIGHT:70%" classid="clsid:556DBC8A-FE4A-4DA7-A82E-3926C8D4AC41" > </OBJECT> <div style= "border:1px solid #000000"> <select name="adjust" id="adjust" style = "margin-left:180px" onchange = "SetEffect()"> <option value="0">不优化</option> <option value="1">文档优化</option> <option value="2">彩页优化</option> </select> <select name="autocrop" id="autocrop" style = "margin-left:180px" onchange = "SetState()"> <option value="0">不裁切</option> <option value="1">单图裁切</option> <option value="2">多图裁切</option> </select> <input id="SetCusState" type="checkbox" value="" onClick="SetCusState(this)" style = "margin-left:180px" />手动裁切 <input type = "button" value = "拍摄" onClick = "Capture();" name = "Capture" style = "margin-left:180px"> </div> </body> </html> <script type="text/javascript"> var strFile; var Width = 0; var Height = 0; var mainIndex = 0; var index = 0; var strFile = "D:\\test.jpg" function StartVideo() { var aa = CamSDKOCX.InitCameraLib(); alert(aa); CamSDKOCX.OpenDev(0,0,3264,2448); } function SetEffect() { var obj=document.getElementById("adjust") ; var index=obj.selectedIndex; CamSDKOCX.SetAdjust(index); } function SetState() { var obj=document.getElementById("autocrop") ; var index=obj.selectedIndex; CamSDKOCX.SetAutoCrop(index); } function SetCusState(obj) { var statcuscrop = obj.checked; CamSDKOCX.SetCusCrop(statcuscrop); } function Capture() { CamSDKOCX.CaptureImage(strFile); nFileCount ++; } </script> <SCRIPT> setTimeout("StartVideo()",100); SetState.checked = true; </SCRIPT>
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
这30个CSS选择器,你必须熟记(上)
关注前端达人,与你共同进步CSS的魅力就是让我们前端工程师像设计师一样进行网页的设计,我们能轻而易举的改变颜色、布局、制作出漂亮的影音效果等等,我们只需要改几行代码,不需...
国产开源API网关项目进入Apache孵化器:APISIX
点击蓝色“程序猿DD”关注我回复“资源”获取独家整理的学习资料!近日,又有一个开源项目加入了这个Java开源界大名鼎鼎的Apache基金会,开始进行孵化器。项目名称:AP...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
编写Spring MVC控制器的14个技巧
本期目录 1.使用@Controller构造型 2.实现控制器接口 3.扩展AbstractController类 4.为处理程序方法指定URL映射 5.为处理程序方法指定HTTP请求方法 6.将请求参数映射到处理程序方法 7.返回模型和视图 8.将对象放入模型 9.处理程序方法中的重定向 10.处理表格提交和表格验证 11.处理文件上传 12.在控制器中自动装配业务类 ...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
求小姐姐抠图竟遭白眼?痛定思痛,我决定用 Python 自力更生!
点击蓝色“Python空间”关注我丫加个“星标”,每天一起快乐的学习大家好,我是 Rocky0429,一个刚恰完午饭,正在用刷网页浪费生命的蒟蒻...一堆堆无聊八卦信息的网页内容慢慢使我的双眼模糊,一个哈欠打出了三斤老泪,就在此时我看到了一张图片:是谁!是谁把我女朋友的照片放出来的!awsl!太好看了叭...等等,那个背景上的一堆鬼画符是什么鬼?!真是看不下去!叔叔婶婶能忍,隔壁老王的三姨妈的四表...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
相关热词 如何提升c#开发能力 矩阵乘法c# c#调用谷歌浏览器 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天
立即提问

相似问题