public int Logins(String Username, String PWD) { DataSet ds = null; int tag = 0; try { string strSql = string.Format("select 1 tag from TUser where UserName= '******' and PWD='{1}'", Username, PWD); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { //tag =Convert.ToInt32(dt.Rows[0]["tag"]); tag = (int)dt.Rows[0]["tag"]; } } return(tag); } catch { return(0); } }
private void queryCount() { DataSet ds = null; try { string strSql = string.Format("SELECT SUM(b.Num) num,SUM(b.Price) price FROM dbo.TSale a,dbo.TCusForm b,dbo.TCustomer c WHERE a.ID=b.SID and b.CID=c.ID AND b.Tag<>0 AND c.CName like '%{0}%' and b.FID like '%{1}%'", txt_name.Text, textBox1.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; lab_num.Text = dt.Rows[0]["num"].ToString(); lab_price.Text = dt.Rows[0]["price"].ToString(); } else { lab_num.Text = ""; lab_price.Text = ""; } } catch { lab_num.Text = ""; lab_price.Text = ""; } }
private void queryTag() { DataSet ds = null; try { string strSql = string.Format("SELECT a.tag FROM dbo.TForm a,dbo.TCusForm b,dbo.TCustomer c WHERE a.FID=b.FID AND b.CID=c.ID AND b.Tag=1 AND c.CName='{0}'", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; if (dt.Rows[0]["tag"].ToString().Equals("0")) { lab_tap.Text = "未上传"; btn_up.Visible = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } } } catch { } }
private void query2() { DataSet ds = null; try { string strSql = string.Format("SELECT b.ID,a.SName,a.Norms,a.Texture,b.Num,b.Price FROM dbo.TSale a,dbo.TCusForm b WHERE a.ID=b.SID and b.CID='{0}' and b.tag=0", ID); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["ID"].ColumnName = "订单ID"; dt.Columns["SName"].ColumnName = "产品名称"; dt.Columns["Norms"].ColumnName = "规格"; dt.Columns["Texture"].ColumnName = "材质"; dt.Columns["Num"].ColumnName = "数量"; dt.Columns["Price"].ColumnName = "总价格"; this.dataGridView2.DataSource = dt.DefaultView; //AutoSizeColumn(dataGridView2); } else { if (dataGridView2.DataSource != null) { dataGridView2.DataSource = null; } } } catch { } }
private void btn_zhen_Click(object sender, EventArgs e) { DataSet ds = null; int result = -1; try { string strSql = string.Format("exec UP_TCustomer '{0}','{1}','{2}','{3}','{4}'", ID, txt_username.Text, txt_phone.Text, txt_email.Text, txt_address.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } if (result == -1) { MessageBox.Show("新增失败,请稍后重试!", "提示"); isUser = false; } else { MessageBox.Show("新增成功!", "提示"); ID = result; btn_zhen.Enabled = false; isUser = true; } }
private void query() { DataSet ds = null; try { string strSql = string.Format("select ID,SName,Norms,Texture,Price,Num from TSale where SName like '%{0}%'", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["ID"].ColumnName = "产品ID"; dt.Columns["SName"].ColumnName = "产品名称"; dt.Columns["Norms"].ColumnName = "规格"; dt.Columns["Texture"].ColumnName = "材质"; dt.Columns["Price"].ColumnName = "价格"; dt.Columns["Num"].ColumnName = "库存数量"; this.dataGridView1.DataSource = dt.DefaultView; //AutoSizeColumn(dataGridView1); } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } } } catch { } }
private void btn_del_Click(object sender, EventArgs e) { if (dataGridView2.RowCount == 0) { MessageBox.Show("没有选中任何订单,请选中后重试!", "提示"); } else { int a = dataGridView2.CurrentRow.Index; int id = (int)dataGridView2.Rows[a].Cells[0].Value; DataSet ds = null; int result = -1; try { string strSql = string.Format("exec UP_TCusForm_Delete '{0}'", id); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } if (result == 0) { MessageBox.Show("删除成功!", "提示"); query2(); } } }
public List <string> GetLinkMan(String FranchiserID) { DataSet ds = null; List <string> list = new List <string>(); try { string strSql = string.Format("exec APP_GetLinkManInfo '{0}'", FranchiserID); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { //LinkMan a = new LinkMan(); //a.setLinkManName(dt.Rows[i]["LinkManName"].ToString()); //a.setLinkManMobile(dt.Rows[i]["LinkManMobile"].ToString()); //a.setEmail(dt.Rows[i]["Email"].ToString()); //list.Add(a); } } //return MySqlDbFunc.ExecSql(strSql); return(list); } catch { return(null); } }
private void query() { DataSet ds = null; try { string strSql = string.Format("select ID,SName,Price,BasePrice from TSale where SName like '%{0}%'", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["ID"].ColumnName = "产品ID"; dt.Columns["SName"].ColumnName = "产品名称"; dt.Columns["Price"].ColumnName = "销售价格"; dt.Columns["BasePrice"].ColumnName = "基础报价"; this.dataGridView1.DataSource = dt.DefaultView; if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } } } catch { } }
//上传收货凭证 private void btn_up2_Click(object sender, EventArgs e) { string filePath = ""; FID = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString(); //创建文件弹出选择窗口(包括文件名)对象 OpenFileDialog ofd = new OpenFileDialog(); //判断选择的路径 if (ofd.ShowDialog() == DialogResult.OK) { progressBar1.Visible = true; //this.txtSoundPath.Text = ofd.FileName.ToString(); filePath = ofd.FileName.ToString(); try { //上传后文件保存的名称 string saveName = FID + "_SHPZ" + ".jpg"; int count = UpFile.UpSound_Request(filePath, saveName, this.progressBar1); if (count > 0) { MessageBox.Show("上传文件成功!"); progressBar1.Visible = false; DataSet ds = null; int result = -1; try { DateTime currentTime = DateTime.Now; string time = currentTime.ToString("yyyy-MM-dd HH:mm:ss"); string strSql = string.Format("exec UP_TLogistics_ADD '{0}','{1}','{2}','{3}','{4}','{5}'", FID, 2, dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[7].Value.ToString(), saveName, dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[8].Value.ToString(), time); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } query(); } else { MessageBox.Show("上传文件失败!"); } } catch (Exception ex) { MessageBox.Show("" + ex.GetBaseException()); } } }
private void query() { DataSet ds = null; try { string strSql = string.Format("SELECT b.FID,a.SName,a.Norms,a.Texture,b.Num,b.Price,b.Tag FROM dbo.TSale a,dbo.TCusForm b,dbo.TCustomer c WHERE a.ID=b.SID and b.CID=c.ID and b.Tag<>2 AND c.CName='{0}'", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; FID = dt.Rows[0]["FID"].ToString(); dt.Columns["FID"].ColumnName = "订单ID"; dt.Columns["SName"].ColumnName = "产品名称"; dt.Columns["Norms"].ColumnName = "规格"; dt.Columns["Texture"].ColumnName = "材质"; dt.Columns["Num"].ColumnName = "数量"; dt.Columns["Price"].ColumnName = "总价格"; dt.Columns["Tag"].ColumnName = "订单状态"; this.dataGridView1.DataSource = dt.DefaultView; queryCus(); queryCount(); //btn_place.Enabled = true; if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; lab_num.Text = ""; lab_price.Text = ""; lab_tap.Text = ""; btn_place.Enabled = false; } } } catch { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; lab_num.Text = ""; lab_price.Text = ""; lab_tap.Text = ""; btn_place.Enabled = false; } } }
private void query() { DataSet ds = null; try { string strSql = string.Format("select ID,Name,Sex,Phone,Address,FamilyPhone,FamilyAddress,Birthday,EntryTime,Resume,State from TStaff where Name like '%{0}%' ", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["ID"].ColumnName = "用户ID"; dt.Columns["Name"].ColumnName = "姓名"; dt.Columns["Sex"].ColumnName = "性别"; dt.Columns["Phone"].ColumnName = "联系电话"; dt.Columns["Address"].ColumnName = "现居住地"; dt.Columns["FamilyPhone"].ColumnName = "家庭电话"; dt.Columns["FamilyAddress"].ColumnName = "家庭地址"; dt.Columns["Birthday"].ColumnName = "出生日期"; dt.Columns["EntryTime"].ColumnName = "入职时间"; dt.Columns["Resume"].ColumnName = "简历名称"; dt.Columns["State"].ColumnName = "员工状态"; this.dataGridView1.DataSource = dt.DefaultView; btn_useradd.Visible = true; btn_userdel.Visible = true; button2.Visible = true; if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; btn_useradd.Visible = false; btn_userdel.Visible = false; button2.Visible = false; } } } catch { btn_useradd.Visible = false; btn_userdel.Visible = false; button2.Visible = false; } }
//动态加载菜单 private void HomePage_Load(object sender, EventArgs e) { //this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea; //this.WindowState = System.Windows.Forms.FormWindowState.Maximized; DataSet ds = null; try { string strSql = string.Format("SELECT * FROM dbo.TMenu f,(SELECT b.RMenuName FROM dbo.TUser a,dbo.TRole_Menu b WHERE a.UserName='******' AND a.RoleID=b.RID) AS t WHERE t.RMenuName LIKE '%'+f.Name+'%' AND f.FID=0", Gloab.username); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { ToolStripMenuItem tool = new ToolStripMenuItem(); tool.Tag = dt.Rows[i]["EName"].ToString(); tool.Name = dt.Rows[i]["EName"].ToString(); tool.Text = dt.Rows[i]["Name"].ToString(); tool.Font = new Font("Microsoft YaHei UI", 10f, FontStyle.Bold); //二级菜单 string strSql2 = string.Format("SELECT * FROM dbo.TMenu WHERE FID='{0}'", dt.Rows[i]["ID"].ToString()); DataSet ds2 = null; ds2 = DbFunc.GetTableNoName(strSql2); if (ds2 != null && ds2.Tables.Count != 0 && ds2.Tables[0].Rows.Count != 0) { DataTable dt2 = ds2.Tables[0]; for (int j = 0; j < dt2.Rows.Count; j++) { ToolStripMenuItem tool2 = new ToolStripMenuItem(); tool2.Tag = dt2.Rows[j]["EName"].ToString(); tool2.Name = dt2.Rows[j]["EName"].ToString(); tool2.Text = dt2.Rows[j]["Name"].ToString(); tool2.Font = new Font("Microsoft YaHei UI", 10f, FontStyle.Bold); tool2.Click += new EventHandler(subMenu_Click); tool.DropDownItems.Add(tool2); } } tool.Click += new EventHandler((subMenu_Click)); this.menuStrip1.Items.Add(tool); } } } catch { } }
private void btn_up_Click(object sender, EventArgs e) { //创建文件弹出选择窗口(包括文件名)对象 OpenFileDialog ofd = new OpenFileDialog(); //判断选择的路径 if (ofd.ShowDialog() == DialogResult.OK) { progressBar1.Visible = true; //this.txtSoundPath.Text = ofd.FileName.ToString(); filePath = ofd.FileName.ToString(); try { //上传后文件保存的名称 string saveName = FID + ".doc"; int count = UpFile.UpSound_Request(filePath, saveName, this.progressBar1); if (count > 0) { MessageBox.Show("上传文件成功!"); progressBar1.Visible = false; DataSet ds = null; int result = -1; try { string strSql = string.Format("exec UP_TForm_ADD '{0}','{1}','{2}','{3}','{4}'", FID, CID, lab_num.Text, lab_price.Text, 1); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } query(); } else { MessageBox.Show("上传文件失败!"); } } catch (Exception ex) { MessageBox.Show("" + ex.GetBaseException()); } } }
private void queryCus() { DataSet ds = null; try { string strSql = string.Format("SELECT ID FROM dbo.TCustomer WHERE CName like '%{0}%' and FID like '%{1}%'", txt_name.Text, textBox1.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; //CID = (int)dt.Rows[0]["ID"]; } } catch { } }
private void queryCount() { DataSet ds = null; try { string strSql = string.Format("SELECT SUM(b.Num) num,SUM(b.Price) price,ISNULL(b.FID,0) tag FROM dbo.TSale a,dbo.TCusForm b,dbo.TCustomer c WHERE a.ID=b.SID and b.CID=c.ID AND b.Tag<>2 AND c.CName='{0}' GROUP BY b.FID", txt_name.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; lab_num.Text = dt.Rows[0]["num"].ToString(); lab_price.Text = dt.Rows[0]["price"].ToString(); if (dt.Rows[0]["tag"].ToString().Equals("0")) { btn_place.Enabled = true; lab_tap.Text = "未下单(不可上传)"; } else { //已下单情况下查询合同上传状态 btn_place.Enabled = false; queryTag(); } } else { lab_num.Text = ""; lab_price.Text = ""; lab_tap.Text = ""; } } catch { lab_num.Text = ""; lab_price.Text = ""; lab_tap.Text = ""; } }
private void btn_add_Click(object sender, EventArgs e) { if (isUser) { DateTime currentTime = DateTime.Now; string str = currentTime.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo); int a = dataGridView1.CurrentRow.Index; DataSet ds = null; int result = -1; try { string strSql = string.Format("exec UP_TCusForm_ADD '{0}','{1}','{2}','{3}','{4}','{5}'", ID, dataGridView1.Rows[a].Cells[0].Value.ToString(), 1, dataGridView1.Rows[a].Cells[4].Value.ToString(), str, 0); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } if (result == 0) { query2(); } else { MessageBox.Show("添加产品失败!", "提示"); } } else { MessageBox.Show("客户信息不能为空!", "提示"); } }
private void query() { DataSet ds = null; try { string strSql = string.Format("SELECT a.RoleID,a.RoleName,b.RMenuID,b.RMenuName FROM dbo.TRole a LEFT JOIN dbo.TRole_Menu b ON a.RoleID=b.RID"); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["RoleID"].ColumnName = "角色ID"; dt.Columns["RoleName"].ColumnName = "角色名称"; dt.Columns["RMenuID"].ColumnName = "对应权限ID"; dt.Columns["RMenuName"].ColumnName = "对应权限"; this.dataGridView1.DataSource = dt.DefaultView; if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } } } catch { } }
private void btn_cha_Click(object sender, EventArgs e) { int result = 0; DataSet ds = null; try { string strSql = string.Format("select * from TCustomer where CName = '{0}'", txt_username.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; ID = (int)dt.Rows[0]["ID"]; txt_username.Text = dt.Rows[0]["CName"].ToString(); txt_phone.Text = dt.Rows[0]["Phone"].ToString(); txt_email.Text = dt.Rows[0]["Email"].ToString(); txt_address.Text = dt.Rows[0]["Address"].ToString(); result = 1; } } catch { } if (result == 0) { ID = 0; MessageBox.Show("没有该联系人,请新增后再试!", "提示"); btn_zhen.Enabled = true; isUser = false; } else { query2(); btn_zhen.Enabled = false; isUser = true; } }
private void btn_place_Click(object sender, EventArgs e) { string str = "XLS"; DateTime currentTime = DateTime.Now; str += currentTime.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); Random rd = new Random(); str += rd.Next(100, 999).ToString(); DataSet ds = null; int result = -1; try { string strSql = string.Format("exec UP_TForm_ADD '{0}','{1}','{2}','{3}','{4}'", str, CID, lab_num.Text, lab_price.Text, 0); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } if (result == 0) { MessageBox.Show("下单成功,请尽快上销售合同!", "提示"); query(); } else { MessageBox.Show("下单失败!", "提示"); } }
private void query() { int state = 0; if (radioButton1.Checked) { state = 0; } if (radioButton2.Checked) { state = 1; } if (radioButton3.Checked) { state = 2; } DataSet ds = null; try { string strSql = string.Format("SELECT * FROM (SELECT a.FID,a.Num,a.Time,b.CName,b.Phone,b.Address,ISNULL(c.State,0) State,ISNULL(c.Certificate1,0) Certificate1,c.Time1 Time1,ISNULL(c.Certificate2,0) Certificate2,c.Time2 Time2 FROM dbo.TForm a INNER JOIN dbo.TCustomer b on a.CID=b.ID AND b.CName like '%{0}%' LEFT JOIN TLogistics c ON a.FID=c.FID ) AS Z WHERE Z.State={1} ", txt_name.Text, state); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["FID"].ColumnName = "订单ID"; dt.Columns["Num"].ColumnName = "数量"; dt.Columns["CName"].ColumnName = "客户名字"; dt.Columns["Phone"].ColumnName = "客户手机"; dt.Columns["Address"].ColumnName = "客户地址"; dt.Columns["Time"].ColumnName = "下单时间"; dt.Columns["State"].ColumnName = "配送状态"; dt.Columns["Certificate1"].ColumnName = "送货凭证"; dt.Columns["Time1"].ColumnName = "送货时间"; dt.Columns["Certificate2"].ColumnName = "收货凭证"; dt.Columns["Time2"].ColumnName = "收货时间"; this.dataGridView1.DataSource = dt.DefaultView; btn_up1.Enabled = true; btn_up2.Enabled = true; if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } btn_up1.Enabled = false; btn_up2.Enabled = false; } } catch { btn_up1.Enabled = false; btn_up2.Enabled = false; } }
private void query() { string str = ""; if (radioButton1.Checked) { } if (radioButton2.Checked) { str = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1).ToShortDateString(); } if (radioButton3.Checked) { str = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-3).ToShortDateString(); } if (radioButton4.Checked) { str = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-6).ToShortDateString(); } if (radioButton5.Checked) { str = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-12).ToShortDateString(); } DataSet ds = null; try { string strSql = string.Format("SELECT b.FID,c.CName,a.SName,a.Norms,a.Texture,b.Num,b.Price,b.Tag,b.Time FROM dbo.TSale a,dbo.TCusForm b,dbo.TCustomer c WHERE a.ID=b.SID and b.CID=c.ID and b.Tag<>0 AND c.CName like '%{0}%' and b.Time>'{1}' and b.FID like '%{2}%'", txt_name.Text, str, textBox1.Text); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; dt.Columns["FID"].ColumnName = "订单ID"; dt.Columns["CName"].ColumnName = "客户姓名"; dt.Columns["SName"].ColumnName = "产品名称"; dt.Columns["Norms"].ColumnName = "规格"; dt.Columns["Texture"].ColumnName = "材质"; dt.Columns["Num"].ColumnName = "数量"; dt.Columns["Price"].ColumnName = "总价格"; dt.Columns["Tag"].ColumnName = "订单状态"; dt.Columns["Time"].ColumnName = "下单时间"; this.dataGridView1.DataSource = dt.DefaultView; queryCus(); queryCount(); if (!isAuto) { AutoSizeColumn(dataGridView1); isAuto = true; } } else { if (dataGridView1.DataSource != null) { dataGridView1.DataSource = null; } } } catch { } }
private void button2_Click(object sender, EventArgs e) { if (dataGridView1.RowCount == 0) { MessageBox.Show("没有选中任何产品,请选中后重试!", "提示"); } else { string filePath = ""; //创建文件弹出选择窗口(包括文件名)对象 OpenFileDialog ofd = new OpenFileDialog(); //判断选择的路径 if (ofd.ShowDialog() == DialogResult.OK) { progressBar1.Visible = true; //this.txtSoundPath.Text = ofd.FileName.ToString(); filePath = ofd.FileName.ToString(); try { //上传后文件保存的名称 int a = dataGridView1.CurrentRow.Index; int id = (int)dataGridView1.Rows[a].Cells[0].Value; string name = dataGridView1.Rows[a].Cells[1].Value.ToString(); string saveName = name + ".doc"; int count = UpFile.UpSound_Request(filePath, saveName, this.progressBar1); if (count > 0) { MessageBox.Show("上传文件成功!"); progressBar1.Visible = false; DataSet ds = null; int result = -1; try { DateTime currentTime = DateTime.Now; string time = currentTime.ToString("yyyy-MM-dd HH:mm:ss"); string strSql = string.Format("exec UP_TStaff_Resume '{0}','{1}'", id, saveName); ds = DbFunc.GetTableNoName(strSql); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { DataTable dt = ds.Tables[0]; result = (int)dt.Rows[0]["Result"]; } } catch { } query(); } else { MessageBox.Show("上传文件失败!"); } } catch (Exception ex) { MessageBox.Show("" + ex.GetBaseException()); } } } }