//刪除 private void tsbDelete_Click(object sender, EventArgs e) { string Msg = "是否要進行進貨單[" + txtStockID.Text + "]刪除動作?\r\n"; DialogResult DR; DR = MessageBox.Show(Msg, "刪除進貨單", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (DR == DialogResult.Yes) { if (CheckField()) { SIS.DBClass.DBClassStockDetails DBCSD = new DBClass.DBClassStockDetails(); SIS.Configuration.Items[] oldItems = null; oldItems = DBCSD.QueryData(txtStockID.Text); if (oldItems == null) { MessageBox.Show("對不起,資料庫不存在[ " + txtStockID.Text + " ]進貨單資料!!(資料不存在)", "資料刪除"); return; } RunDeleteData(oldItems); } } else { MessageBox.Show("取消進貨單刪除動作!!", "刪除進貨單"); } }
/// <summary> /// 查詢進貨單相關資料 /// </summary> /// <param name="StockID">傳入進貨單編號</param> /// <param name="CSC">傳入存放查詢結果資料的SIS.Configuration.ClsStockConfig CSC</param> /// <returns></returns> public bool QueryData(string StockID, SIS.Configuration.ClsStockConfig CSC) { InitDB(); string selectCmd; selectCmd = "Select * From " + TableName + " Where StockID='" + StockID + "'"; try { cmd = new SqlCommand(selectCmd, conn); dr = cmd.ExecuteReader(); if (dr.Read()) { CSC.StockID = StockID; CSC.StockDate = dr["StockDate"].ToString(); CSC.TotalPreTax = int.Parse(dr["TotalPreTax"].ToString()); CSC.Tax = int.Parse(dr["Tax"].ToString()); CSC.TotalAfterTax = int.Parse(dr["TotalAfterTax"].ToString()); CSC.ManufacturerID = dr["ManufacturerID"].ToString(); CSC.BusinessTaxStockTaxRate = int.Parse(dr["BusinessTaxStockTaxRate"].ToString()); CSC.AmountPaid = int.Parse(dr["AmountPaid"].ToString()); CSC.UnpaidAmount = int.Parse(dr["UnpaidAmount"].ToString()); CSC.StockStaff = dr["StockStaff"].ToString(); CSC.PaymentType = dr["PaymentType"].ToString(); CSC.Notes = dr["Notes"].ToString(); conn.Close(); SIS.DBClass.DBClassStockDetails DBSD = new DBClassStockDetails(); CSC.StockItems = DBSD.QueryData(StockID); if (CSC.StockItems == null) { return(false); } else { return(true); } } else { conn.Close(); return(false); } } catch (Exception ex) { errorMsg = ex.Message; conn.Close(); return(false); } }