/// <summary> /// 产品选择下拉列表选择触发事件 /// 选择后将对应代码产品信息填入货物信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBox_Product_SelectedIndexChanged(object sender, EventArgs e) { KeyValuePair <int, string> kv = (KeyValuePair <int, string>)comboBox_Product.SelectedItem; int product_id = kv.Key; string sql = "SELECT * FROM OSM_STORAGE WHERE ID = " + product_id; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; textBox_HW_NAME.Text = dr["HW_NAME"].ToString(); textBox_HW_CODE.Text = dr["HW_CODE"].ToString(); for (int i = 0; i < comboBox_HW_TYPE.Items.Count; i++) { KeyValuePair <string, string> item = (KeyValuePair <string, string>)comboBox_HW_TYPE.Items[i]; if (item.Key == dr["HW_TYPE"].ToString()) { comboBox_HW_TYPE.SelectedIndex = i; break; } } hw.setPRODUCT_ID(int.Parse(dr["ID"].ToString())); } }
/// <summary> /// 采购到货确认 /// </summary> /// <param name="purchase_id">采购记录编号</param> private void confirmPurchase(string purchase_id) { string sql = "SELECT OSM_PURCHASE_SHEET.ORDER_ID, OSM_PURCHASE_SHEET.PRODUCT_ID, OSM_STORAGE.HW_TYPE, OSM_STORAGE.HW_NAME, OSM_STORAGE.HW_CODE, OSM_PURCHASE_SHEET.PURCHASE_NUMBER "; sql += " FROM OSM_STORAGE INNER JOIN OSM_PURCHASE_SHEET ON OSM_STORAGE.ID = OSM_PURCHASE_SHEET.PRODUCT_ID"; sql += " WHERE OSM_PURCHASE_SHEET.ID = " + purchase_id; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Hashtable hashtable = new Hashtable(); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; hashtable.Add("ID", purchase_id); hashtable.Add("ORDER_ID", dr["ORDER_ID"]); hashtable.Add("PRODUCT_ID", dr["PRODUCT_ID"]); hashtable.Add("HW_TYPE", dr["HW_TYPE"]); hashtable.Add("HW_NAME", dr["HW_NAME"]); hashtable.Add("HW_CODE", dr["HW_CODE"]); hashtable.Add("PURCHASE_NUMBER", dr["PURCHASE_NUMBER"]); } FormOSM_Purchase_Confirm fpc = new FormOSM_Purchase_Confirm(); fpc.Set_fWindow(this); fpc.viewProduct(hashtable); fpc.StartPosition = FormStartPosition.CenterParent; fpc.ShowDialog(); //MessageBox.Show(purchase_id); }
/// <summary> /// 检查订单是否可以发货 /// </summary> /// <param name="order_id"></param> private void checkOrder(string order_id) { bool flag = true; AccessDB adb = new AccessDB(); string sql = "select PURCHASE_STATE from OSM_PURCHASE_SHEET where ORDER_ID = " + order_id; DataTable dt = adb.SQLTableQuery(sql); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; if ("1" == dr["PURCHASE_STATE"].ToString()) { flag = false; } } if (flag) { string updateSQL = "update OSM_ORDER_SHEET set ORDER_STATE = '3' where ID = " + order_id; if (adb.SQLExecute(updateSQL)) { MessageBox.Show("对应订单已可以进入发货流程!", "消息"); //string insertSQL = "insert into OSM_DILIVERY_SHEET(ORDER_ID,DILIVERY_STATE) values(" + order_id + ",'1')"; //if (adb.SQLExecute(insertSQL)) //{ // MessageBox.Show("对应订单已可以发货,已生成发货单!", "消息"); //} } } }
/// <summary> /// 查看报价单详情 /// </summary> /// <param name="offersheet_code"></param> private void viewOfferSheet(string offersheet_id) { string sql = "select * from OSM_OFFER_SHEET "; sql += "where ID = " + offersheet_id + " "; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Hashtable hashtable = new Hashtable(); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; hashtable.Add("ID", dr["ID"]); hashtable.Add("OFFERSHEET_CODE", dr["OFFERSHEET_CODE"]); hashtable.Add("GMF_ID", dr["GMF_ID"]); hashtable.Add("BJF_ID", dr["BJF_ID"]); hashtable.Add("OFFERSHEET_TYPE", dr["OFFERSHEET_TYPE"]); hashtable.Add("OFFERSHEET_DATE", dr["OFFERSHEET_DATE"]); hashtable.Add("OFFERSHEET_STATE", dr["OFFERSHEET_STATE"]); hashtable.Add("OFFERSHEET_REGION", dr["OFFERSHEET_REGION"]); hashtable.Add("CONFIRM_DATE", dr["CONFIRM_DATE"]); } FormOSM_Offers_Add form_add_offers = new FormOSM_Offers_Add(); form_add_offers.dataGridView_viewBtn_click_reaction(hashtable); form_add_offers.setViewState(1); form_add_offers.StartPosition = FormStartPosition.CenterParent; form_add_offers.ShowDialog(); }
/// <summary> /// 检查是否可以发货,不能发货则生成对应的采购单 /// </summary> /// <param name="hashList">货物列表</param> /// <param name="order_id">订单ID</param> /// <returns></returns> private bool checkDelivery(List <Hashtable> hashList, string order_id) { List <Hashtable> purchaseList = new List <Hashtable>(); AccessDB adb = new AccessDB(); for (int i = 0; i < hashList.Count; i++) { Hashtable ht = hashList[i]; string product_id = ht["PRODUCT_ID"].ToString(); int hw_need_number = int.Parse(ht["HW_NUMBER"].ToString()); string sql = "select ID,HW_NUMBER from OSM_STORAGE where ID = " + product_id + ""; DataTable dt = adb.SQLTableQuery(sql); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; int hw_storage_number = int.Parse(dr["HW_NUMBER"].ToString()); int hw_diff_number = hw_need_number - hw_storage_number; if (hw_diff_number > 0) { string updateSQL = "update OSM_STORAGE set HW_NUMBER = 0 where ID = " + product_id; adb.SQLExecute(updateSQL); ht["HW_NUMBER"] = hw_diff_number; purchaseList.Add(ht); } else { string updateSQL = "update OSM_STORAGE set HW_NUMBER = " + (-hw_diff_number) + " where ID = " + product_id; adb.SQLExecute(updateSQL); break; } } else { ht["HW_NUMBER"] = hw_need_number; purchaseList.Add(ht); } } if (purchaseList.Count == 0) { //string insertSQL = "insert into OSM_DILIVERY_SHEET(ORDER_ID,DILIVERY_STATE) values(" + order_id + ",'1')"; //if (adb.SQLExecute(insertSQL)) //{ // return true; //} return(true); } else { int count = createPurchaseSheet(purchaseList, order_id); MessageBox.Show("库存不足,新增" + count + "条采购记录", "消息"); return(false); } }
/// <summary> /// 刷新货物列表 /// </summary> public void refresh_hw_datagrid() { string sql = "select * from OSM_HW_LIST_V where OFFERSHEET_CODE = '" + textBox_OFFERSHEET_CODE.Text + "' "; sql += "order by ID DESC"; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); dataGridView_HW.DataSource = dt; }
/// <summary> /// 到货确认按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_OK_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(purchase_id) && !string.IsNullOrWhiteSpace(product_id) && !string.IsNullOrWhiteSpace(order_id)) { if (string.IsNullOrWhiteSpace(textBox_HWNumber.Text)) { MessageBox.Show("请填写到货数量,谢谢!", "警告"); return; } int number_want = int.Parse(textBox_PurchaseNumber.Text); int number_real = int.Parse(textBox_HWNumber.Text); if (number_want > number_real) { //需采购数量大于到货数量,不能确认 MessageBox.Show("到货数量小于需求数量,无法确认到货!", "警告"); return; } else { //到货数量大于等于需采购数量,改变采购记录状态,改变库存数量 AccessDB adb = new AccessDB(); string sql = "select HW_NUMBER,REAL_NUMBER from OSM_STORAGE where ID = " + product_id; DataTable dt = adb.SQLTableQuery(sql); DataRow dr = dt.Rows[0]; int hw_number = int.Parse(dr["HW_NUMBER"].ToString()); int real_number = int.Parse(dr["REAL_NUMBER"].ToString()); real_number += number_real; hw_number += number_real - number_want; string updateSQL = "update OSM_STORAGE set HW_NUMBER = " + hw_number + ", REAL_NUMBER = " + real_number + " where ID = " + product_id; if (adb.SQLExecute(updateSQL)) { updateSQL = "update OSM_PURCHASE_SHEET set PURCHASE_STATE = '2' where ID = " + purchase_id; if (adb.SQLExecute(updateSQL)) { MessageBox.Show("到货确认成功!", "消息"); fWindow.refresh_dataGridView(); checkOrder(order_id); this.Close(); this.Dispose(); } } } } else { MessageBox.Show("UNEXCEPTED ERROR!", "ERROR"); } }
/// <summary> /// 对应报价单审核通过 /// </summary> /// <param name="offerSheetID">报价单ID</param> /// <param name="offerSheetCode">报价单编号</param> private void PassOfferSheet(string offerSheetID, string offerSheetCode) { AccessDB adb = new AccessDB(); string query = "select sum(HW_TOTALPRICE) as REQUIRE_PAYMENT from OSM_HW where OFFERSHEET_CODE = '" + offerSheetCode + "'"; DataTable dt = adb.SQLTableQuery(query); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; double require_payment = 0; try { require_payment = double.Parse(dr["REQUIRE_PAYMENT"].ToString()); } catch (Exception exception) { MessageBox.Show("该报价单没有对应的货物列表,无法通过审核!" + exception.ToString(), "警告"); return; } FormOSM_PayMode_Select fps = new FormOSM_PayMode_Select(); fps.setOfferForm(this); fps.StartPosition = FormStartPosition.CenterParent; fps.ShowDialog(); if (!string.IsNullOrWhiteSpace(pay_mode)) { //生成订单存入数据库 string insertSQL = "insert into OSM_ORDER_SHEET(OFFERSHEET_ID,ORDER_STATE,REQUIRE_PAYMENT,ORDER_DATE,PAY_STATE,PAY_MODE) values ('"; insertSQL += offerSheetID + "','1'," + require_payment + ",#" + DateTime.Now.ToString("yyyy-MM-dd") + "#,'1','" + pay_mode + "')"; if (adb.SQLExecute(insertSQL)) { MessageBox.Show("已将审核通过的报价单生成订单", "消息"); string sql = "update OSM_OFFER_SHEET set OFFERSHEET_STATE = '2' where ID = " + offerSheetID; if (adb.SQLExecute(sql)) { main_form.TSMItem_offer_aduit_Refresh(); } } } else { MessageBox.Show("请确定付款方式!", "警告"); } } else { MessageBox.Show("该报价单没有对应的货物列表,无法通过审核!", "警告"); } }
/// <summary> /// 购买方按钮index变化触发事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBox_BUYER_SelectedIndexChanged(object sender, EventArgs e) { KeyValuePair <int, string> kv = ((KeyValuePair <int, string>)comboBox_BUYER.SelectedItem); string id = kv.Key.ToString(); string sql = "select COM_NAME,COM_CODE,ADDR,CONTACT,PHONE,ZIP_CODE,EMAIL,FAX,COMMENT from OSM_GMF where ID = "; sql += id; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); if (dt.Rows.Count == 1) { //构造购买方ID buyer.setID(int.Parse(id)); //报价单中购买方ID offer_sheet.setGMF_ID(int.Parse(id)); DataRow dr = dt.Rows[0]; buyer.setCOM_NAME(dr.ItemArray[0].ToString()); buyer.setCOM_CODE(dr.ItemArray[1].ToString()); buyer.setADDR(dr.ItemArray[2].ToString()); buyer.setCONTACT(dr.ItemArray[3].ToString()); buyer.setPHONE(dr.ItemArray[4].ToString()); buyer.setZIP_CODE(dr.ItemArray[5].ToString()); buyer.setEMAIL(dr.ItemArray[6].ToString()); buyer.setFAX(dr.ItemArray[7].ToString()); buyer.setCOMMENT(dr.ItemArray[8].ToString()); textBox_COM_NAME_BUYER.Text = buyer.getCOM_NAME(); textBox_COM_CODE_BUYER.Text = buyer.getCOM_CODE(); textBox_ADDR_BUYER.Text = buyer.getADDR(); textBox_CONTACT_BUYER.Text = buyer.getCONTACT(); textBox_PHONE_BUYER.Text = buyer.getPHONE(); textBox_ZIPCODE_BUYER.Text = buyer.getZIP_CODE(); textBox_EMAIL_BUYER.Text = buyer.getEMAIL(); textBox_FAX_BUYER.Text = buyer.getFAX(); textBox_COMMENT_BUYER.Text = buyer.getCOMMENT(); } else { MessageBox.Show("数据库返回数据不止一条!"); return; } }
/// <summary> /// 检查订单对应货物列表 /// </summary> /// <param name="order_id">订单ID</param> /// <param name="offersheet_code">报价单编号</param> private void checkOfferHW(string order_id, string offersheet_code) { string sql = "select PRODUCT_ID,HW_NUMBER from OSM_HW where OFFERSHEET_CODE = '" + offersheet_code + "'"; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); List <Hashtable> hashList = new List <Hashtable>(); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dt.Rows[i]; Hashtable ht = new Hashtable(); ht.Add("PRODUCT_ID", dr["PRODUCT_ID"]); //ht.Add("HW_NAME", dr["HW_NAME"]); //ht.Add("HW_CODE", dr["HW_CODE"]); ht.Add("HW_NUMBER", dr["HW_NUMBER"]); hashList.Add(ht); } if (checkDelivery(hashList, order_id)) { //MessageBox.Show("根据与库存容量比对,可以发货!", "消息"); sql = "update OSM_ORDER_SHEET set ORDER_STATE = '3' where ID = " + order_id; if (adb.SQLExecute(sql)) { MessageBox.Show("库存充足,对应订单已可以进行发货审核!", "消息"); //查询订单视图返回结果 queryFromOrderSheetV(dataGridView_Order, "where ORDER_STATE = '1' "); } } else { sql = "update OSM_ORDER_SHEET set ORDER_STATE = '2' where ID = " + order_id; if (adb.SQLExecute(sql)) { //查询订单视图返回结果 queryFromOrderSheetV(dataGridView_Order, "where ORDER_STATE = '1' "); } } }
/// <summary> /// 通过按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_pass_Click(object sender, EventArgs e) { AccessDB adb = new AccessDB(); string query = "select sum(HW_TOTALPRICE) from OSM_HW where OFFERSHEET_CODE = '" + offerSheetCode + "'"; DataTable dt = adb.SQLTableQuery(query); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; double require_payment = 0; try { require_payment = double.Parse(dr[0].ToString()); } catch (Exception exception) { MessageBox.Show("该报价单没有对应的货物列表,无法通过审核!" + exception.ToString(), "警告"); return; } //生成订单存入数据库 string insertSQL = "insert into OSM_ORDER_SHEET(OFFERSHEET_ID,ORDER_STATE,REQUIRE_PAYMENT,ORDER_DATE,PAY_STATE) values ('" + offerSheetID + "','1'," + require_payment + ",#" + DateTime.Now.ToString("yyyy-MM-dd") + "#,'1')"; if (adb.SQLExecute(insertSQL)) { MessageBox.Show("已将审核通过的报价单生成订单", "消息"); string sql = "update OSM_OFFER_SHEET set OFFERSHEET_STATE = '2' where ID = " + offerSheetID; if (adb.SQLExecute(sql)) { main_form.TSMItem_offer_aduit_Refresh(); this.Close(); this.Dispose(); } } } else { MessageBox.Show("该报价单没有对应的货物列表,无法通过审核!", "警告"); } }
/// <summary> /// 查看订单按钮 /// </summary> /// <param name="order_id"></param> private void viewOrderSheet(string order_id) { string sql = "select OSM_ORDER_SHEET.ID,OFFERSHEET_ID,ORDER_STATE,ORDER_DATE,PAY_MODE,PAY_STATE,ALREADY_PAYMENT,PRE_PAYMENT,REQUIRE_PAYMENT,OFFERSHEET_CODE "; sql += " from (OSM_ORDER_SHEET inner join OSM_OFFER_SHEET on OSM_ORDER_SHEET.OFFERSHEET_ID = OSM_OFFER_SHEET.ID) "; sql += " where OSM_ORDER_SHEET.ID = " + order_id + " "; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Hashtable hashtable = new Hashtable(); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; hashtable.Add("ID", dr["ID"]); hashtable.Add("OFFERSHEET_ID", dr["OFFERSHEET_ID"]); hashtable.Add("ORDER_STATE", dr["ORDER_STATE"]); hashtable.Add("ORDER_DATE", dr["ORDER_DATE"]); hashtable.Add("PAY_MODE", dr["PAY_MODE"]); hashtable.Add("PAY_STATE", dr["PAY_STATE"]); hashtable.Add("ALREADY_PAYMENT", dr["ALREADY_PAYMENT"]); hashtable.Add("PRE_PAYMENT", dr["PRE_PAYMENT"]); hashtable.Add("REQUIRE_PAYMENT", dr["REQUIRE_PAYMENT"]); hashtable.Add("OFFERSHEET_CODE", dr["OFFERSHEET_CODE"]); } FormOSM_Order_View orderView = new FormOSM_Order_View(); orderView.setOrderID(order_id); //设置窗口状态为查看 orderView.setViewState(0); orderView.viewOrderSheet(hashtable); orderView.StartPosition = FormStartPosition.CenterParent; orderView.ShowDialog(); }
/// <summary> /// 查询对应报价单货物列表 /// </summary> /// <param name="dgv"></param> private void queryByHW(DataGridView dgv) { switch (view_state) { case 0: break; case 1: dgv.Columns["delBtn"].Visible = false; break; case 2: break; } string sql = "select * from OSM_HW_LIST_V where OFFERSHEET_CODE = '" + textBox_OFFERSHEET_CODE.Text + "' "; sql += "order by ID DESC"; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); dgv.DataSource = dt; }
/// <summary> /// 打开订单窗口可触发动作,显示读取到的数据 /// </summary> /// <param name="ht"></param> public void viewOrderSheet(Hashtable ht) { if (viewState == 0) { textBox_AlreadyPayment.ReadOnly = true; textBox_PrePayment.ReadOnly = true; textBox_RequirePayment.ReadOnly = true; //textBox_AlreadyPayment.Enabled = false; //textBox_PrePayment.Enabled = false; //textBox_RequirePayment.Enabled = false; comboBox_OrderState.Enabled = false; comboBox_PayMode.Enabled = false; comboBox_PayState.Enabled = false; dateTimePicker_OrderDate.Enabled = false; } if (viewState == 1) { textBox_RequirePayment.ReadOnly = true; comboBox_OrderState.Enabled = false; comboBox_PayState.Enabled = false; dateTimePicker_OrderDate.Enabled = false; } textBox_OfferSheetCode.Text = ht["OFFERSHEET_CODE"].ToString(); textBox_AlreadyPayment.Text = ht["ALREADY_PAYMENT"].ToString(); textBox_PrePayment.Text = ht["PRE_PAYMENT"].ToString(); textBox_RequirePayment.Text = ht["REQUIRE_PAYMENT"].ToString(); dateTimePicker_OrderDate.Text = ((DateTime)ht["ORDER_DATE"]).ToString("yyyy-MM-dd"); for (int i = 0; i < comboBox_OrderState.Items.Count; i++) { KeyValuePair <string, string> kv = (KeyValuePair <string, string>)comboBox_OrderState.Items[i]; if (ht["ORDER_STATE"].ToString() == kv.Key) { comboBox_OrderState.SelectedIndex = i; break; } } if (string.IsNullOrWhiteSpace(ht["PAY_MODE"].ToString())) { comboBox_PayMode.SelectedIndex = -1; } else { for (int i = 0; i < comboBox_PayMode.Items.Count; i++) { KeyValuePair <string, string> kv = (KeyValuePair <string, string>)comboBox_PayMode.Items[i]; if (ht["PAY_MODE"].ToString() == kv.Key) { comboBox_PayMode.SelectedIndex = i; break; } } } for (int i = 0; i < comboBox_PayState.Items.Count; i++) { KeyValuePair <string, string> kv = (KeyValuePair <string, string>)comboBox_PayState.Items[i]; if (ht["PAY_STATE"].ToString() == kv.Key) { comboBox_PayState.SelectedIndex = i; break; } } string sql = "select * from OSM_HW_LIST_V where OFFERSHEET_CODE = '" + ht["OFFERSHEET_CODE"].ToString() + "'"; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); dataGridView_HW.AutoGenerateColumns = false; dataGridView_HW.DataSource = dt; }
/// <summary> /// 检查是否可以发货 /// </summary> /// <param name="order_id"></param> private void checkDelivery(string order_id) { string sql = "select PAY_MODE,PAY_STATE,ALREADY_PAYMENT,PRE_PAYMENT,REQUIRE_PAYMENT from OSM_ORDER_SHEET where ID = " + order_id; AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Hashtable hashtable = new Hashtable(); if (dt.Rows.Count == 1) { DataRow dr = dt.Rows[0]; string pay_mode = dr["PAY_MODE"].ToString(); string pay_state = dr["PAY_STATE"].ToString(); double already_payment = double.Parse(dr["ALREADY_PAYMENT"].ToString()); double pre_payment = double.Parse(dr["PRE_PAYMENT"].ToString()); double require_payment = double.Parse(dr["REQUIRE_PAYMENT"].ToString()); //hashtable.Add("PAY_MODE", dr["PAY_MODE"]); //hashtable.Add("PAY_STATE", dr["PAY_STATE"]); //hashtable.Add("ALREADY_PAYMENT", dr["ALREADY_PAYMENT"]); //hashtable.Add("PRE_PAYMENT", dr["PRE_PAYMENT"]); //hashtable.Add("REQUIRE_PAYMENT", dr["REQUIRE_PAYMENT"]); switch (pay_mode) { case "1": if (pay_state == "2") { orderDeliver(order_id); } else { MessageBox.Show("未付全款,无法发货!", "警告"); } break; case "2": if (pay_state == "1") { orderDeliver(order_id); } break; case "3": if (pay_state == "3") { orderDeliver(order_id); } else { MessageBox.Show("未预付部分款,无法发货!", "警告"); } break; } string checkPayListSQL = "select ID from OSM_PAYMENTREMINDER_SHEET where ORDER_ID = " + order_id; DataTable dataT = adb.SQLTableQuery(checkPayListSQL); if (dataT.Rows.Count == 0) { createPaySheet(order_id); } } }
/// <summary> /// DataGridView单元格点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView_PayList_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView_PayList.Columns[e.ColumnIndex].Name == "viewOrderBtn") { string order_id = dataGridView_PayList.Rows[e.RowIndex].Cells["ORDER_ID"].Value.ToString(); viewOrderSheet(order_id); } if (dataGridView_PayList.Columns[e.ColumnIndex].Name == "PayBtn") { AccessDB adb = new AccessDB(); string p_id = dataGridView_PayList.Rows[e.RowIndex].Cells["ID"].Value.ToString(); string order_id = dataGridView_PayList.Rows[e.RowIndex].Cells["ORDER_ID"].Value.ToString(); string payMode = dataGridView_PayList.Rows[e.RowIndex].Cells["PAY_MODE"].Value.ToString(); string payState = dataGridView_PayList.Rows[e.RowIndex].Cells["PAY_STATE"].Value.ToString(); string need_to_pay = dataGridView_PayList.Rows[e.RowIndex].Cells["REQUIRE_PAYMENT"].Value.ToString(); string pre_pay = dataGridView_PayList.Rows[e.RowIndex].Cells["PRE_PAYMENT"].Value.ToString(); string already_pay = dataGridView_PayList.Rows[e.RowIndex].Cells["ALREADY_PAYMENT"].Value.ToString(); switch (payMode) { case "1": if (payState == "1") { getPayed(order_id, p_id, need_to_pay); } else { MessageBox.Show("该订单已付款!", "消息"); return; } break; case "2": if (payState == "1") { string sql = "select ORDER_STATE from OSM_ORDER_SHEET where ID = " + order_id; DataTable dt = adb.SQLTableQuery(sql); DataRow dr = dt.Rows[0]; string order_state = dr["ORDER_STATE"].ToString(); if (order_state == "6") { getPayed(order_id, p_id, need_to_pay); } else { MessageBox.Show("该订单为货到付款,现订单状态非已到货,无法提前付款!", "警告"); } } else { MessageBox.Show("该订单已付款!", "消息"); return; } break; case "3": if (payState == "1") { getPrePayed(order_id, p_id, need_to_pay); } else if (payState == "3") { string sql = "select ORDER_STATE from OSM_ORDER_SHEET where ID = " + order_id; DataTable dt = adb.SQLTableQuery(sql); DataRow dr = dt.Rows[0]; string order_state = dr["ORDER_STATE"].ToString(); if (order_state == "6") { getRestPayed(order_id, p_id, need_to_pay, already_pay); } else { MessageBox.Show("该订单已预付部分款,现订单状态非已到货,无法提前付剩余款!", "警告"); } } else { MessageBox.Show("该订单已付款!", "消息"); return; } break; default: MessageBox.Show("付款方式出错!", "错误"); break; } } }