private void m_pCreateUser_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { wfrm_User_Frame frm = new wfrm_User_Frame(m_ServerAPI,"ALL"); if(frm.ShowDialog(this) == DialogResult.OK){ DataRow dr = m_ServerAPI.AddUser(frm.FullName,frm.UserName,frm.Password,frm.Description,frm.Emails,frm.DomainID,frm.MailboxSize,frm.UserEnabled,frm.AllowRelay,frm.wp_RemoteAccounts); if(dr == null){ MessageBox.Show("Error adding user!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } } m_ServerAPI.LoadUsers(); }
private void wToolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { //--- Add new if(e.Button.Equals(toolBarButton_Add)){ if(m_pDomains.Items.Count > 1){ wfrm_User_Frame frm = new wfrm_User_Frame(m_ServerAPI,m_pDomains.SelectedItem.Tag.ToString()); if(frm.ShowDialog(this) == DialogResult.OK){ DataRow dr = m_ServerAPI.AddUser(frm.FullName,frm.UserName,frm.Password,frm.Description,frm.Emails,frm.DomainID,frm.MailboxSize,frm.UserEnabled,frm.AllowRelay,frm.wp_RemoteAccounts); if(dr == null){ MessageBox.Show("Error adding user!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } m_DvUsers.Table.ImportRow(dr); UpdateButtons(); } } else{ MessageBox.Show("Please open Emails domain before!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); } return; } //--- Delete if(e.Button.Equals(toolBarButton_Delete)){ try { if(MessageBox.Show(this,"Warning: Deleting user!!!\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.DeleteUser(dr["UserID"].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_User_Frame frm = new wfrm_User_Frame(m_ServerAPI,dr); if(frm.ShowDialog(this) == DialogResult.OK){ m_ServerAPI.UpdateUser(dr["UserID"].ToString(),frm.FullName,frm.Password,frm.Description,frm.Emails,frm.DomainID,frm.MailboxSize,frm.UserEnabled,frm.AllowRelay,frm.wp_RemoteAccounts); dr["FULLNAME"] = frm.FullName; dr["USERNAME"] = frm.UserName; dr["PASSWORD"] = frm.Password; dr["Description"] = frm.Description; dr["Emails"] = frm.Emails; dr["DomainID"] = frm.DomainID; dr["Mailbox_Size"] = frm.MailboxSize; dr["Enabled"] = frm.UserEnabled; dr["AllowRelay"] = frm.AllowRelay; if(frm.wp_RemoteAccounts != null){ dr["RemotePop3Servers"] = frm.wp_RemoteAccounts; } else{ dr["RemotePop3Servers"] = System.DBNull.Value; } } } } catch(Exception x) { wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace()); frm.ShowDialog(this); } return; } }