private void m_pCreateRoute_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { wfrm_Route frm = new wfrm_Route(m_ServerAPI); if(frm.ShowDialog(this) == DialogResult.OK){ DataRow dr = m_ServerAPI.AddRoute(frm.Pattern,frm.MailBox,frm.Description,frm.DomainID); if(dr == null){ MessageBox.Show("Error adding alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } } m_ServerAPI.LoadRouting(); }
private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { //--- Add new if(e.Button.Equals(toolBarButton_Add)){ try { if(m_pDomains.Items.Count > 0){ wfrm_Route frm = new wfrm_Route(m_ServerAPI); if(frm.ShowDialog(this) == DialogResult.OK){ DataRow dr = m_ServerAPI.AddRoute(frm.Pattern,frm.MailBox,frm.Description,frm.DomainID); if(dr == null){ MessageBox.Show("Error adding alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } m_DV.Table.ImportRow(dr); } } else{ MessageBox.Show("Please open Emails domain before!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } } catch(Exception x) { wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace()); frm.ShowDialog(this); } return; } //--- Delete if(e.Button.Equals(toolBarButton_Delete)){ try { if(MessageBox.Show(this,"Warning: Deleting route!!!\nDo you want to continue?","Delete confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes) { DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row; if(dr != null){ m_ServerAPI.DeleteRoute(dr["RouteID"].ToString()); dr.Delete(); } // UpdateButtons(); } } catch(Exception x) { wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace()); frm.ShowDialog(this); } return; } //--- Edit if(e.Button.Equals(toolBarButton_Edit)){ try { DataRow dr = ((DataView)(grid.DataSource))[grid.CurrentRowIndex].Row; if(dr != null){ wfrm_Route frm = new wfrm_Route(m_ServerAPI,dr); if(frm.ShowDialog(this) == DialogResult.OK){ m_ServerAPI.UpdateRoute(dr["RouteID"].ToString(),frm.Pattern,frm.MailBox,frm.Description,frm.DomainID); dr["Pattern"] = frm.Pattern; dr["Mailbox"] = frm.MailBox; dr["Description"] = frm.Description; dr["DomainID"] = frm.DomainID; dr["DomainName"] = frm.DomainName; } } } catch(Exception x) { wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace()); frm.ShowDialog(this); } return; } }