コード例 #1
0
        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_Alias frm = new wfrm_Alias(m_ServerAPI,m_pDomains.SelectedItem.Tag.ToString());
                        if(frm.ShowDialog(this) == DialogResult.OK){

                            DataRow dr = m_ServerAPI.AddAlias(frm.AliasName,frm.Descriprion,frm.Members,frm.DomainID,frm.IsPublic);
                            if(dr == null){
                                MessageBox.Show("Error adding alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                                return;
                            }

                            m_DvAliases.Table.ImportRow(dr);

                            UpdateButtons();
                        }
                    }
                    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 alias!!!\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.DeleteAlias(dr["AliasID"].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_Alias frm = new wfrm_Alias(m_ServerAPI,dr);
                        if(frm.ShowDialog(this) == DialogResult.OK){
                            m_ServerAPI.UpdateAlias(dr["AliasID"].ToString(),frm.AliasName,frm.Descriprion,frm.Members,frm.DomainID,frm.IsPublic);

                            dr["AliasName"]    = frm.AliasName;
                            dr["Description"]  = frm.Descriprion;
                            dr["AliasMembers"] = frm.Members;
                            dr["DomainID"]     = frm.DomainID;
                            dr["IsPublic"]     = frm.IsPublic;
                        }
                    }
                }
                catch(Exception x)
                {
                    wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
                    frm.ShowDialog(this);
                }

                return;
            }
        }
コード例 #2
0
        private void m_pCreateAlias_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            wfrm_Alias frm = new wfrm_Alias(m_ServerAPI,"ALL");
            if(frm.ShowDialog(this) == DialogResult.OK){

                DataRow dr = m_ServerAPI.AddAlias(frm.AliasName,frm.Descriprion,frm.Members,frm.DomainID,frm.IsPublic);
                if(dr == null){
                    MessageBox.Show("Error adding alias!!!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
            }

            m_ServerAPI.LoadAliases();
        }