private void btnUpdate_Click(object sender, EventArgs e) { //Database Connection Classes.DataAccess.SalesDataAccess db = new Classes.DataAccess.SalesDataAccess(); //To hold all the information Classes.DatabaseTables.ActiveQuotes updateQuote = new Classes.DatabaseTables.ActiveQuotes(); //Fill updateQuote updateQuote.QuoteWOR = Int32.Parse(txtWOR.Text); updateQuote.Date = tempDate; updateQuote.Time = tempTime; updateQuote.PartID = txtPartID.Text; updateQuote.Customer = txtCustomer.Text; updateQuote.PartDescription = txtDescription.Text; if (radioLowConf.Checked) { updateQuote.QuoteConfidence = "Low"; } if (radioMedConf.Checked) { updateQuote.QuoteConfidence = "Medium"; } if (radioHighConf.Checked) { updateQuote.QuoteConfidence = "High"; } updateQuote.QuoteComments = txtComment.Text; updateQuote.QuoteDueDate = dtDueDate.Text; if (ckConsigned.Checked == true) { updateQuote.Consigned = 1; } else { updateQuote.Consigned = 0; } if (ckTurnkey.Checked == true) { updateQuote.Turnkey = 1; } else { updateQuote.Turnkey = 0; } db.UpdateQuote(updateQuote); btnClear_Click(null, null); }
//Update Data--------------------------------------------------------------------------------------------------------------- public void UpdateQuote(Classes.DatabaseTables.ActiveQuotes updateQuote) { using (System.Data.IDbConnection connection = new System.Data.SqlClient.SqlConnection(Classes.Helper.CnnVal("TracerDB"))) { List <DatabaseTables.ActiveQuotes> activeQuote = new List <DatabaseTables.ActiveQuotes>(); activeQuote.Add(updateQuote); connection.Execute($"UPDATE ActiveQuotes SET Date=@Date, Time=@Time, PartID=@PartID, Customer=@Customer, PartDescription=@PartDescription, QuoteConfidence=@QuoteConfidence, Consigned=@Consigned, Turnkey=@Turnkey, QuoteComments=@QuoteComments, QuoteDueDate=@QuoteDueDate WHERE QuoteWOR=@QuoteWOR", activeQuote); } }
//Insert Data--------------------------------------------------------------------------------------------------------------- public void InsertNewQuote(Classes.DatabaseTables.ActiveQuotes newActiveQuote, Classes.DatabaseTables.QuoteStatus newQuoteStatus) { using (System.Data.IDbConnection connection = new System.Data.SqlClient.SqlConnection(Classes.Helper.CnnVal("TracerDB"))) { //Add new ActiveQuotes and QuoteStatus List <DatabaseTables.ActiveQuotes> activeQuote = new List <DatabaseTables.ActiveQuotes>(); List <DatabaseTables.QuoteStatus> quoteStatus = new List <DatabaseTables.QuoteStatus>(); activeQuote.Add(newActiveQuote); quoteStatus.Add(newQuoteStatus); connection.Execute($"insert into ActiveQuotes(QuoteWOR, Date, Time, PartID, Customer, PartDescription, QuoteConfidence, Consigned, Turnkey, QuoteComments, QuoteDueDate, QuoteInactive, POReceived) values(@QuoteWOR, @Date, @Time, @PartID, @Customer, @PartDescription, @QuoteConfidence, @Consigned, @Turnkey, @QuoteComments, @QuoteDueDate, @QuoteInactive, @POReceived)", activeQuote); connection.Execute($"insert into QuoteStatus(QuoteWOR, BOMValidationRequest, BOMValidationInProgress, BOMValidationComplete, PartsReviewRequest, PartsReviewInProgress, PartsReviewComplete, PreBidRequest, PreBidInProgress, PreBidComplete, FinalReviewRequest, FinalReviewInProgress, FinalReviewComplete, QuoteSent, QuoteCurrentStatus) values(@QuoteWOR, @BOMValidationRequest, @BOMValidationInProgress, @BOMValidationComplete, @PartsReviewRequest, @PartsReviewInProgress, @PartsReviewComplete, @PreBidRequest, @PreBidInProgress, @PreBidComplete, @FinalReviewRequest, @FinalReviewInProgress, @FinalReviewComplete, @QuoteSent, @QuoteCurrentStatus)", quoteStatus); } }
private void createWOR() { //Set Up holder to update the Active Quote PO Status Classes.DatabaseTables.ActiveQuotes activeQuote = new Classes.DatabaseTables.ActiveQuotes(); //Set Up Holder for the new WOR Classes.DatabaseTables.WorkOrders newWOR = new Classes.DatabaseTables.WorkOrders(); DateTime rightNow = new DateTime(); rightNow = DateTime.Now; newWOR.JobWOR = Int32.Parse(SelectedWorkOrder); newWOR.Date = rightNow.ToString("MM-dd-yyyy"); newWOR.Time = rightNow.ToString("hh:mm:ss tt"); newWOR.PurchaseOrderNumber = txtPONumber.Text; newWOR.WorkOrderComplete = 0; //Create Data Access Class Classes.DataAccess.SalesDataAccess db = new Classes.DataAccess.SalesDataAccess(); db.InsterWorkOrder(newWOR); }
//Physical Button Events-------------------------------------------------------------- private void btnAdd_Click(object sender, EventArgs e) { Classes.DataAccess.SalesDataAccess db = new Classes.DataAccess.SalesDataAccess(); //Holder to validate the Data //Create new class to hold the new Active Quote Classes.DatabaseTables.ActiveQuotes newActiveQuote = new Classes.DatabaseTables.ActiveQuotes(); Classes.DatabaseTables.QuoteStatus newQuoteStatus = new Classes.DatabaseTables.QuoteStatus(); //Fill New Active Quote newActiveQuote.QuoteWOR = Int32.Parse(txtWOR.Text); DateTime rightNow = new DateTime(); rightNow = DateTime.Now; newActiveQuote.Date = rightNow.ToString("MM-dd-yyyy"); newActiveQuote.Time = rightNow.ToString("hh:mm:ss tt"); newActiveQuote.PartID = txtPartID.Text; newActiveQuote.Customer = txtCustomer.Text; newActiveQuote.PartDescription = txtDescription.Text; if (radioLowConf.Checked) { newActiveQuote.QuoteConfidence = "Low"; } if (radioMedConf.Checked) { newActiveQuote.QuoteConfidence = "Medium"; } if (radioHighConf.Checked) { newActiveQuote.QuoteConfidence = "High"; } newActiveQuote.QuoteComments = txtComment.Text; newActiveQuote.QuoteDueDate = dtDueDate.Text; if (ckConsigned.Checked == true) { newActiveQuote.Consigned = 1; } else { newActiveQuote.Consigned = 0; } if (ckTurnkey.Checked == true) { newActiveQuote.Turnkey = 1; } else { newActiveQuote.Turnkey = 0; } //Set Initial Status newActiveQuote.QuoteInactive = 0; newActiveQuote.POReceived = 0; //QuoteStatus Initialization newQuoteStatus.QuoteWOR = Int32.Parse(txtWOR.Text); newQuoteStatus.BOMValidationRequest = 0; newQuoteStatus.BOMValidationInProgress = 0; newQuoteStatus.BOMValidationComplete = 0; newQuoteStatus.PartsReviewRequest = 0; newQuoteStatus.PartsReviewInProgress = 0; newQuoteStatus.PartsReviewComplete = 0; newQuoteStatus.PreBidRequest = 0; newQuoteStatus.PreBidInProgress = 0; newQuoteStatus.PreBidComplete = 0; newQuoteStatus.FinalReviewRequest = 0; newQuoteStatus.FinalReviewInProgress = 0; newQuoteStatus.FinalReviewComplete = 0; newQuoteStatus.QuoteSent = 0; newQuoteStatus.QuoteCurrentStatus = ""; db.InsertNewQuote(newActiveQuote, newQuoteStatus); btnClear_Click(null, null); }