private void button_OK_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBox_Name.Text)) { MessageBox.Show("产品名称不能为空!", "警告"); return; } if (string.IsNullOrWhiteSpace(textBox_Code.Text)) { MessageBox.Show("产品代码不能为空!", "警告"); return; } if (comboBox_Type.SelectedIndex == -1) { MessageBox.Show("所属设备不能为空!", "警告"); return; } AccessDB adb = new AccessDB(); KeyValuePair<string,string> item = (KeyValuePair<string,string>)(comboBox_Type.SelectedItem); string insertSQL = "INSERT INTO OSM_STORAGE(HW_NAME,HW_CODE,HW_TYPE,COMMENT) VALUES ("; insertSQL += "'" + textBox_Name.Text + "','" + textBox_Code.Text + "','" + item.Key + "','" + textBox_Comment.Text + "')"; if (adb.SQLExecute(insertSQL)) { MessageBox.Show("添加成功!", "消息"); HWWindow.refresh_product_comboBox(); this.Close(); this.Dispose(); } }
/// <summary> /// 以数据字典中的内容填充下拉列表 /// </summary> /// <param name="whereString"></param> /// <param name="cmbx"></param> public static void setZD_ComboBox(string whereString, ComboBox cmbx) { AccessDB adb = new AccessDB(); Dictionary<string, string> dict = adb.QuerySJZD(whereString); BindingSource bs = new BindingSource(); bs.DataSource = dict; cmbx.DataSource = bs; cmbx.ValueMember = "Key"; cmbx.DisplayMember = "Value"; }
/// <summary> /// 以数据字典中的内容填充下拉列表 /// </summary> /// <param name="whereString"></param> /// <param name="cmbx"></param> public static void setZD_ComboBox(string whereString, ComboBox cmbx) { AccessDB adb = new AccessDB(); Dictionary <string, string> dict = adb.QuerySJZD(whereString); BindingSource bs = new BindingSource(); bs.DataSource = dict; cmbx.DataSource = bs; cmbx.ValueMember = "Key"; cmbx.DisplayMember = "Value"; }
/// <summary> /// 确认按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_OK_Click(object sender, EventArgs e) { if (textBox_old_pwd.Text == "") { MessageBox.Show("原密码输入框不能为空!", "警告"); return; } if (textBox_new_pwd.Text == "") { MessageBox.Show("新密码输入框不能为空!", "警告"); return; } AccessDB adb = new AccessDB(); string sql = "SELECT * FROM BASE_USERS WHERE USER_ID = '" + uid + "'"; DataSet ds = adb.SQLQuery(sql); DataTable dt = ds.Tables[0]; DataRow dr = dt.Rows[0]; if (textBox_old_pwd.Text != dr["USER_PWD"].ToString() && dr["USER_PWD"] != null) { MessageBox.Show("原密码输入错误!", "警告"); return; } if (textBox_new_pwd.Text == textBox_old_pwd.Text) { MessageBox.Show("新密码请不要与旧密码重复", "警告"); return; } if (textBox_new_pwd.Text != textBox_pwd_confirm.Text) { MessageBox.Show("两次输入密码不一致!", "警告"); return; } sql = "UPDATE BASE_USERS SET USER_PWD = '" + textBox_new_pwd.Text + "' WHERE USER_ID = '" + uid + "'"; if (adb.SQLExecute(sql)) { MessageBox.Show("密码修改成功!", "消息"); this.Close(); } }
private void button_OK_Click(object sender, EventArgs e) { AccessDB adb = new AccessDB(); string updateSQL = "update OSM_DILIVERY_SHEET set "; string orderUpdateSQL = "update OSM_ORDER_SHEET set ORDER_STATE = "; if (state == 0) { //发货时间 updateSQL += " DILIVERY_DATE = #" + dateTimePicker_Delivery.Text + "#,DILIVERY_STATE='2' where ID = " + deliverySheetID; orderUpdateSQL += " '5' where ID = " + orderID; } else { //到货时间 updateSQL += " ARRIVE_DATE = #" + dateTimePicker_Delivery.Text + "#,DILIVERY_STATE='3' where ID = " + deliverySheetID; orderUpdateSQL += " '6' where ID = " + orderID; } if (adb.SQLExecute(updateSQL)) { if (adb.SQLExecute(orderUpdateSQL)) { MessageBox.Show("确认成功!", "消息"); this.Close(); this.Dispose(); } else { MessageBox.Show("更新订单列表出错!", "错误"); this.Close(); this.Dispose(); } } else { MessageBox.Show("更新发货单列表出错!", "错误"); this.Close(); this.Dispose(); } }
private void login() { AccessDB adb = new AccessDB(); string sql = "select * from BASE_USERS where USER_ID = '" + TB_UserName.Text + "' and USER_PWD = '" + TB_PWD.Text + "'"; Hashtable ht = adb.login(sql); if (ht != null) { id = ht["id"].ToString(); userid = ht["userid"].ToString(); username = ht["username"].ToString(); //MessageBox.Show("登录成功!", "欢迎"); //登陆成功,返回成功信息 DialogResult = DialogResult.OK; } else { MessageBox.Show("用户名密码不匹配!", "警告"); } }
/// <summary> /// 以sql查询结果填充下拉列表 /// </summary> /// <param name="sql"></param> /// <param name="cbox"></param> public static void fillComboBox(string sql, ComboBox cbox) { AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Dictionary<int, string> Dict = new Dictionary<int, string>(); foreach (DataRow dr in dt.Rows) { int id = (int)dr.ItemArray[0]; string com_name = dr.ItemArray[1].ToString(); Dict.Add(id, com_name); } BindingSource bs = new BindingSource(); bs.DataSource = Dict; cbox.DataSource = bs; cbox.ValueMember = "Key"; cbox.DisplayMember = "Value"; }
/// <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> /// 以sql查询结果填充下拉列表 /// </summary> /// <param name="sql"></param> /// <param name="cbox"></param> public static void fillComboBox(string sql, ComboBox cbox) { AccessDB adb = new AccessDB(); DataTable dt = adb.SQLTableQuery(sql); Dictionary <int, string> Dict = new Dictionary <int, string>(); foreach (DataRow dr in dt.Rows) { int id = (int)dr.ItemArray[0]; string com_name = dr.ItemArray[1].ToString(); Dict.Add(id, com_name); } BindingSource bs = new BindingSource(); bs.DataSource = Dict; cbox.DataSource = bs; cbox.ValueMember = "Key"; cbox.DisplayMember = "Value"; }
/// <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="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> /// 查看订单按钮 /// </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="sender"></param> /// <param name="e"></param> private void button_unpass_Click(object sender, EventArgs e) { string sql = "update OSM_OFFER_SHEET set OFFERSHEET_STATE = '3' where ID = " + offerSheetID; AccessDB adb = new AccessDB(); if (adb.SQLExecute(sql)) { main_form.TSMItem_offer_aduit_Refresh(); this.Close(); this.Dispose(); } }
/// <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; } }
private void comboBox_recordsPerPage_SelectedIndexChanged(object sender, EventArgs e) { pageIndex = 1; pageSize = int.Parse(comboBox_recordsPerPage.SelectedItem.ToString()); AccessDB adb = new AccessDB(); //执行查询第一页,默认页面容量为选择页面容量 DataTable dt = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum); dgv.DataSource = dt; label_current_page.Text = "1/" + pageCount.ToString(); label_record_sum.Text = recordSum.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="offersheet_code"></param> private void delOfferSheet(string offersheet_code) { AccessDB adb = new AccessDB(); string whereString = " where OFFERSHEET_CODE = '" + offersheet_code + "'"; if (adb.SQLTableDelete("OSM_HW", whereString) >= 0) { if (adb.SQLTableDelete("OSM_OFFER_SHEET", whereString) == 1) { MessageBox.Show("删除成功!", "消息"); queryFromOfferSheetV(dataGridView_OfferSheet); } } }
/// <summary> /// 查看报价单按钮 /// </summary> /// <param name="offersheet_code"></param> private void viewOfferSheet(string offersheet_code) { string sql = "select * from OSM_OFFER_SHEET "; sql += "where OFFERSHEET_CODE = '" + offersheet_code + "'"; 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.setMainForm(main_form); form_add_offers.setViewState(1); form_add_offers.StartPosition = FormStartPosition.CenterParent; form_add_offers.ShowDialog(); }
/// <summary> /// 付款操作 /// </summary> /// <param name="pre_pay">预付款金额</param> /// <param name="actual_pay">实际付款</param> private void prePayOrder(double pre_pay, double actual_pay) { AccessDB adb = new AccessDB(); string PaySheetUpdateSQL = "update OSM_PAYMENTREMINDER_SHEET set ACHIEVE_DATE = #" + DateTime.Now.ToString("yyyy-MM-dd") + "# where ID = " + p_id; string OrderSheetUpdateSQL = "update OSM_ORDER_SHEET set PAY_STATE = '3',PRE_PAYMENT = " + pre_pay + ",ALREADY_PAYMENT = " + actual_pay + " where ID = " + order_id; if (adb.SQLExecute(OrderSheetUpdateSQL)) { if (adb.SQLExecute(PaySheetUpdateSQL)) { MessageBox.Show("预付部分款成功", "消息"); } } }
/// <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; } } }
/// <summary> /// 对应报价单审核不通过 /// </summary> /// <param name="offerSheetID">报价单ID</param> private void FailOfferSheet(string offerSheetID) { string sql = "update OSM_OFFER_SHEET set OFFERSHEET_STATE = '3' where ID = " + offerSheetID; AccessDB adb = new AccessDB(); if (adb.SQLExecute(sql)) { main_form.TSMItem_offer_aduit_Refresh(); } }
/// <summary> /// 付款操作 /// </summary> /// <param name="rest_pay">预付款阶段已付款</param> /// <param name="actual_pay">实际付款</param> private void restPayOrder(double already_pay, double actual_pay) { AccessDB adb = new AccessDB(); double payment = already_pay + actual_pay; string PaySheetUpdateSQL = "update OSM_PAYMENTREMINDER_SHEET set ACHIEVE_DATE = #" + DateTime.Now.ToString("yyyy-MM-dd") + "# where ID = " + p_id; string OrderSheetUpdateSQL = "update OSM_ORDER_SHEET set PAY_STATE = '2',ALREADY_PAYMENT = " + payment + " where ID = " + order_id; if (adb.SQLExecute(OrderSheetUpdateSQL)) { if (adb.SQLExecute(PaySheetUpdateSQL)) { MessageBox.Show("已付清全款!", "消息"); } } }
/// <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="order_id"></param> private void orderDeliver(string order_id) { AccessDB adb = new AccessDB(); string insertSQL = "insert into OSM_DILIVERY_SHEET(ORDER_ID,DILIVERY_STATE) values(" + order_id + ",'1')"; if (adb.SQLExecute(insertSQL)) { string updateSQL = "update OSM_ORDER_SHEET set ORDER_STATE = '4' where ID = " + order_id; if (adb.SQLExecute(updateSQL)) { MessageBox.Show("该订单可以发货,已生成发货单!", "消息"); queryFromOrderSheetV(dataGridView_Order, "where ORDER_STATE = '3' "); } } }
/// <summary> /// 根据得到的hashList货物列表生成采购单 /// </summary> /// <param name="purchaseList">采购货物列表</param> /// <param name="order_id">订单</param> /// <returns>新增采购记录数量</returns> private int createPurchaseSheet(List<Hashtable> purchaseList, string order_id) { AccessDB adb = new AccessDB(); int count = 0; string insertSql = "insert into OSM_PURCHASE_SHEET(ORDER_ID,PRODUCT_ID,PURCHASE_NUMBER,PURCHASE_STATE,INIT_DATE) values ("; for (int i = 0; i < purchaseList.Count; i++) { Hashtable ht = purchaseList[i]; string valueString = order_id + ","; valueString += ht["PRODUCT_ID"].ToString() + ","; //valueString += "'" + ht["HW_NAME"].ToString() + "',"; //valueString += "'" + ht["HW_CODE"].ToString() + "',"; valueString += ht["HW_NUMBER"].ToString() + ",'1',#" + DateTime.Now.ToString("yyyy-MM-dd") + "#)"; string sql = insertSql + valueString; if (adb.SQLExecute(sql)) { count++; } } return count; }
/// <summary> /// 跳转按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_goToPage_Click(object sender, EventArgs e) { pageIndex = int.Parse(textBox_page_index.Text); if (pageIndex > pageCount) { MessageBox.Show("页码大于总页数!", "错误"); return; } AccessDB adb = new AccessDB(); DataTable dt = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum); dgv.DataSource = dt; textBox_page_index.Text = pageIndex.ToString(); label_current_page.Text = pageIndex.ToString() + "/" + pageCount.ToString(); label_record_sum.Text = recordSum.ToString(); }
/// <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="sender"></param> /// <param name="e"></param> private void button_last_page_Click(object sender, EventArgs e) { pageIndex = pageCount; AccessDB adb = new AccessDB(); DataTable dt = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum); dgv.DataSource = dt; textBox_page_index.Text = pageIndex.ToString(); label_current_page.Text = pageIndex.ToString() + "/" + pageCount.ToString(); label_record_sum.Text = recordSum.ToString(); }
/// <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> /// 实现数据库插入报价方数据 /// </summary> /// <param name="seller"></param> /// <returns></returns> private bool addSeller(Seller seller) { string sql = "insert into OSM_BJF(COM_NAME,ADDR,CONTACT,PHONE,ZIP_CODE,FAX,EMAIL,COMMENT) "; sql += " values('" + seller.getCOM_NAME() + "','" + seller.getADDR() + "','"; sql += seller.getCONTACT() + "','" + seller.getPHONE() + "','" + seller.getZIP_CODE(); sql += "','" + seller.getFAX() + "','" + seller.getEMAIL() + "','" + seller.getCOMMENT() + "')"; AccessDB adb = new AccessDB(); bool isExecuteSucc = adb.SQLExecute(sql); if (isExecuteSucc) { MessageBox.Show("添加成功!", "消息"); } else { MessageBox.Show("添加失败!", "消息"); } return isExecuteSucc; }
/// <summary> /// 生成收款单 /// </summary> /// <param name="order_id">订单ID</param> private void createPaySheet(string order_id) { AccessDB adb = new AccessDB(); string payListSQL = "insert into OSM_PAYMENTREMINDER_SHEET(ORDER_ID,GEN_DATE) values (" + order_id + ",#" + DateTime.Now.ToString("yyyy-MM-dd") + "#)"; if (adb.SQLExecute(payListSQL)) { MessageBox.Show("已生成对应收款单!", "消息"); } else { MessageBox.Show("生成收款单遇到错误!", "错误"); } }
/// <summary> /// 实现数据库插入货物数据 /// </summary> /// <param name="hw"></param> /// <returns></returns> private bool addHW(HW hw) { string sql = "insert into OSM_HW(OFFERSHEET_CODE,PRODUCT_ID,HW_NUMBER,HW_PRICE,HW_TOTALPRICE,COMMENT) "; sql += "values('" + hw.getOFFERSHEET_CODE() + "'," + hw.getPRODUCT_ID() + ","; sql += hw.getHW_NUMBER().ToString() + "," + hw.getHW_PRICE().ToString(); sql += "," + hw.getHW_TOTALPRICE().ToString() + ",'" + hw.getCOMMENT() + "')"; AccessDB adb = new AccessDB(); bool isExecuteSucc = adb.SQLExecute(sql); if (isExecuteSucc) { MessageBox.Show("添加成功!", "消息"); } else { MessageBox.Show("添加失败!", "消息"); } return isExecuteSucc; }