protected void btnAddPO_Click(object sender, EventArgs e) { PurchaseOrder PO = new PurchaseOrder(); PO.PONumber = txtBoxPoNo.Text; PO.DeliveryDate = txtBoxDeliveryDate.Text; PO.RequisitionNumber = txtBoxRequisitionNo.Text; PO.PurchaseDate = txtBoxPurchaseDate.Text; PO.Title = txtBoxTitle.Text; lblMessage.Text = PurchaseOrder.savePO(PO); lblMessage.Visible = true; if (lblMessage.Text == "Purchase Order created successfully<bR>") { GridView1.DataBind(); panelCreateNewPO.Visible = false; btnCreateNewPO.Visible = true; txtBoxPoNo.Text = ""; txtBoxRequisitionNo.Text = ""; txtBoxPurchaseDate.Text = ""; txtBoxDeliveryDate.Text = ""; txtBoxTitle.Text = ""; } }
public Equipment() { currentLocation = new Logistics(); groups = new List<Group>(); po = new PurchaseOrder(); licenses = new List<License>(); warranties = new List<Warranty>(); }
public Computer() { monitors = new List<Monitor>(); po = new PurchaseOrder(); groups = new List<Group>(); logistics = new List<Logistics>(); currentLocation = new Logistics(); licenses = new List<License>(); warranties = new List<Warranty>(); transfer = new Transfer(); }
protected void btnAddPO_Click(object sender, EventArgs e) { PurchaseOrder PO = new PurchaseOrder(); PO.PONumber = txtBoxPoNo.Text; PO.DeliveryDate = txtBoxDeliveryDate.Text; PO.RequisitionNumber = txtBoxRequisitionNo.Text; PO.PurchaseDate = txtBoxPurchaseDate.Text; PO.Title = txtBoxTitle.Text; lblMessage.Text = PurchaseOrder.savePO(PO); btnClear.Visible = true; }
protected void btnEditPurchaseOrder_Click(object sender, EventArgs e) { DetailsView1.Visible = false; panelEditPurchaseOrder.Visible = true; btnEditPurchaseOrder.Visible = false; PurchaseOrder PO = new PurchaseOrder(); PO = PurchaseOrder.getPO(Session["CurrentPurchaseOrder"].ToString()); txtBoxDeliveryDate.Text = PO.DeliveryDate; txtBoxPONumber.Text = PO.PONumber; txtBoxPurchaseDate.Text = PO.PurchaseDate; txtBoxRequisitionNumber.Text = PO.RequisitionNumber; txtBoxTitle.Text = PO.Title; }
protected void btnUpdatePO_Click(object sender, EventArgs e) { PurchaseOrder newPO = new PurchaseOrder(); newPO.Title = txtBoxTitle.Text; newPO.PONumber = txtBoxPONumber.Text; newPO.DeliveryDate = txtBoxDeliveryDate.Text; newPO.PurchaseDate = txtBoxPurchaseDate.Text; newPO.RequisitionNumber = txtBoxRequisitionNumber.Text; lblMessage.Text = PurchaseOrder.updatePO(newPO, Convert.ToInt32(Session["CurrentPurchaseOrder"])); if (lblMessage.Text == "Purchase Order created successfully<bR>") { DetailsView1.Visible = true; panelEditPurchaseOrder.Visible = false; btnEditPurchaseOrder.Visible = true; DetailsView1.DataBind(); } else { lblMessage.Visible = true; } }
public static string updatePO(PurchaseOrder newPO, int oldPOid) { return PODA.updatePO(newPO, oldPOid); }
public static string savePO(PurchaseOrder po) { return PODA.savePO(po); }
public static PurchaseOrder getPO(string POID) { SqlConnection dbConn; string sConnection; SqlCommand dbCmd; SqlTransaction transaction; SqlDataReader dbReader; sConnection = GlobalVars.ConnectionString; dbConn = new SqlConnection(sConnection); dbConn.Open(); dbCmd = dbConn.CreateCommand(); transaction = dbConn.BeginTransaction("Transaction"); dbCmd.Transaction = transaction; try { string sql = "SELECT POID, POno, DeliveryDate, REquisitionNo, PurchaseDate, Title FROM PO WHERE POID = @POID"; dbCmd.CommandText = sql; dbCmd.Parameters.AddWithValue("POID", POID); dbReader = dbCmd.ExecuteReader(); PurchaseOrder PO = new PurchaseOrder(); while (dbReader.Read()) { PO.ID = Convert.ToInt32(dbReader["POID"]); PO.PONumber = dbReader["POno"].ToString(); PO.DeliveryDate = dbReader["DeliveryDate"].ToString(); PO.RequisitionNumber = dbReader["RequisitionNo"].ToString(); PO.PurchaseDate = dbReader["PurchaseDate"].ToString(); PO.Title = dbReader["Title"].ToString(); } dbReader.Close(); dbCmd.Parameters.Clear(); transaction.Commit(); dbConn.Close(); return PO; } catch (Exception ex) { Console.WriteLine(ex.ToString()); transaction.Rollback(); return null; } }
public static string updatePO(PurchaseOrder newPO, int oldPOid) { SqlConnection dbConn; string sConnection; SqlCommand dbCmd; SqlTransaction transaction; StringBuilder message = new StringBuilder(); sConnection = GlobalVars.ConnectionString; dbConn = new SqlConnection(sConnection); dbConn.Open(); dbCmd = dbConn.CreateCommand(); transaction = dbConn.BeginTransaction("Transaction"); dbCmd.Transaction = transaction; PurchaseOrder oldPO = PODA.getPO(dbCmd, oldPOid); if (newPO.PONumber == oldPO.PONumber || PODA.poExist(dbCmd, newPO.PONumber) == false) { try { String sqlCommand = "UPDATE PO SET " + "POno = @PONO, " + "DeliveryDate = @DeliveryDate, " + "RequisitionNo = @RequisitionNo, " + "PurchaseDate = @PurchaseDate, " + "Title = @Title " + "WHERE POno = @OldPONO"; dbCmd.CommandText = sqlCommand; dbCmd.Parameters.AddWithValue("PONO", newPO.PONumber); dbCmd.Parameters.AddWithValue("DeliveryDate", newPO.DeliveryDate); dbCmd.Parameters.AddWithValue("RequisitionNo", newPO.RequisitionNumber); dbCmd.Parameters.AddWithValue("PurchaseDate", newPO.PurchaseDate); dbCmd.Parameters.AddWithValue("Title", newPO.Title); dbCmd.Parameters.AddWithValue("OldPONO", oldPO.PONumber); dbCmd.ExecuteNonQuery(); dbCmd.Parameters.Clear(); transaction.Commit(); dbConn.Close(); message.Append("Purchase Order created successfully<bR>"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); message.Append(ex.ToString()); transaction.Rollback(); } return message.ToString(); } else { message.Append("That PO number already exists, choose another.<bR>"); return message.ToString(); } }
public static string savePO(PurchaseOrder PO) { SqlConnection dbConn; string sConnection; SqlCommand dbCmd; SqlTransaction transaction; StringBuilder message = new StringBuilder(); sConnection = GlobalVars.ConnectionString; dbConn = new SqlConnection(sConnection); dbConn.Open(); dbCmd = dbConn.CreateCommand(); transaction = dbConn.BeginTransaction("Transaction"); dbCmd.Transaction = transaction; if (PODA.poExist(dbCmd, PO.PONumber) == false) { try { String sqlCommand = "INSERT INTO PO (POno, DeliveryDate, RequisitionNo, PurchaseDate, Title) " + "VALUES (@POno, @DeliveryDate, @RequisitionNo, @PurchaseDate, @Title)"; dbCmd.CommandText = sqlCommand; dbCmd.Parameters.AddWithValue("POno", PO.PONumber); dbCmd.Parameters.AddWithValue("DeliveryDate", PO.DeliveryDate); dbCmd.Parameters.AddWithValue("RequisitionNo", PO.RequisitionNumber); dbCmd.Parameters.AddWithValue("PurchaseDate", PO.PurchaseDate); dbCmd.Parameters.AddWithValue("Title", PO.Title); dbCmd.ExecuteNonQuery(); transaction.Commit(); dbCmd.Parameters.Clear(); dbConn.Close(); message.Append("Purchase Order created successfully<bR>"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); message.Append(ex.ToString()); } return message.ToString(); } else { message.Append("That PO number already exists, choose another.<bR>"); return message.ToString(); } }
public static int getPOID(SqlCommand cmd, string PONo) { SqlDataReader dbReader; string sql = "SELECT POID FROM PO WHERE POno = @POno"; cmd.CommandText = sql; cmd.Parameters.AddWithValue("POno", PONo); dbReader = cmd.ExecuteReader(); PurchaseOrder PO = new PurchaseOrder(); int POID = 0; while (dbReader.Read()) { POID = Convert.ToInt32(dbReader["POID"]); } dbReader.Close(); cmd.Parameters.Clear(); return POID; }
public static PurchaseOrder getPODetails(SqlCommand cmd, int invID) { SqlDataReader dbReader; string sql; sql = "SELECT PO.POID, POno, DeliveryDate, RequisitionNo, PurchaseDate, Title FROM PO, POInventory WHERE PO.POID = POInventory.POID and POInventory.InvID = @InvID"; cmd.CommandText = sql; cmd.Parameters.AddWithValue("InvID", invID); dbReader = cmd.ExecuteReader(); PurchaseOrder PO = new PurchaseOrder(); while (dbReader.Read()) { PO.ID = Convert.ToInt32(dbReader["POID"]); PO.PONumber = dbReader["POno"].ToString(); PO.DeliveryDate = dbReader["DeliveryDate"].ToString(); PO.RequisitionNumber = dbReader["RequisitionNo"].ToString(); PO.PurchaseDate = dbReader["PurchaseDate"].ToString(); PO.Title = dbReader["Title"].ToString(); } dbReader.Close(); cmd.Parameters.Clear(); return PO; }