private void LoadData(bool isRefresh) { string strWhereTmp = string.IsNullOrEmpty(strfilterSql) ? string.Format(" where a1.ztid={0}", strZtID) : string.Format(",({1}) f1 where a1.ztid={0} and a1.sid=f1.sid", strZtID, strfilterSql); nPtCount = PtDataHelper.getPtDataCount(strWhereTmp); nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(nPtCount) / Convert.ToDouble(nPageSize))); if (nPageCount < 1) { nCuurentPage = 1; btnSY.Enabled = false; btnPre.Enabled = false; btnNext.Enabled = false; btnEnd.Enabled = false; groupBox2.Text = string.Format("共{0}条数据", nPtCount, nCuurentPage, nPageCount); //dgvListData.DataSource = null; //dgvListData.Refresh(); nPageCount = 1; BingData(nCuurentPage, nPageSize); } else { nCuurentPage = isRefresh ? nCuurentPage : 1; BingData(nCuurentPage, nPageSize); } }
private void InitCnBaseData() { string strSid = dtSource.Rows[nCuurentIdx - 1]["sid"].ToString(); strSidKey = strSid; DataTable dt = PtDataHelper.getPtData(string.Format("sid='{0}' and ztid={1}", strSid, strZtId), "", "show_base"); //DataTable dt = PatDetails.getBaseData(strSidKey, strDbType); if (dt.Rows.Count < 1) { return; } txbAB.Text = dt.Rows[0]["abs"].ToString(); txbAD.Text = dt.Rows[0]["ad"].ToString(); txbAG.Text = dt.Rows[0]["dljg"].ToString(); txbAN.Text = dt.Rows[0]["an"].ToString(); txbAT.Text = dt.Rows[0]["dlr"].ToString(); txbCO.Text = dt.Rows[0]["sheng"].ToString(); txbDZ.Text = dt.Rows[0]["addr"].ToString(); txbGD.Text = dt.Rows[0]["gd"].ToString(); txbGN.Text = dt.Rows[0]["gn"].ToString(); txbIC.Text = dt.Rows[0]["ipc"].ToString(); txbIN.Text = dt.Rows[0]["iv"].ToString(); txbMC.Text = ""; txbPA.Text = dt.Rows[0]["pa"].ToString(); txbPR.Text = dt.Rows[0]["cpy"].ToString(); txbPD.Text = dt.Rows[0]["pd"].ToString(); txbPN.Text = dt.Rows[0]["pn"].ToString(); txbTI.Text = dt.Rows[0]["title"].ToString(); txbCl1.Text = dt.Rows[0]["clm"].ToString(); InitByCnData(); }
private void btnDel_Click(object sender, EventArgs e) { string strPIDs = ""; foreach (DataGridViewRow dr in dgvListData.Rows) { if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value)) { strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'"; } } strPIDs = strPIDs.TrimStart(','); if (strPIDs == "") { MessageBox.Show("请选择要删除的数据!", "温馨提示:"); return; } this.Cursor = Cursors.WaitCursor; if (PtDataHelper.DelPt(strPIDs, strZtID)) { MessageBox.Show("数据删除成功!", "温馨提示:"); LoadData(true); } else { MessageBox.Show("数据删除失败,请重试!", "温馨提示:"); } this.Cursor = Cursors.Default; }
private void btnImportSelect_Click(object sender, EventArgs e) { string strPIDs = ""; foreach (DataGridViewRow dr in dgvListData.Rows) { if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value)) { strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'"; } } strPIDs = strPIDs.TrimStart(','); if (strPIDs == "") { MessageBox.Show("请选择要导出的数据!", "温馨提示:"); return; } By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType); frm.bIsSetExportFileds = true; if (frm.ShowDialog() == DialogResult.OK) { string excelname = System.Windows.Forms.Application.StartupPath + "\\Excel\\pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"; DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0} and a1.sid in ({1})", ztid, strPIDs), "", 1, nPageSize, strDbType); NPOIHelper.Export(dt, excelname, "专利数据", ""); if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start("explorer", "/select," + excelname); } } }
private void btnQuery_Click(object sender, EventArgs e) { ztinfo zt = (ztinfo)cmbZtLst.SelectedItem; int ztid = zt.ID; nPtCount = PtDataHelper.getPtDataCount(string.Format("ztid={0}", ztid)); nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(nPtCount) / Convert.ToDouble(nPageSize))); if (nPageCount < 1) { nCuurentPage = 0; btnSY.Enabled = false; btnPre.Enabled = false; btnNext.Enabled = false; btnEnd.Enabled = false; groupBox2.Text = string.Format("共{0}条数据", nPtCount, nCuurentPage, nPageCount); dgvListData.DataSource = null; dgvListData.Refresh(); } else { nCuurentPage = 1; BingData(nCuurentPage, nPageSize); } }
private void btnOutput_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show(string.Format("请选择要导出的数据库!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataGridViewRow datarow = dataGridView1.SelectedRows[0]; string name = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString()); string des = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString()); string type = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString()); int id = Convert.ToInt32(datarow.Cells["Id"].Value.ToString()); int nPtNum = datarow.Cells["app_sum"].Value == null ? 0 : Convert.ToInt32(datarow.Cells["app_sum"].Value.ToString()); if (nPtNum == 0) { MessageBox.Show(string.Format("您选择的专利库中没有数据可以导出!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } By.frmSetShowFiles frm = new By.frmSetShowFiles(type.ToUpper()); frm.bIsSetExportFileds = true; if (frm.ShowDialog() == DialogResult.OK) { string excelname = ""; SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel"; saveDlg.Filter = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx"; saveDlg.FileName = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"; if (saveDlg.ShowDialog() != DialogResult.OK) { return; } string strFileName = saveDlg.FileName.Substring(0, saveDlg.FileName.LastIndexOf('.'));; string strExtension = saveDlg.FileName.Substring(saveDlg.FileName.LastIndexOf('.')); int nSplitFlag = 10000; //拆分文件,每x条数据导出一个excel文件; for (int nIdx = 1; (nIdx - 1) * nSplitFlag < nPtNum; nIdx++) { excelname = nPtNum > nSplitFlag ? strFileName + "_" + nIdx.ToString() + strExtension : strFileName + "" + strExtension; DataTable dt = PtDataHelper.getPtData(string.Format("a1.ztid={0}", id), "", nIdx, nSplitFlag, type.ToUpper()); if (dt != null) { dt.Columns.Remove("sid"); } ExcelLib.NPOIHelper.Export(dt, excelname, "专利数据", ""); } if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start("explorer", "/select," + excelname); } } }
private void InitByEnData() { string strSid = dtSource.Rows[nCuurentIdx - 1]["sid"].ToString(); strSidKey = strSid; DataTable dt = PtDataHelper.getPtData(string.Format("sid='{0}' and ztid={1}", strSid, strZtId), "", "st_dt"); if (dt.Rows.Count < 1) { btnUpdate.Tag = ""; return; } btnUpdate.Tag = dt.Rows[0]["id"].ToString(); txbEnAdy.Text = dt.Rows[0]["ady"].ToString(); txbEnPdY.Text = dt.Rows[0]["pdy"].ToString(); txbEnPrY.Text = "";//pr 表 txbEnOldPrY.Text = dt.Rows[0]["opdy"].ToString(); txbEnPnYC.Text = dt.Rows[0]["pdy_def"].ToString(); txbEnGnYC.Text = dt.Rows[0]["gdy_def"].ToString(); txbEnFmlNm.Text = dt.Rows[0]["fml_sum"].ToString(); txbEnCcNm.Text = dt.Rows[0]["gj_sum"].ToString(); txbEnYzNm.Text = dt.Rows[0]["yz_sum"].ToString(); txbEnPA1.Text = dt.Rows[0]["f_pa"].ToString(); txbEnPaNm.Text = dt.Rows[0]["pa_sum"].ToString(); cbxEnSfhzSq.Text = dt.Rows[0]["ishezuo"].ToString().Equals("1") ? "是" : "否"; txbEnIn1.Text = dt.Rows[0]["f_in"].ToString(); txbEnInNm.Text = dt.Rows[0]["in_sum"].ToString(); txbEnZj.Text = dt.Rows[0]["zhou"].ToString(); cbxEnSf3J.Text = dt.Rows[0]["issanju"].ToString().Equals("1") ? "是" : "否"; cbxEnSf5j.Text = dt.Rows[0]["iswuju"].ToString().Equals("1") ? "是" : "否"; txbEnOldPrC.Text = dt.Rows[0]["oprc"].ToString(); txbEnIpc1.Text = dt.Rows[0]["f_ipc"].ToString(); txbEnCpc1.Text = dt.Rows[0]["f_cpc"].ToString(); txbEnDmc1.Text = dt.Rows[0]["f_dmc"].ToString(); txbEnIpcNm.Text = dt.Rows[0]["ipc_sum"].ToString(); txbEnCpcNm.Text = dt.Rows[0]["cpc_sum"].ToString(); txbEnDmcNm.Text = dt.Rows[0]["dmc_sum"].ToString(); txbEnEndLg.Text = dt.Rows[0]["lg"].ToString(); txbEnZlNl.Text = dt.Rows[0]["age"].ToString(); //cbxEnGzjs.Text = dt.Rows[0]["isgongzhi"].ToString().Equals("1") ? "是" : "否"; //txbEnZlWcY.Text = ""; txbEnAp_gjs.Text = dt.Rows[0]["ap_gjs"].ToString(); txbEnPn_gjs.Text = dt.Rows[0]["pn_gjs"].ToString(); txbBySl.Text = dt.Rows[0]["byz_sum"].ToString(); txbCLzs.Text = dt.Rows[0]["cls_char_sum"].ToString(); txbGkn.Text = dt.Rows[0]["pdy"].ToString(); txbGknc.Text = dt.Rows[0]["pdy_def"].ToString(); InitRgByData(); }
private void InitByCnData() { string strSid = dtSource.Rows[nCuurentIdx - 1]["sid"].ToString(); strSidKey = strSid; DataTable dt = PtDataHelper.getPtData(string.Format("sid='{0}' and ztid={1}", strSid, strZtId), "", "st_dt"); if (dt.Rows.Count < 1) { btnUpdate.Tag = ""; return; } btnUpdate.Tag = dt.Rows[0]["id"].ToString(); txbBySl.Text = dt.Rows[0]["byz_sum"].ToString(); txbCLzs.Text = dt.Rows[0]["cls_char_sum"].ToString(); txbGkn.Text = dt.Rows[0]["pdy"].ToString(); txbGknc.Text = dt.Rows[0]["pdy_def"].ToString(); cbxSfgwlh.Text = (dt.Rows[0]["isguowai"].ToString().Equals("0") || dt.Rows[0]["isguowai"].ToString() == "") ? "否" : "是"; cbxSfgz.Text = (dt.Rows[0]["isgongzhi"].ToString().Equals("0") || dt.Rows[0]["isgongzhi"].ToString() == "") ? "否" : "是"; cbxSfhzsq.Text = (dt.Rows[0]["ishezuo"].ToString().Equals("0") || dt.Rows[0]["ishezuo"].ToString() == "") ? "否" : "是"; txbGj.Text = dt.Rows[0]["gj"].ToString(); txbSheng.Text = dt.Rows[0]["sheng"].ToString(); txbSheng2.Text = dt.Rows[0]["sheng1"].ToString(); txbShi.Text = dt.Rows[0]["shi"].ToString(); txbQx.Text = dt.Rows[0]["quxian"].ToString(); txbSqn1.Text = dt.Rows[0]["ady"].ToString(); txbSqn.Text = dt.Rows[0]["gdy"].ToString(); txbSqnc.Text = dt.Rows[0]["gdy_def"].ToString(); txbYzSl.Text = dt.Rows[0]["yz_sum"].ToString(); txbZcpc.Text = dt.Rows[0]["f_cpc"].ToString(); txbZfmr.Text = dt.Rows[0]["f_in"].ToString(); txbZIpc.Text = dt.Rows[0]["f_ipc"].ToString(); txbZj.Text = dt.Rows[0]["zhou"].ToString(); txbZlLx.Text = dt.Rows[0]["type"].ToString(); txbZllx2.Text = dt.Rows[0]["type1"].ToString(); txbZlnl.Text = dt.Rows[0]["age"].ToString(); txbZsqr.Text = dt.Rows[0]["f_pa"].ToString(); txbZsqrLx.Text = dt.Rows[0]["f_pa_type"].ToString(); txbZzflzt.Text = dt.Rows[0]["lg"].ToString(); txbCpcSl.Text = dt.Rows[0]["cpc_sum"].ToString(); txbIpcSl.Text = dt.Rows[0]["ipc_sum"].ToString(); txbfmrSl.Text = dt.Rows[0]["in_sum"].ToString(); txbSqrSl.Text = dt.Rows[0]["pa_sum"].ToString(); txbJjqq.Text = dt.Rows[0]["quyu"].ToString(); txbFljzn.Text = dt.Rows[0]["lg"].ToString(); InitRgByData(); }
private void btnImportSelect_Click(object sender, EventArgs e) { string strPIDs = ""; foreach (DataGridViewRow dr in dgvListData.Rows) { if (dr.Cells[0].Value != null && Convert.ToBoolean(dr.Cells[0].Value)) { strPIDs += ",'" + ((DataGridViewCell)dr.Cells["Idx"]).Value.ToString() + "'"; } } strPIDs = strPIDs.TrimStart(','); if (strPIDs == "") { MessageBox.Show("请选择要导出的数据!", "温馨提示:"); return; } By.frmSetShowFiles frm = new By.frmSetShowFiles(strDbType); frm.bIsSetExportFileds = true; if (frm.ShowDialog() == DialogResult.OK) { string excelname = ""; saveFileDialog1.InitialDirectory = System.Windows.Forms.Application.StartupPath + "\\Excel"; saveFileDialog1.Filter = "Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx"; saveFileDialog1.FileName = "pt_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"; if (saveFileDialog1.ShowDialog() != DialogResult.OK) { return; } excelname = saveFileDialog1.FileName; //DataTable dt = PtDataHelper.getPtData(string.Format(",fun_filter f1 where a1.ztid={0} and a1.sid in ({1}) and a1.sid=f1.sid ", strZtID, strPIDs), "", 1, nPageSize, strDbType); string strWhereTmp = string.IsNullOrEmpty(strfilterSql) ? string.Format(" where a1.ztid={0} and a1.sid in ({1}) ", strZtID, strPIDs) : string.Format(",({1}) f1 where a1.ztid={0} and a1.sid in ({2}) and a1.sid=f1.sid", strZtID, strfilterSql, strPIDs); DataTable dt = PtDataHelper.getPtData(strWhereTmp, "", 1, nPageSize, strDbType); if (dt != null) { dt.Columns.Remove("sid"); } NPOIHelper.Export(dt, excelname, "专利数据", ""); if (MessageBox.Show("导出成功,是否查看导出文件所在目录?", "导出提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start("explorer", "/select," + excelname); } } }
private void button1_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; DataGridViewCell cell = (DataGridViewCell)dataGridView1.SelectedRows[0].Cells["id"]; string strNztID = cell.Value.ToString(); switch (strMoveCopy) { case "COPY": bool bCopyRs = false; if (strSID.Contains("','")) { bCopyRs = PtDataHelper.CopyPt(strSID.Replace("'", "").Split(',').ToList <string>(), nZtID.ToString(), strNztID); } else { bCopyRs = PtDataHelper.CopyPt(strSID, nZtID.ToString(), strNztID); } if (bCopyRs) { MessageBox.Show("数据复制成功!", "温馨提示:"); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("数据复制失败,请重试!", "温馨提示:"); } break; case "MOVE": if (PtDataHelper.MovePt(strSID, nZtID.ToString(), strNztID)) { MessageBox.Show("数据移动成功!", "温馨提示:"); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("数据移动失败,请重试!", "温馨提示:"); } break; } this.Cursor = Cursors.Default; }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; DataGridViewCell cell = (DataGridViewCell)dgvListData.SelectedRows[0].Cells["Idx"]; string strPID = cell.Value.ToString(); if (PtDataHelper.DelPt(strPID, strZtID)) { MessageBox.Show("数据删除成功!", "温馨提示:"); LoadData(true); } else { MessageBox.Show("数据删除失败,请重试!", "温馨提示:"); } this.Cursor = Cursors.Default; }
private void InitEnBaseData() { string strSid = dtSource.Rows[nCuurentIdx - 1]["sid"].ToString(); strSidKey = strSid; string strSqlFileds = @"ipc,cpc,dmc,cpy,pa,iv,addr,pr,opd,abs,title, (select GROUP_CONCAT(an ORDER BY sort ASC SEPARATOR ';') FROM st_ans where sid=a.sid) as an, (select GROUP_CONCAT(ad ORDER BY sort ASC SEPARATOR ';') FROM st_ans where sid=a.sid) as ad, (select GROUP_CONCAT(pn ORDER BY sort ASC SEPARATOR ';') FROM st_pns where sid=a.sid) as pn, (select GROUP_CONCAT(pd ORDER BY sort ASC SEPARATOR ';') FROM st_pns where sid=a.sid) as pd "; if (strDbType.Equals("EPODOC")) { strSqlFileds = @"ipc,cpc,dmc,cpy,pa,iv,addr,pr,opd,abs,title,pd, (select an FROM st_dt where ztid=a.ztid and sid=a.sid limit 0,1) as an, (select ad FROM st_dt where ztid=a.ztid and sid=a.sid limit 0,1) as ad, (select pn FROM st_dt where ztid=a.ztid and sid=a.sid limit 0,1) as pn "; } DataTable dt = PtDataHelper.getPtData(strSqlFileds, string.Format("sid='{0}' and ztid={1}", strSid, strZtId), "", "show_base a"); //DataTable dt = PatDetails.getBaseData(strSidKey, strDbType); if (dt.Rows.Count < 1) { return; } txbEnTi.Text = dt.Rows[0]["title"].ToString(); txbEnAN.Text = dt.Rows[0]["an"].ToString(); txbEnAD.Text = dt.Rows[0]["ad"].ToString(); txbEnPb.Text = dt.Rows[0]["pn"].ToString(); txbEnPD.Text = dt.Rows[0]["pd"].ToString(); txbEnIpc.Text = dt.Rows[0]["ipc"].ToString(); txbEnCpc.Text = dt.Rows[0]["cpc"].ToString(); txbEnDmc.Text = dt.Rows[0]["dmc"].ToString(); txbEnCpy.Text = dt.Rows[0]["cpy"].ToString(); txbEnPA.Text = dt.Rows[0]["pa"].ToString(); txbEnIN.Text = dt.Rows[0]["iv"].ToString(); txbEnAddres.Text = dt.Rows[0]["addr"].ToString(); txbEnPR.Text = dt.Rows[0]["pr"].ToString(); txbEnOPD.Text = dt.Rows[0]["opd"].ToString(); txbEnAB.Text = dt.Rows[0]["abs"].ToString().Replace("NOVELTY :", ""); InitByEnData(); }
private void BingData(int nPageidx, int nPageSize) { if (nPageCount == 0) { return; } if (nPageidx > nPageCount) { nPageidx = nPageCount; } else if (nPageidx < 1) { nPageidx = 1; } btnSY.Enabled = true; btnPre.Enabled = true; btnNext.Enabled = true; btnEnd.Enabled = true; if (nPageidx == 1) { btnSY.Enabled = false; btnPre.Enabled = false; } if (nPageidx == nPageCount) { btnNext.Enabled = false; btnEnd.Enabled = false; } ztinfo zt = (ztinfo)cmbZtLst.SelectedItem; int ztid = zt.ID; dgvListData.DataSource = PtDataHelper.getPtData(string.Format("ztid={0}", ztid), nPageidx, nPageSize); nCuurentPage = nPageidx; groupBox2.Text = string.Format("共{0}条数据,第{1}页/共{2}页 双击可查看专利的详细信息.", nPtCount, nCuurentPage, nPageCount); }
private void BingData(int nPageidx, int nPageSize) { //if (nPageCount == 0) // return; if (nPageidx > nPageCount) { nPageidx = nPageCount; } else if (nPageidx < 1) { nPageidx = 1; } btnSY.Enabled = true; btnPre.Enabled = true; btnNext.Enabled = true; btnEnd.Enabled = true; if (nPageidx == 1) { btnSY.Enabled = false; btnPre.Enabled = false; } if (nPageidx == nPageCount) { btnNext.Enabled = false; btnEnd.Enabled = false; } ztinfo zt = (ztinfo)cmbZtLst.SelectedItem; int ztid = zt.ID; switch (cbxOrder.Text) { case "申请号降序": strOrder = "a1.an desc"; break; case "申请号升序": strOrder = "a1.an"; break; case "申请日降序": //strOrder = "ad desc"; strOrder = "date_format(REPLACE(REPLACE(REPLACE(a1.ad,'年','-'),'月','-'),'日',''),'%Y-%m-%d') desc"; break; case "申请日升序": //strOrder = "ad "; strOrder = "date_format(REPLACE(REPLACE(REPLACE(a1.ad,'年','-'),'月','-'),'日',''),'%Y-%m-%d')"; break; case "公开日降序": //strOrder = "pd desc"; strOrder = "date_format(REPLACE(REPLACE(REPLACE(a1.pd,'年','-'),'月','-'),'日',''),'%Y-%m-%d') desc"; break; case "公开日升序": //strOrder = "pd "; strOrder = "date_format(REPLACE(REPLACE(REPLACE(a1.pd,'年','-'),'月','-'),'日',''),'%Y-%m-%d')"; break; default: strOrder = "a1.id"; break; } strOrderShowText = cbxOrder.Text; string strWhereTmp = string.IsNullOrEmpty(strfilterSql) ? string.Format(" where a1.ztid={0}", strZtID) : string.Format(",({1}) f1 where a1.ztid={0} and a1.sid=f1.sid", strZtID, strfilterSql); dgvListData.DataSource = PtDataHelper.getPtData(strWhereTmp, strOrder, nPageidx, nPageSize, strDbType); nCuurentPage = nPageidx; groupBox2.Text = string.Format("共{0}条数据,第{1}页/共{2}页,[双击]可查看专利的详细信息.", nPtCount, nCuurentPage, nPageCount); }
private void SaveAutoIdx(TabPage tbPage) { string strUpFileds = ""; string[] strFiled = null; string strValue = ""; foreach (var item in tbPage.Controls) { if (((Control)item).Tag != null && ((Control)item).Tag.ToString() == "") { continue; } if (item is TextBox) { strFiled = ((TextBox)item).Tag.ToString().Split('|'); strValue = ((TextBox)item).Text; if (strFiled[1] == "int") { strValue = strValue.Equals("") ? "0" : strValue; strUpFileds += string.Format(",{0}={1}", strFiled[0], strValue); } else { strUpFileds += string.Format(",{0}='{1}'", strFiled[0], strValue); } } else if (item is ComboBox) { strFiled = ((ComboBox)item).Tag.ToString().Split('|'); strValue = ((ComboBox)item).Text.Equals("否") ? "0" : "1"; if (strFiled[1] == "int") { strValue = strValue.Equals("") ? "0" : strValue; strUpFileds += string.Format(",{0}={1}", strFiled[0], strValue); } else { strUpFileds += string.Format(",{0}='{1}'", strFiled[0], strValue); } } } if (strUpFileds == "") { return; } strUpFileds = strUpFileds.TrimStart(','); if (PtDataHelper.UpdatePt(btnUpdate.Tag.ToString(), strUpFileds, "st_dt")) { MessageBox.Show("数据修改成功!", "温馨提示:"); } else { MessageBox.Show("数据修改失败,请重试!", "温馨提示:"); } }