private void frmSYSNoMaster_Load(object sender, EventArgs e) { try { if (GlobalVariables.ClasificationMaster == null) { DataSet dsClafMaster = ReactionCurationDB.GetSysNoClassificationMasterDetails(); if (dsClafMaster != null) { if (dsClafMaster.Tables.Count == 2) { GlobalVariables.ClasificationMaster = dsClafMaster.Tables[0]; GlobalVariables.SysNoClasifications = dsClafMaster.Tables[1]; } } } if (GlobalVariables.ClasificationMaster != null) { BindClasificationsToGrid(GlobalVariables.ClasificationMaster); } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
private static FullArticleInfo GetFullArticleDetailsOnShipmentRefID(int shipmentRefID) { FullArticleInfo objFullArtInfo = null; try { if (shipmentRefID > 0) { objFullArtInfo = new FullArticleInfo(); objFullArtInfo.ShipmentRefID = shipmentRefID; DataTable dtArticleInfo = ReactionCurationDB.SaveFullArticleInfo(objFullArtInfo); if (dtArticleInfo != null && dtArticleInfo.Rows.Count > 0) { objFullArtInfo.ArticleType = dtArticleInfo.Rows[0]["REFERENCE_TYPE"].ToString(); objFullArtInfo.JournalDOI = dtArticleInfo.Rows[0]["DOI"].ToString(); objFullArtInfo.JournalName = dtArticleInfo.Rows[0]["JOURNAL_NAME"].ToString(); objFullArtInfo.JournalRefNo = dtArticleInfo.Rows[0]["REFERENCE_NAME"].ToString(); objFullArtInfo.JournalVolume = dtArticleInfo.Rows[0]["VOLUME"].ToString(); int journalYear = 0; int.TryParse(dtArticleInfo.Rows[0]["JOURNAL_YEAR"].ToString(), out journalYear); objFullArtInfo.JournalYear = journalYear; objFullArtInfo.JournalStartPage = dtArticleInfo.Rows[0]["START_PAGE"].ToString(); objFullArtInfo.JournalEndPage = dtArticleInfo.Rows[0]["END_PAGE"].ToString(); } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(objFullArtInfo); }
private void btnAddCondition_Click(object sender, EventArgs e) { try { FrmEditConditions frmEditCondition = new FrmEditConditions(); if (frmEditCondition.ShowDialog() == DialogResult.OK) { DataTable dtConditions = new DataTable(); ConditionInfo objCond = frmEditCondition.condInfo; objCond.ReactionID = ReactionID; objCond.RxnStepID = StepID; objCond.StepNo = SerialNo; objCond.Option = objCond.ConditionID == 0 ? DmlOperations.INSERT.ToString() : DmlOperations.UPDATE.ToString(); if (ReactionCurationDB.SaveReactionConditions(objCond, out dtConditions)) { MessageBox.Show("Condition saved successfully.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error accured in condition updation.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } BindDataToConditionsGrid(dtConditions); } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
private void btnAddParticipant_Click(object sender, EventArgs e) { try { FrmEditParticipants frmEditPartpnt = new FrmEditParticipants(); if (frmEditPartpnt.ShowDialog() == DialogResult.OK) { ParticipantInfo objPartpnt = frmEditPartpnt.PaticipantData; objPartpnt.ReactionID = ReactionID; objPartpnt.RxnStepID = StepID; objPartpnt.StepNo = SerialNo == 0 ? 1 : SerialNo; objPartpnt.Option = objPartpnt.ParticipantID > 0 ? DmlOperations.UPDATE.ToString() : DmlOperations.INSERT.ToString(); DataTable dtPartpnt = new DataTable(); if (ReactionCurationDB.SaveReactionParticipants(objPartpnt, out dtPartpnt)) { MessageBox.Show("Participant updated successfully.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); BindDataToParticipantsGrid(dtPartpnt); } else { MessageBox.Show("Error accured in participant updation.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
public bool ExportReferenceDataToPdf(int shipmentRefID, string outFilePath) { bool blStatus = false; try { if (shipmentRefID > 0) { DataTable dtRxnRefs = null; DataTable dtCrossRefs = null; DataSet dsRxn_CrossRefs = ReactionCurationDB.GetRxnAndCrossReferencesOnShipmentRefID(shipmentRefID); if (dsRxn_CrossRefs != null) { if (dsRxn_CrossRefs.Tables.Count == 2) { dtCrossRefs = dsRxn_CrossRefs.Tables[0]; dtRxnRefs = dsRxn_CrossRefs.Tables[1]; } } DataSet dsRxns = ReactionCurationDB.GetReactionsForExportOnDocID(shipmentRefID); if (dsRxns != null) { if (dsRxns.Tables.Count == 8) { DataTable dtDocMaster = dsRxns.Tables[0]; DataTable dtReactions = dsRxns.Tables[1]; //DataTable dtRxnRefs = dsRxns.Tables[2]; //DataTable dtCrossRefs = dsRxns.Tables[3]; DataTable dtRxnSteps = dsRxns.Tables[4]; DataTable dtConditions = dsRxns.Tables[5]; DataTable dtParticipants = dsRxns.Tables[6]; DataTable dtProducts = dsRxns.Tables[7]; string rxnsRefNo = dtDocMaster.Rows[0]["REFERENCE_NAME"].ToString(); string sysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); string sysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); string outFileName = outFilePath;// Path.Combine(outFilePath, rxnsRefNo + ".pdf"); List <ReactionInfo> lstRxnInfo = new List <ReactionInfo>(); int reactionID = 0; //Unique ID for reaction (serial number); format: RXCInnnnnnnn;n=numerical range for backfiles is 70000001...89999999. int mdlNo = 70000000; foreach (DataRow drow in dtReactions.Rows) { //increment MDL Numer mdlNo++; reactionID = Convert.ToInt32(drow["REACTION_ID"]); ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = shipmentRefID; rxnInfo.ReactionID = reactionID; rxnInfo.SysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); rxnInfo.SysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); rxnInfo.RxnMDLNo = "RXCI" + mdlNo; rxnInfo.ReactionScheme = drow["REACTION_SCHEME"]; rxnInfo.ReactionSNo = Convert.ToInt32(drow["REACTION_SNO"]); rxnInfo.RxnRef = GetRxnRefInfoFromTableOnReactionID(dtRxnRefs, reactionID); rxnInfo.RxnCrossRef = GetCrossRefInfoFromTableOnReactionID(dtCrossRefs, reactionID); DataTable dtRxnStages = GetStepsOnReactionID(dtRxnSteps, reactionID); DataTable participantsData = GetParticipantsForProdFormation(dtParticipants, dtConditions, dtRxnStages); rxnInfo.ParticipantsForPdf = participantsData;// GetReactionStepsInfoFromTableOnReactionID(dtRxnSteps, dtParticipants, dtConditions, reactionID); //Add to list lstRxnInfo.Add(rxnInfo); } if (lstRxnInfo != null) { if (dtReactions.Rows.Count > 0) { using (iTextSharp.text.Document doc = new iTextSharp.text.Document()) { iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new System.IO.FileStream(outFileName, FileMode.Create)); doc.Open(); //Declare Reaction Participants tables #region MyRegion DataTable dtProdTbl = null; DataTable dtReactantTbl = null; DataTable dtPartpntTbl = null; DataTable dtCondsTbl = null; DataTable dtStagesTbl = null; #endregion iTextSharp.text.Image chemimg = null; iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 10f); //Define variables #region MyRegion int intProdCnt = 0; int intReactCnt = 0; string strRxnHdr = ""; PdfPTable PdfTable = null; PdfPCell rxnCell = null; #endregion //Define font style #region MyRegion styles = new StyleSheet(); styles.LoadTagStyle("th", "size", "8px"); styles.LoadTagStyle("th", "face", "helvetica"); styles.LoadTagStyle("span", "size", "7px"); styles.LoadTagStyle("span", "face", "helvetica"); styles.LoadTagStyle("td", "size", "7px"); styles.LoadTagStyle("td", "face", "helvetica"); #endregion PdfPTable pTRxnRef = null; PdfPTable pTCrossRef = null; PdfPCell pcRxnRef = null; PdfPCell pcCrossRef = null; //Add Pdf Header to document PdfPTable ptHeader = GetPdfHeaderTable(rxnsRefNo, sysNo); doc.Add(ptHeader); //Define Participants elements List <IElement> lstPartpnt = null; foreach (ReactionInfo rxnInfo in lstRxnInfo) { //Create instance of the pdf table and set the number of column in that table PdfTable = new PdfPTable(1); PdfTable.SpacingAfter = 4f; PdfTable.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right PdfTable.TotalWidth = 800f; // doc.PageSize.Width; PdfTable.WidthPercentage = 100; //Add Reaction Header to Pdf Table strRxnHdr = "Reaction - " + rxnInfo.ReactionSNo.ToString(); rxnCell = new PdfPCell(new Phrase(strRxnHdr, fontTinyItalic)); rxnCell.Colspan = intProdCnt + intReactCnt; rxnCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;// 0; //0=Left, 1=Centre, 2=Right rxnCell.VerticalAlignment = PdfPCell.ALIGN_TOP; rxnCell.BackgroundColor = bgcolRxnNo; PdfTable.AddCell(rxnCell); //Reaction Reference Info pTRxnRef = GetReactionReferecneTable(rxnInfo); if (pTRxnRef != null) { pcRxnRef = new PdfPCell(pTRxnRef); pcRxnRef.Border = PdfPCell.NO_BORDER; //pcRxnRef.BackgroundColor = bgcolRctNumStage; PdfTable.AddCell(pcRxnRef); } //Cross Reference Info pTCrossRef = GetCrossReferecneTable(rxnInfo); if (pTCrossRef != null) { pcCrossRef = new PdfPCell(pTCrossRef); pcCrossRef.Border = PdfPCell.NO_BORDER; //pcRxnRef.BackgroundColor = bgcolRctNumStage; PdfTable.AddCell(pcCrossRef); } if (rxnInfo.ReactionScheme != null) { System.Drawing.Image img = GetStructureImage(rxnInfo.ReactionScheme.ToString()); chemimg = iTextSharp.text.Image.GetInstance(img as System.Drawing.Image, System.Drawing.Imaging.ImageFormat.Jpeg); if (chemimg != null) { chemimg.ScaleToFit(450f, 150f); //chemimg.ScaleAbsolute((float)600f, (float)250f); chemimg.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_CENTER; //pdfCell = new PdfPCell(chemimg, true); } else { //pdfCell = new PdfPCell(new Phrase("Structure generation error", fontTinyItalic)); } PdfTable.AddCell(chemimg); } //Product Yield, CS, DS and Other information //Get Participatns text from RichTextBox object string strRtf = GetPartpntsDataBindToRichTextBox(rxnInfo.ParticipantsForPdf); //Get Participants elements from RichTextBox Rtf and convert to HTML lstPartpnt = HTMLWorker.ParseToList(new StringReader(markupConverter.ConvertRtfToHtml(strRtf)), styles); //Add Participants string in a row cell to Pdf Table PdfPCell pcPartpnt = new PdfPCell(); foreach (IElement iEle in lstPartpnt) { pcPartpnt.AddElement(iEle); } pcPartpnt.Colspan = 1;// intProdCnt + intReactCnt; //pcPartpnt.BackgroundColor = bgcolRxnPartpnt; pcPartpnt.VerticalAlignment = Element.ALIGN_TOP; pcPartpnt.HorizontalAlignment = 0;// Element.ALIGN_LEFT; //0=Left, 1=Centre, 2=Right PdfTable.AddCell(pcPartpnt); doc.Add(PdfTable); } doc.Close(); blStatus = true; } } } } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } return(blStatus); }
public static DataTable ValidateSchemeProductsAndReactantsChain(DataTable crossRefsData) { DataTable dtRxnChainValidStatus = null; try { if (crossRefsData != null) { //Get Unique Path Nos var distPathNos = (from DataRow dRow in crossRefsData.Rows select new { pathNo = dRow["EXT_REG_NO"] }).Distinct(); //Get Unique PathNames var distPathNames = (from DataRow dRow in crossRefsData.Rows select new { PathName = dRow["PATH_LETTER"] }).Distinct(); DataTable dtRxnChain = null; foreach (var pNo in distPathNos) { foreach (var pName in distPathNames) { DataView dvTemp = crossRefsData.Copy().DefaultView; dvTemp.RowFilter = "EXT_REG_NO = " + pNo.pathNo + " and PATH_LETTER = '" + pName.PathName.ToString() + "'"; dtRxnChain = dvTemp.ToTable(); ////Get ReactionChain table on pathNo and pathName //dtRxnChain = (from DataRow dr in crossRefsData.Rows // where dr["EXT_REG_NO"] == pNo.pathNo && dr["PATH_LETTER"] == pName.PathName.ToString() // select dr).CopyToDataTable(); //EnumerableRowCollection<DataRow> query = from order in crossRefsData.AsEnumerable() // where order.Field<Decimal>("EXT_REG_NO") =pNo.pathNo && order.Field<string>("PATH_LETTER") = pName.PathName.ToString() // select order; //dtRxnChain = query.AsDataView().ToTable(); if (dtRxnChain != null) { dtRxnChain.Columns.Add("STATUS", typeof(string)); if (dtRxnChainValidStatus == null) { dtRxnChainValidStatus = dtRxnChain.Clone(); } if (dtRxnChain.Rows.Count > 1) { for (int i = 1; i < dtRxnChain.Rows.Count; i++) { //Get Product of first row DataTable productData = ReactionCurationDB.GetReactionDataOnReactionID(Convert.ToInt32(dtRxnChain.Rows[i - 1]["REACTION_ID"])); //Get Reactants of second row DataTable reactantData = ReactionCurationDB.GetReactionDataOnReactionID(Convert.ToInt32(dtRxnChain.Rows[i]["REACTION_ID"])); if (CompareProductsAndReactantsInTables(productData, reactantData)) { dtRxnChain.Rows[i - 1]["STATUS"] = dtRxnChain.Rows[i]["STATUS"].ToString() != "Valid" ? "Valid" : dtRxnChain.Rows[i]["STATUS"].ToString(); dtRxnChain.Rows[i]["STATUS"] = dtRxnChain.Rows[i]["STATUS"].ToString() != "Valid" ? "Valid" : dtRxnChain.Rows[i]["STATUS"].ToString(); } else { dtRxnChain.Rows[i - 1]["STATUS"] = dtRxnChain.Rows[i]["STATUS"].ToString() != "Valid" ? "Valid" : dtRxnChain.Rows[i]["STATUS"].ToString(); dtRxnChain.Rows[i]["STATUS"] = "In-Valid"; } } //Import Rows to new table if (dtRxnChain.Rows.Count > 0) { if (dtRxnChainValidStatus == null) { dtRxnChainValidStatus = dtRxnChain.Clone(); } foreach (DataRow dr in dtRxnChain.Rows) { DataRow drNew = dtRxnChainValidStatus.NewRow(); drNew.ItemArray = dr.ItemArray; dtRxnChainValidStatus.Rows.Add(drNew); } } } } } } #region MyRegion //foreach pathNo in Unique Paths //{ //foreach pathName in unique PathNames //{ //Get ReactionChain table on pathNo and pathName //foreach row in ReactionChain //{ //Get Product of first row //Get Reactants of second row //Compare Product with reactant //If matching, set second row as valid else invalid //} //} //} #endregion } } catch (Exception) { throw; } return(dtRxnChainValidStatus); }
/// <summary> /// Export Reactions for client delivery /// </summary> /// <param name="RefIDsList"></param> /// <param name="shipmentYear"></param> /// <param name="outputPath"></param> /// <param name="mdlStartNo"></param> /// <param name="deliveryDtls"></param> /// <param name="delivSovCats"></param> /// <returns></returns> public static bool ExportReactionsForClientDelivery(List <int> RefIDsList, string shipmentYear, string outputPath, int mdlStartNo, out Delivery deliveryDtls, out List <DeliverySolvCats> delivSovCatsList) { bool blStatus = false; Delivery objDelivery = null; List <DeliverySolvCats> lstDeliverySovCats = null; try { int mdlNo = mdlStartNo;//70000000; List <string> lstUniqSolvInchi = new List <string>(); //Define Delivery class objDelivery = new Delivery(); objDelivery.DeliveryDate = DateTime.Now; objDelivery.MDLStartNo = mdlStartNo; objDelivery.DeliveryRefCount = RefIDsList.Count; List <int> lstDelRefs = new List <int>(); List <int> lstDelRefMDLStNo = new List <int>(); List <int> lstDelRefMDLEndNo = new List <int>(); int deliveredRxnCnt = 0; lstDeliverySovCats = new List <DeliverySolvCats>(); foreach (int shipRefID in RefIDsList) { DataSet dsRxns = ReactionCurationDB.GetReactionsForExportOnDocID(shipRefID); DataTable dtRxnRefs = null; DataTable dtCrossRefs = null; //Automated Export DataSet dsRxn_CrossRefs = ReactionCurationDB.GetRxnAndCrossReferencesOnShipmentRefID(shipRefID); if (dsRxn_CrossRefs != null) { if (dsRxn_CrossRefs.Tables.Count == 2) { dtCrossRefs = dsRxn_CrossRefs.Tables[0]; dtRxnRefs = dsRxn_CrossRefs.Tables[1]; } } if (dsRxns != null) { if (dsRxns.Tables.Count == 8) { DataTable dtDocMaster = dsRxns.Tables[0]; DataTable dtReactions = dsRxns.Tables[1]; //Manual Export //DataTable dtRxnRefs = dsRxns.Tables[2]; //DataTable dtCrossRefs = dsRxns.Tables[3]; DataTable dtRxnSteps = dsRxns.Tables[4]; DataTable dtConditions = dsRxns.Tables[5]; DataTable dtParticipants = dsRxns.Tables[6]; DataTable dtProducts = dsRxns.Tables[7]; // FullArticleInfo articleInfo = GetArticleInfoFromTable(dtDocMaster); FullArticleInfo articleInfo = GetFullArticleDetailsOnShipmentRefID(Convert.ToInt32(dtDocMaster.Rows[0]["SHIPMENT_REF_ID"].ToString())); string shipementRefName = dtDocMaster.Rows[0]["REFERENCE_NAME"].ToString(); List <ReactionInfo> lstRxnInfo = new List <ReactionInfo>(); int reactionID = 0; //Add Reference Name and MDL Start No lstDelRefs.Add(shipRefID); lstDelRefMDLStNo.Add(mdlNo); //Unique ID for reaction (serial number); format: RXCInnnnnnnn;n=numerical range for backfiles is 70000001...89999999. //Feedback on 28th Oct 2014 //General: Please assign MDLnumbers according to the year, i.e. issues from 1981 should have MDLnumbers RXCI81nnnnnn, to avoid duplicates foreach (DataRow drow in dtReactions.Rows) { reactionID = Convert.ToInt32(drow["REACTION_ID"]); ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = shipRefID; rxnInfo.ReactionID = reactionID; rxnInfo.SysNo = dtDocMaster.Rows[0]["SYS_NO"].ToString(); rxnInfo.SysText = dtDocMaster.Rows[0]["SYS_TEXT"].ToString(); rxnInfo.RxnMDLNo = "RXCI" + shipmentYear + mdlNo.ToString("000000");//RXCI81nnnnnn rxnInfo.ReactionScheme = drow["REACTION_SCHEME"]; rxnInfo.ReactionSNo = Convert.ToInt32(drow["REACTION_SNO"]); rxnInfo.RxnComments = drow["RXN_COMMENTS"].ToString(); rxnInfo.RxnRef = GetRxnRefInfoFromTableOnReactionID(dtRxnRefs, reactionID); rxnInfo.RxnCrossRef = GetCrossRefInfoFromTableOnReactionID(dtCrossRefs, reactionID); rxnInfo.RxnProducts = GetProductsFromTableOnReactionID(dtProducts, reactionID); rxnInfo.RxnSteps = GetStepsInfoFromTableOnReactionID(dtRxnSteps, dtParticipants, dtConditions, reactionID); //Add to list lstRxnInfo.Add(rxnInfo); //increment MDL Numer mdlNo++; //Count delivery Rxns deliveredRxnCnt++; } //Add Reference MDL End No lstDelRefMDLEndNo.Add(mdlNo); if (lstRxnInfo != null) { DeliverySolvCats refSovCats = new DeliverySolvCats(); if (ReactionExport.ExportToRDFile(lstRxnInfo, articleInfo, shipementRefName, outputPath, ref lstUniqSolvInchi, ref refSovCats)) { blStatus = true; if (refSovCats.RefNewSolvents != null) { refSovCats.ShipmentRefID = shipRefID; //Add Refs and SolvCats to List lstDeliverySovCats.Add(refSovCats); } } } } } } //Delivery references and Mdl Nos objDelivery.DeliveryRefsList = lstDelRefs; objDelivery.RefMdlStartNoList = lstDelRefMDLStNo; objDelivery.RefMdlEndNoList = lstDelRefMDLEndNo; objDelivery.DeliveryRxnCount = deliveredRxnCnt; objDelivery.MDLEndNo = (mdlStartNo + deliveredRxnCnt) - 1; } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } deliveryDtls = objDelivery; delivSovCatsList = lstDeliverySovCats; return(blStatus); }
private void btnCreateRxn_Click(object sender, EventArgs e) { try { DataTable dtReactions = null; int newRxnSNo = 0; if (cmbRxnNo.SelectedItem != null) { int selRxnNo = Convert.ToInt32(cmbRxnNo.Text); newRxnSNo = rbnAfter.Checked ? selRxnNo + 1 : selRxnNo; } else if (ReactionsTbl.Rows.Count == 0) { newRxnSNo = 1; } if (!chkDuplicateWithRxn.Checked)//New Reaction { ReactionInfo rxnInfo = new ReactionInfo(); rxnInfo.ShipmentRefID = ShipmentRefID; rxnInfo.ReactionSNo = newRxnSNo; rxnInfo.UR_ID = GlobalVariables.UR_ID; if (ReactionCurationDB.SaveReactionInfo(DmlOperations.INSERT, rxnInfo, out dtReactions)) { ReactionsTbl = dtReactions; DialogResult = System.Windows.Forms.DialogResult.OK; var query = from r in dtReactions.AsEnumerable() where r.Field <Int64>("REACTION_SNO") == newRxnSNo select new { NewRxn_Id = r["REACTION_ID"] }; if (query != null) { NewRxnID = Convert.ToInt32(query.ElementAt(0).NewRxn_Id); NewRxnSNo = newRxnSNo; } DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Error in adding new reaction", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //Duplicate Reaction { DialogResult diaRes = MessageBox.Show("Do you want to duplicate the reaction?", GlobalVariables.MessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (diaRes == System.Windows.Forms.DialogResult.Yes) { int dupRxnID = cmbDuplicateWithRxn.SelectedItem != null?Convert.ToInt32(cmbDuplicateWithRxn.SelectedValue) : 0; int newRxnID = ReactionCurationDB.DuplicateReactionData(ShipmentRefID, dupRxnID, newRxnSNo, GlobalVariables.UR_ID); if (newRxnID > 0) { NewRxnID = newRxnID; NewRxnSNo = newRxnSNo; DuplicateRxn = true; DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Error in duplicating reaction", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
private void dgvParticipants_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { ParticipantInfo objPartpnt = new ParticipantInfo(); DataTable dtPartpnt = new DataTable(); if (dgvParticipants.Columns[e.ColumnIndex].HeaderText.ToString().ToUpper() == "EDIT") { using (FrmEditParticipants fParticipants = new FrmEditParticipants()) { editRowIndxPartpnt = e.RowIndex; blEditPartpnt = true; objPartpnt.ReactionID = ReactionID; objPartpnt.StepNo = SerialNo; objPartpnt.RxnStepID = StepID; objPartpnt.ParticipantID = Convert.ToInt32(dgvParticipants.Rows[e.RowIndex].Cells[colParticipantID.Name].Value); objPartpnt.ParticipantName = dgvParticipants.Rows[e.RowIndex].Cells[colParticipantName.Name].Value != null ? dgvParticipants.Rows[e.RowIndex].Cells[colParticipantName.Name].Value.ToString() : ""; objPartpnt.StructureNo = dgvParticipants.Rows[e.RowIndex].Cells[colParticipantStructNo.Name].Value.ToString(); objPartpnt.Structure = dgvParticipants.Rows[e.RowIndex].Cells[colParticipantStructure.Name].Value != null ? dgvParticipants.Rows[e.RowIndex].Cells[colParticipantStructure.Name].Value.ToString() : ""; objPartpnt.Grade = dgvParticipants.Rows[e.RowIndex].Cells[colParticipantGrade.Name].Value != null ? dgvParticipants.Rows[e.RowIndex].Cells[colParticipantGrade.Name].Value.ToString() : ""; objPartpnt.ParticipantType = dgvParticipants.Rows[e.RowIndex].Cells[colParticipantType.Name].Value.ToString(); fParticipants.PaticipantData = objPartpnt; if (fParticipants.ShowDialog() == DialogResult.OK) { objPartpnt = fParticipants.PaticipantData; objPartpnt.RxnStepID = StepID; objPartpnt.StepNo = SerialNo; objPartpnt.ReactionID = ReactionID; objPartpnt.ParticipantID = Convert.ToInt32(dgvParticipants.Rows[e.RowIndex].Cells[colParticipantID.Name].Value); objPartpnt.Option = objPartpnt.ParticipantID > 0 ? DmlOperations.UPDATE.ToString() : DmlOperations.INSERT.ToString(); if (ReactionCurationDB.SaveReactionParticipants(objPartpnt, out dtPartpnt)) { MessageBox.Show("Participant updated successfully", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); BindDataToParticipantsGrid(dtPartpnt); } else { MessageBox.Show("Error in participant update.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else if (dgvParticipants.Columns[e.ColumnIndex].HeaderText.ToString().ToUpper() == "DELETE") { if (MessageBox.Show("Do you want to delete the selected participant?", GlobalVariables.MessageCaption, MessageBoxButtons.YesNo) == DialogResult.Yes) { objPartpnt.ReactionID = ReactionID; objPartpnt.ParticipantID = Convert.ToInt32(dgvParticipants.Rows[e.RowIndex].Cells[colParticipantID.Name].Value); objPartpnt.Option = DmlOperations.DELETE.ToString(); if (ReactionCurationDB.SaveReactionParticipants(objPartpnt, out dtPartpnt)) { MessageBox.Show("Participant deleted successfully", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); BindDataToParticipantsGrid(dtPartpnt); } else { MessageBox.Show("Error in participant delete.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }
private void dgvConditions_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { DataTable dtConditions = new DataTable(); ConditionInfo condInfo = new ConditionInfo(); condInfo.ReactionID = ReactionID; condInfo.RxnStepID = StepID; condInfo.StepNo = SerialNo; if (dgvConditions.Columns[e.ColumnIndex].HeaderText.ToString().ToUpper() == "EDIT") { using (FrmEditConditions fConditions = new FrmEditConditions()) { editRowIndxCond = e.RowIndex; blEditCond = true; condInfo.ConditionID = Convert.ToInt32(dgvConditions.Rows[e.RowIndex].Cells[colConditionID.Name].Value); condInfo.Time = dgvConditions.Rows[e.RowIndex].Cells[colConditionTime.Name].Value.ToString(); condInfo.TimeUnits = dgvConditions.Rows[e.RowIndex].Cells[colTimeUnits.Name].Value.ToString(); condInfo.Temperature = dgvConditions.Rows[e.RowIndex].Cells[colConditionTemp.Name].Value.ToString(); condInfo.TempUnits = dgvConditions.Rows[e.RowIndex].Cells[colTempUnits.Name].Value.ToString(); condInfo.Pressure = dgvConditions.Rows[e.RowIndex].Cells[colConditionPressure.Name].Value.ToString(); condInfo.PressureUnits = dgvConditions.Rows[e.RowIndex].Cells[colPressureUnits.Name].Value.ToString(); condInfo.PH = dgvConditions.Rows[e.RowIndex].Cells[colConditionPh.Name].Value.ToString(); condInfo.WarmUp = dgvConditions.Rows[e.RowIndex].Cells[colConditionWarmUp.Name].Value.ToString().ToUpper() == "Y" ? true : false; condInfo.CoolDown = dgvConditions.Rows[e.RowIndex].Cells[colConditionCoolDown.Name].Value.ToString().ToUpper() == "Y" ? true : false; condInfo.Reflux = dgvConditions.Rows[e.RowIndex].Cells[colConditionIsReflux.Name].Value.ToString().ToUpper() == "Y" ? true : false; condInfo.Operation = dgvConditions.Rows[e.RowIndex].Cells[colConditionOperation.Name].Value != null ? dgvConditions.Rows[e.RowIndex].Cells[colConditionOperation.Name].Value.ToString() : ""; condInfo.Other = dgvConditions.Rows[e.RowIndex].Cells[colConditionOther.Name].Value.ToString(); condInfo.Option = DmlOperations.UPDATE.ToString(); fConditions.condInfo = condInfo; if (fConditions.ShowDialog() == DialogResult.OK) { if (ReactionCurationDB.SaveReactionConditions(condInfo, out dtConditions)) { BindDataToConditionsGrid(dtConditions); MessageBox.Show("Condition updated successfully.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error in condition update.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else if (dgvConditions.Columns[e.ColumnIndex].HeaderText.ToString().ToUpper() == "DELETE") { if (MessageBox.Show("Do you want to delete the selected condition?", GlobalVariables.MessageCaption, MessageBoxButtons.YesNo) == DialogResult.Yes) { condInfo.ReactionID = ReactionID; condInfo.ConditionID = Convert.ToInt32(dgvConditions.Rows[e.RowIndex].Cells[colConditionID.Name].Value); condInfo.Option = DmlOperations.DELETE.ToString(); if (ReactionCurationDB.SaveReactionConditions(condInfo, out dtConditions)) { BindDataToConditionsGrid(dtConditions); MessageBox.Show("Condition deleted successfully.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error in condition delete.", GlobalVariables.MessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } }