private void btnSave_Click(object sender, EventArgs e) { tapal tap = new tapal(); TapalPickDB tapdb = new TapalPickDB(); tap.ReceivedFrom = txtReceivedFrom.Text.Trim(); tap.Description = txtDescription.Text.Trim(); tap.InwardDocumentType = cmbInwardDocType.SelectedItem.ToString(); if (cmbInwardDocType.SelectedIndex == -1 || string.IsNullOrWhiteSpace(tap.ReceivedFrom)) { MessageBox.Show("Please check the Data Entered!!!"); return; } if (tapdb.updateTapalDetails(tap, refr)) { MessageBox.Show("Tapal Summary updated"); grdDetailList.Rows.Clear(); detaillist(); pnlUpdate.Visible = false; grdDetailList.Enabled = true; grdMainList.Enabled = true; btnCancel.Enabled = true; } else { MessageBox.Show("Failed to Update Tapal Summary"); } }
private void listtapal() { try { grdMainList.Rows.Clear(); clearData(); TapalPickDB TapDB = new TapalPickDB(); List <tapalDistribution> list = TapDB.getTapalListDateWiseSummary(); int i = 1; foreach (tapalDistribution ts in list) { grdMainList.Rows.Add(); grdMainList.Rows[grdMainList.RowCount - 1].Cells["SiNo"].Value = i; grdMainList.Rows[grdMainList.RowCount - 1].Cells["dtDate"].Value = ts.Date; grdMainList.Rows[grdMainList.RowCount - 1].Cells["DocAdded"].Value = ts.RowID; grdMainList.Rows[grdMainList.RowCount - 1].Cells["DocDistributed"].Value = ts.TapalReference; i++; } grdMainList.ClearSelection(); } catch (Exception ex) { MessageBox.Show("Error in Account Group Listing"); } try { enableBottomButtons(); pnlList.Visible = true; } catch (Exception ex) { } }
private void ShowIncomingTapalList() { try { grdTapaList.Rows.Clear(); TapalPickDB tpdb = new TapalPickDB(); List <tapalDistribution> TPList = tpdb.getTapalListInDashBoard(Login.userLoggedIn); foreach (tapalDistribution td in TPList) { grdTapaList.Rows.Add(); grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["SINo"].Value = grdTapaList.RowCount; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["RowId"].Value = td.RowID; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["DocID"].Value = td.DocumentID; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["TapalReference"].Value = td.TapalReference; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["Date"].Value = td.Date; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["FileName"].Value = td.FileName; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["InwardDocumentType"].Value = td.InwardDocumentType; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["ReceivedFrom"].Value = td.ReceivedFrom; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["Sender"].Value = td.Creator; grdTapaList.Rows[grdTapaList.RowCount - 1].Cells["Description"].Value = td.Description; } if (grdTapaList.Rows.Count > 0) { pnlTapal.Visible = true; } else { pnlTapal.Visible = false; } } catch (Exception ex) { MessageBox.Show("Error in showing DocumentList Status"); } }
private void initVariables() { docID = Main.currentDocument; pnlUI.Controls.Add(pnlList); enableBottomButtons(); TapalPickDB.fillInwardDocCombo(cmbInwardDocType, "TapalType"); grdMainList.Visible = true; grdMainList.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; pnlUpdate.Visible = false; }
private void btnSend_Click(object sender, EventArgs e) { TapalPickDB tpdb = new TapalPickDB(); prevtapal.Date = UpdateTable.getSQLDateTime(); try { if (list.Count != 0) { if (tpdb.insertTapalDistribution(list, prevtapal)) { string menuID = getMenuID(); try { string toAddress = ""; toAddress = ERPUserDB.getemailIDs(list, menuID); //create emaildata if (toAddress.Trim().Length > 0) { EmailDataDB emdataDB = new EmailDataDB(); emaildata emdata = new emaildata(); emdata.ToAddress = toAddress; emdata.status = 0; emdata.EmailData = "Tapal from " + prevtapal.ReceivedFrom + " is forwarded to you by " + Login.userLoggedInName; emdata.Subject = "Tapal From " + prevtapal.ReceivedFrom; emdataDB.insertEmailData(emdata); } } catch (Exception ex) { } // tpdb.updateTapalStatus(prevtapal); pnlDistrbutor.Visible = false; grdList.Enabled = true; btnPickFile.Enabled = true; listtapal(); } else { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error 1"); } } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error 2"); } }
private void grdDetailList_CellContentClick(object sender, DataGridViewCellEventArgs e) { ////////grdDetailList.Enabled = false; if (e.RowIndex < 0) { return; } string columnName = grdDetailList.Columns[e.ColumnIndex].Name; if (columnName.Equals("View")) { grdDetailList.Enabled = false; ////grdDetailList.Columns["View"].ReadOnly = true; //btnCancel.Enabled = false; int rowId = Convert.ToInt32(grdDetailList.CurrentRow.Cells["RowID"].Value); string FileName = grdDetailList.CurrentRow.Cells["FileName"].Value.ToString(); string fileName = TapalPickDB.getFileFromDB(rowId, FileName); fileDir = fileName; System.Diagnostics.Process process = System.Diagnostics.Process.Start(fileName); grdDetailList.Enabled = true; process.EnableRaisingEvents = true; process.Exited += new EventHandler(myProcess_Exited); process.WaitForExit(); } if (columnName.Equals("Edit")) { refr = Convert.ToInt32(grdDetailList.Rows[e.RowIndex].Cells["RowID"].Value); try { cmbInwardDocType.SelectedIndex = cmbInwardDocType.FindString(grdDetailList.Rows[e.RowIndex].Cells["InwardDocumentType"].Value.ToString()); txtDescription.Text = grdDetailList.Rows[e.RowIndex].Cells["Description"].Value.ToString(); txtReceivedFrom.Text = grdDetailList.Rows[e.RowIndex].Cells["ReceivedFrom"].Value.ToString(); pnlUpdate.Visible = true; grdDetailList.Enabled = false; grdMainList.Enabled = false; btnCancel.Enabled = false; } catch (Exception ex) { } } }
public void detaillist() { prevag = new tapal(); TapalPickDB TapDB = new TapalPickDB(); List <tapalDistribution> list = TapDB.getTapalListSummaryForADate(dt); int i = 1; foreach (tapalDistribution ts in list) { grdDetailList.Rows.Add(); grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["LineNo"].Value = i; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["RowID"].Value = ts.RowID; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Date"].Value = ts.Date; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["FileName"].Value = ts.FileName; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["InwardDocumentType"].Value = ts.InwardDocumentType; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["ReceivedFrom"].Value = ts.ReceivedFrom; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Description"].Value = ts.Description; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Status"].Value = showStatusString(ts.ActionReferenceID, ts.RowID, ts.Status, ts.ActionStatus); grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CreateUser"].Value = ts.CreateUser; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Creator"].Value = ts.Creator; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["DistributeUser"].Value = ts.DistributeUser; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Distributor"].Value = ts.Distributor; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["ReceiveUser"].Value = ts.UserID; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Receiver"].Value = ts.UserName; grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["CreateTime"].Value = ts.CreateTime; if (grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Status"].Value.ToString() == "Delivered") { //orange grdDetailList.Rows[grdDetailList.RowCount - 1].DefaultCellStyle.BackColor = Color.Orange; } else if (grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Status"].Value.ToString() == "Deleted Before Viewing") { grdDetailList.Rows[grdDetailList.RowCount - 1].DefaultCellStyle.BackColor = Color.Red; } else if (grdDetailList.Rows[grdDetailList.RowCount - 1].Cells["Status"].Value.ToString().Contains("Moved to")) { grdDetailList.Rows[grdDetailList.RowCount - 1].DefaultCellStyle.BackColor = Color.Yellow; } i++; } grdDetailList.ClearSelection(); }
private void listtapal() { try { grdList.Rows.Clear(); clearData(); TapalPickDB TapDB = new TapalPickDB(); List <tapal> list = TapDB.getTapalPicFileDetails(); int i = 1; foreach (tapal cg in list) { grdList.Rows.Add(); grdList.Rows[grdList.RowCount - 1].Cells["LineNo"].Value = i; grdList.Rows[grdList.RowCount - 1].Cells["RowID"].Value = cg.RowID; grdList.Rows[grdList.RowCount - 1].Cells["gDocID"].Value = cg.DocumentID; grdList.Rows[grdList.RowCount - 1].Cells["Date"].Value = cg.Date; grdList.Rows[grdList.RowCount - 1].Cells["FileName"].Value = cg.FileName; grdList.Rows[grdList.RowCount - 1].Cells["InwardDocumentType"].Value = cg.InwardDocumentType; grdList.Rows[grdList.RowCount - 1].Cells["ReceivedFrom"].Value = cg.ReceivedFrom; grdList.Rows[grdList.RowCount - 1].Cells["Description"].Value = cg.Description; grdList.Rows[grdList.RowCount - 1].Cells["FileType"].Value = cg.FileType; grdList.Rows[grdList.RowCount - 1].Cells["Status"].Value = cg.Status; grdList.Rows[grdList.RowCount - 1].Cells["ProtectionLevel"].Value = cg.ProtectionLevel; grdList.Rows[grdList.RowCount - 1].Cells["CreateTime"].Value = cg.CreateTime; grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value = cg.CreateUser; i++; } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } try { enableBottomButtons(); pnlList.Visible = true; // btnNew.Visible = false; } catch (Exception ex) { } }
private string showStatusString(int rowid, int referenceNo, int stat, int ActionStatus) { string str = ""; try { if (stat == 0) { str = "Delivered"; } else if (ActionStatus == 0) { str = "Delivered"; } else if (ActionStatus == 1) { str = TapalPickDB.getMoveReceipentName(rowid, referenceNo); str = "Moved to " + str; } else if (ActionStatus == 2) //deleted { str = "Viewed"; } else if (ActionStatus == 3) { str = "Viewed"; } else if (ActionStatus == 4) { str = "Deleted Before Viewing"; } } catch (Exception ex) { } return(str); }
//private void CopylistView2_ItemChecked(object sender, ItemCheckedEventArgs e) //{ // try // { // if (lvCopy.CheckedIndices.Count > 1) // { // MessageBox.Show("Cannot select more than one item"); // e.Item.Checked = false; // } // } // catch (Exception) // { // } //} private Boolean moveTapal(string userID) { Boolean status = true; try { TapalPickDB tpdb = new TapalPickDB(); prevtd.Date = DateTime.Now.Date; if (tpdb.MoveTapal(userID, prevtd)) { status = true; } else { //pnlDistrbutor.Visible = false; status = false; } } catch (Exception ex) { status = false; } return(status); }
private void grdList_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } string columnName = grdList.Columns[e.ColumnIndex].Name; clearData(); try { if (columnName.Equals("Distribute") || columnName.Equals("View") || columnName.Equals("Delete")) { prevtapal = new tapal(); prevtapal.RowID = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["RowID"].Value.ToString()); prevtapal.DocumentID = grdList.Rows[e.RowIndex].Cells["gDocID"].Value.ToString(); prevtapal.Date = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["Date"].Value.ToString()); prevtapal.FileName = grdList.Rows[e.RowIndex].Cells["FileName"].Value.ToString(); prevtapal.ReceivedFrom = grdList.Rows[e.RowIndex].Cells["ReceivedFrom"].Value.ToString(); prevtapal.InwardDocumentType = grdList.Rows[e.RowIndex].Cells["InwardDocumentType"].Value.ToString(); prevtapal.FileType = grdList.Rows[e.RowIndex].Cells["FileType"].Value.ToString(); prevtapal.Status = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["Status"].Value.ToString()); prevtapal.ProtectionLevel = Convert.ToInt32(grdList.Rows[e.RowIndex].Cells["ProtectionLevel"].Value.ToString()); prevtapal.CreateUser = grdList.Rows[e.RowIndex].Cells["Creator"].Value.ToString(); prevtapal.CreateTime = Convert.ToDateTime(grdList.Rows[e.RowIndex].Cells["CreateTime"].Value.ToString()); prevtapal.Description = grdList.Rows[e.RowIndex].Cells["Description"].Value.ToString(); if (columnName.Equals("View")) { grdList.Enabled = false; string fileName = TapalPickDB.getFileFromDB(prevtapal.RowID, prevtapal.FileName); fileDir = fileName; System.Diagnostics.Process process = System.Diagnostics.Process.Start(fileName); grdList.Enabled = true; process.EnableRaisingEvents = true; process.Exited += new EventHandler(myProcess_Exited); process.WaitForExit(); } if (columnName.Equals("Delete")) { DialogResult dialog = MessageBox.Show("Are you sure to delete the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (TapalPickDB.deleteTapal(prevtapal.RowID)) { MessageBox.Show("Deleted"); listtapal(); } } else { return; } } if (columnName.Equals("Distribute")) { showEmployeeDataGridView("NVP"); //showEmployeeListView(); //grdList.Enabled = false; //btnPickFile.Enabled = false; } //txtFileName.Text = prevag.GroupCode; //txtFileDesc.Text = prevag.GroupInwardDocumentType; //pnlAddNew.Visible = true; //txtFileName.ReadOnly = true; } } catch (Exception ex) { } } catch (Exception ex) { } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { TapalPickDB agdb = new TapalPickDB(); tapal tap = new tapal(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; try { //if (!System.Text.RegularExpressions.Regex.IsMatch(txtFileName.Text, @"^[0-9]+$")) //{ // MessageBox.Show("Group Code accepts only numeric characters"); // return; //} //else tap.DocumentID = docID; tap.Date = UpdateTable.getSQLDateTime(); tap.ReceivedFrom = txtReceivedFrom.Text.Trim(); tap.Description = txtDescription.Text.Trim(); tap.FileName = Path.GetFileName(txtFileName.Text); tap.InwardDocumentType = cmbInwardDocType.SelectedItem.ToString(); if (cmbInwardDocType.SelectedIndex == -1) { MessageBox.Show("Enter InwardDocumentType."); return; } string nm = Path.GetFileName(txtFileName.Text); //if (!System.Text.RegularExpressions.Regex.IsMatch(txtFileDesc.Text, @"^[\sa-zA-Z0-9]+$")) //{ // MessageBox.Show("GroupInwardDocumentType accepts only alphanumeric characters"); // return; //} //else byte[] byteArray = null; FileStream fs = new FileStream(txtFileName.Text, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); tap.DocumentContent = Convert.ToBase64String(br.ReadBytes((int)fs.Length)); } catch (Exception ex) { MessageBox.Show("Validation failed"); return; } if (btnText.Equals("Save")) { if (agdb.validateTapal(tap)) { if (agdb.inserttapal(tap)) { MessageBox.Show("Tapal Added"); closeAllPanels(); listtapal(); pnlAddNew.Visible = false; grdList.Visible = true; pnlBottomButtons.Visible = true; } else { status = false; } } else { MessageBox.Show("Validation failed"); } if (!status) { MessageBox.Show("Failed to save Tapal Document"); } } else { MessageBox.Show("btnSave error."); } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }
private void grdTapaList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { TapalPickDB tpdb = new TapalPickDB(); if (e.RowIndex < 0) { return; } string columnName = grdTapaList.Columns[e.ColumnIndex].Name; if (columnName.Equals("View") || columnName.Equals("Move") || columnName.Equals("Delete")) { prevtd.RowID = Convert.ToInt32(grdTapaList.Rows[e.RowIndex].Cells["RowId"].Value.ToString()); prevtd.DocumentID = grdTapaList.Rows[e.RowIndex].Cells["DocID"].Value.ToString(); prevtd.TapalReference = Convert.ToInt32(grdTapaList.Rows[e.RowIndex].Cells["TapalReference"].Value.ToString()); prevtd.Date = Convert.ToDateTime(grdTapaList.Rows[e.RowIndex].Cells["Date"].Value.ToString()); prevtd.FileName = grdTapaList.Rows[e.RowIndex].Cells["FileName"].Value.ToString(); prevtd.InwardDocumentType = grdTapaList.Rows[e.RowIndex].Cells["InwardDocumentType"].Value.ToString(); prevtd.ReceivedFrom = grdTapaList.Rows[e.RowIndex].Cells["ReceivedFrom"].Value.ToString(); prevtd.UserName = grdTapaList.Rows[e.RowIndex].Cells["Sender"].Value.ToString(); if (columnName.Equals("View")) { grdTapaList.Enabled = false; string path = TapalPickDB.getFileFromDB(prevtd.TapalReference, prevtd.FileName); filDir = path; System.Diagnostics.Process process = System.Diagnostics.Process.Start(path); grdTapaList.Enabled = true; process.EnableRaisingEvents = true; process.Exited += new EventHandler(myProcess_Exited); process.WaitForExit(); tpdb.ChangeTapalStatus(prevtd.RowID, 3); } if (columnName.Equals("Move")) { showEmployeeDataGridView("NVP"); //showEmployeeListView(); // ShowIncomingTapalList(); } if (columnName.Equals("Delete")) { if (columnName.Equals("Delete")) { DialogResult dialog = MessageBox.Show("Are you sure to delete the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (tpdb.ChangeTapalStatus(prevtd.RowID, 2)) { MessageBox.Show("Tapal Removed"); } else { MessageBox.Show("Failed to remove Tapal"); } ShowIncomingTapalList(); } else { return; } } } } ShowIncomingDocumentList(); } catch (Exception ex) { } }