private void UploadPur(Object rows) { try { CDBOperate dbobj = new CDBOperate(); DataGridViewRowCollection dgvrows = rows as DataGridViewRowCollection; foreach (DataGridViewRow r in dgvrows) { string bm = r.Cells[2].Value == null ? "" : r.Cells[2].Value.ToString(); string mc = r.Cells[3].Value == null ? "" : r.Cells[3].Value.ToString(); string sccj = r.Cells[4].Value == null ? "" : r.Cells[4].Value.ToString(); string gg = r.Cells[5].Value == null ? "" : r.Cells[5].Value.ToString(); string jhdw = r.Cells[6].Value == null ? "" : r.Cells[6].Value.ToString(); double yssl = 0; if (Double.TryParse(r.Cells[7].Value.ToString(), out yssl)) { dbobj.UploadPur(remoteConn, bm, mc, sccj, gg, jhdw, yssl, dm); } } this.Invoke((MethodInvoker) delegate() { btnLoadPur.Enabled = false; MessageBox.Show("上传完成"); formLoading.Dispose(); }); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Invoke((MethodInvoker) delegate() { }); } }
private void SelectUnsalableItems() { try { CDBOperate dbobj = new CDBOperate(); //DataTable dbtable = dbobj.GetUnSalableDrug(thisConn, begindate, enddate, buydate, unsaleNum); List <DataTable> dtlist = dbobj.GetUnSalableDrug(thisConn, begindate, enddate, buydate, unsaleNum);//西药 String info = dbobj.GetUnSalableDrug_ZongDian(thisConn); DataTable dtzhongyao = dbobj.GetUnSalableDrug_ZhongYao(thisConn); String info2 = dbobj.GetUnSalableDrug_ZongDian_Zhongyao(thisConn); this.Invoke((MethodInvoker) delegate() { dgvDrug.DataSource = dtlist[0]; dgv_yanzhong.DataSource = dtlist[1]; this.dgv_zhixiao.DataSource = dtlist[2]; this.dgv_jianyi.DataSource = dtlist[3]; formLoading.Dispose(); for (int i = 0; i < dgvDrug.Columns.Count; i++) { dgvDrug.Columns[i].ReadOnly = true; } if (dgvDrug.SelectedRows.Count > 0 && dgvDrug.SelectedRows[0] != null) { DataGridViewRow row = dgvDrug.SelectedRows[0]; UpdateCurrentText(row); } //总店 labelinfo.Text = info; //中药 dgv_zhongyao.DataSource = dtzhongyao; //总店中药 rtxt_zhongyao.Text = info2; }); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Invoke((MethodInvoker) delegate() { formLoading.Dispose(); }); } }
private void UpdateScore() { try { CDBOperate dbobj = new CDBOperate(); DataTable dbtable = dbobj.UpdateScore(thisConn, dm); this.Invoke((MethodInvoker) delegate() { dgvDrugSearch.DataSource = dbtable; stripLabelInfo.Text = "更新不积分品种完成."; formLoading.Dispose(); }); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Invoke((MethodInvoker) delegate() { stripLabelInfo.Text = ""; formLoading.Dispose(); }); } }
/// <summary> /// 更新datagridview行 /// </summary> private void UpdateDgvRows(object sqlstr) { SqlCommand thisCommand = thisConn.CreateCommand(); thisCommand.CommandText = sqlstr as string; SqlDataReader thisReader = thisCommand.ExecuteReader(); while (thisReader.Read()) { string bm = "", mc = "", sccj = "", gg = "", zjm = "", dw = "", lbbm = "-1", lbmc = "", lsj = ""; if (!thisReader.IsDBNull(0)) { bm = thisReader.GetString(0); } if (!thisReader.IsDBNull(1)) { mc = thisReader.GetString(1); } if (!thisReader.IsDBNull(2)) { sccj = thisReader.GetString(2); } if (!thisReader.IsDBNull(3)) { gg = thisReader.GetString(3); } if (!thisReader.IsDBNull(4)) { zjm = thisReader.GetString(4); } if (!thisReader.IsDBNull(5)) { dw = thisReader.GetString(5); } if (!thisReader.IsDBNull(6)) { lbbm = thisReader.GetString(6); } if (!thisReader.IsDBNull(7)) { lbmc = thisReader.GetString(7); } if (!thisReader.IsDBNull(8)) { lsj = thisReader.GetDecimal(8).ToString("#0.00"); } this.Invoke((MethodInvoker) delegate() { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvDrug); row.Cells[dgvDrug.Columns["colDrugSpbm"].Index].Value = bm; row.Cells[dgvDrug.Columns["colmc"].Index].Value = mc; row.Cells[dgvDrug.Columns["colsccj"].Index].Value = sccj; row.Cells[dgvDrug.Columns["colgg"].Index].Value = gg; row.Cells[dgvDrug.Columns["colzjm"].Index].Value = zjm; row.Cells[dgvDrug.Columns["coldw"].Index].Value = dw; row.Cells[dgvDrug.Columns["collsj"].Index].Value = lsj; if (lbbm == "-1") { row.Cells[dgvDrug.Columns["collbbm"].Index].Value = "未分类"; } else { row.Cells[dgvDrug.Columns["collbbm"].Index].Value = lbmc; } row.Cells[dgvDrug.Columns["collbbm"].Index].Tag = lbbm; dgvDrug.Rows.Add(row); }); } thisReader.Close(); this.Invoke((MethodInvoker) delegate() { if (dgvDrug.Rows.Count > 0) { if (dgvDrug.SelectedRows.Count > 0 && dgvDrug.SelectedRows[0] != null) { DataGridViewRow row = dgvDrug.SelectedRows[0]; txtdw.Text = row.Cells[dgvDrug.Columns["coldw"].Index].Value.ToString(); txtgg.Text = row.Cells[dgvDrug.Columns["colgg"].Index].Value.ToString(); txtmc.Text = row.Cells[dgvDrug.Columns["colmc"].Index].Value.ToString(); txtsccj.Text = row.Cells[dgvDrug.Columns["colsccj"].Index].Value.ToString(); txtlsj.Text = row.Cells[dgvDrug.Columns["collsj"].Index].Value.ToString(); string lbmc = row.Cells[dgvDrug.Columns["collbbm"].Index].Value.ToString();//当前类别名称 string lbbm = "-1"; if (row.Cells[dgvDrug.Columns["collbbm"].Index].Tag != null && row.Cells[dgvDrug.Columns["collbbm"].Index].Tag.ToString() != "") { lbbm = row.Cells[dgvDrug.Columns["collbbm"].Index].Tag.ToString(); } txtOldType.Text = lbmc; txtOldType.Tag = lbbm; } } formLoading.Dispose(); }); }