private Boolean updateDashBoard(cvinr cvi, int stat) { Boolean status = true; try { dashboardalarm dsb = new dashboardalarm(); DashboardDB ddsDB = new DashboardDB(); dsb.DocumentID = "CVINR"; //dsb.TemporaryNo = cvi.TemporaryNo; //dsb.TemporaryDate = cvi.TemporaryDate; //dsb.DocumentNo = cvi.InternalOrderNo; //dsb.DocumentDate = cvi.InternalOrderDate; dsb.FromUser = Login.userLoggedIn; if (stat == 1) { dsb.ActivityType = 2; dsb.ToUser = cvi.ForwardUser; if (!ddsDB.insertDashboardAlarm(dsb)) { MessageBox.Show("DashBoard Fail to update"); status = false; } } else if (stat == 2) { dsb.ActivityType = 3; List <documentreceiver> docList = DocumentReceiverDB.getDocumentWiseReceiver("CVINR"); foreach (documentreceiver docRec in docList) { dsb.ToUser = docRec.EmployeeID; //To store UserID Form DocumentReceiver for current Document dsb.DocumentDate = UpdateTable.getSQLDateTime(); if (!ddsDB.insertDashboardAlarm(dsb)) { MessageBox.Show("DashBoard Fail to update"); status = false; } } } } catch (Exception ex) { status = false; } return(status); }
private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; if (columnName.Equals("Edit") || columnName.Equals("Approve") || columnName.Equals("View")) { clearData(); setButtonVisibility(columnName); prevcvi = new cvinr(); int rowID = e.RowIndex; prevcvi.ConversionDate = DateTime.Parse(grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); try { prevcvi.CurrencyID = grdList.Rows[e.RowIndex].Cells[1].Value.ToString().Trim().Substring(0, grdList.Rows[e.RowIndex].Cells[1].Value.ToString().Trim().IndexOf('-')); prevcvi.CurrencyName = grdList.Rows[e.RowIndex].Cells[1].Value.ToString().Trim().Substring(grdList.Rows[e.RowIndex].Cells[1].Value.ToString().IndexOf('-') + 1); prevcvi.type = ComboFIll.getCurrencyConversionTypeCode(grdList.Rows[e.RowIndex].Cells[2].Value.ToString()); prevcvi.documentStatus = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells[5].Value.ToString()); prevcvi.CreateUser = grdList.Rows[e.RowIndex].Cells[6].Value.ToString(); prevcvi.ForwarderList = grdList.Rows[e.RowIndex].Cells["ForwarderLists"].Value.ToString(); } catch (Exception) { prevcvi.CurrencyID = ""; prevcvi.CurrencyName = ""; } btnSave.Text = "Update"; dtDate.Value = DateTime.Parse(grdList.Rows[e.RowIndex].Cells[0].Value.ToString()); cmbCurrency.SelectedIndex = cmbCurrency.FindStringExact(grdList.Rows[e.RowIndex].Cells[1].Value.ToString()); cmbType.SelectedIndex = cmbType.FindStringExact(grdList.Rows[e.RowIndex].Cells[2].Value.ToString()); txtINRValue.Text = grdList.Rows[e.RowIndex].Cells[3].Value.ToString(); pnlCVINRInner.Visible = true; pnlCVINROuter.Visible = true; pnlCVINRList.Visible = false; } } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { cvinr cvi = new cvinr(); CurrencyVsINRDB cvinrDB = new CurrencyVsINRDB(); cvi.ConversionDate = dtDate.Value; try { cvi.CurrencyID = cmbCurrency.SelectedItem.ToString().Trim().Substring(0, cmbCurrency.SelectedItem.ToString().Trim().IndexOf('-')); cvi.CurrencyName = cmbCurrency.SelectedItem.ToString().Trim().Substring(cmbCurrency.SelectedItem.ToString().Trim().IndexOf('-') + 1); cvi.INRValue = float.Parse(txtINRValue.Text); cvi.ForwarderList = prevcvi.ForwarderList; cvi.type = ComboFIll.getCurrencyConversionTypeCode(cmbType.SelectedItem.ToString()); } catch (Exception ex) { status = false; MessageBox.Show("CVINR Data Validation failed"); return; } System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; if (cvinrDB.validateCVINR(cvi)) { //cvi.documentStatus = prevcvi.documentStatus; if (btnText.Equals("Update")) { if (cvinrDB.updateCVINR(cvi, prevcvi)) { MessageBox.Show("CVINR updated"); closeAllPanels(); listOption = 1; ListFilteredCVINR(listOption); } else { status = false; MessageBox.Show("Failed to update CVINR"); } } else if (btnText.Equals("Save")) { cvi.documentStatus = 1;//created if (cvinrDB.insertCVINR(cvi)) { MessageBox.Show("CVINR Added"); closeAllPanels(); listOption = 1; ListFilteredCVINR(listOption); } else { status = false; MessageBox.Show("Failed to Insert CVINR"); } } } else { status = false; MessageBox.Show("CVINR Data Validation failed"); return; } } catch (Exception ex) { status = false; MessageBox.Show("Failed Adding / Editing CVINR"); } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }