www.pudn.com > IntMail.rar > MailOption.cs


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
 
namespace IntMail 
{ 
    public partial class MailOption : Form 
    { 
        public MailOption() 
        { 
            InitializeComponent(); 
        } 
 
        private void button1_Click(object sender, EventArgs e) 
        { 
 
        } 
 
        private void button2_Click(object sender, EventArgs e) 
        { 
            FrmMailSet _fmset = new FrmMailSet(); 
            _fmset.ShowDialog(); 
        } 
 
        private void MailOption_Load(object sender, EventArgs e) 
        { 
            ReLoad(); 
         } 
        private void ReLoad() 
        { 
            listView1.Items.Clear(); 
            try 
            { 
                CommonMail.init(); 
                DataSet ds = new DataSet(); 
                ds = CommonMail.Search("select * from MailAddress"); 
                if (ds.Tables.Count > 0) 
                { 
                    if (ds.Tables[0].Rows.Count > 0) 
                    { 
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
                        { 
                            ListViewItem L1 = new ListViewItem(new string[] { ds.Tables[0].Rows[0]["MailAddress"].ToString(), ds.Tables[0].Rows[0]["MailAddressPOP3"].ToString(), ds.Tables[0].Rows[0]["MailAddressSMTP"].ToString(), ds.Tables[0].Rows[0]["MailAddressUser"].ToString() }, -1); 
                            listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] { L1 }); 
                        } 
                        // StartCount = 1; 
                    } 
                } 
            } 
            catch (Exception ex) 
            { 
                MessageBox.Show("数据文件出现异常"); 
            } 
        } 
        private void button3_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                if (MessageBox.Show("您真的确定要删除" + listView1.FocusedItem.SubItems[0].Text + "邮箱的配置信息") == DialogResult.OK) 
                { 
                    CommonMail.init(); 
                    int i = CommonMail.Delete("DELETE * FROM MailAddress Where MailAddress='" + listView1.FocusedItem.SubItems[0].Text + "'"); 
                    if (i > 0) 
                    { 
                        MessageBox.Show("删除成功"); 
                        ReLoad(); 
                    } 
                    else 
                    { 
                        MessageBox.Show("删除失败"); 
                    } 
                } 
                else 
                { 
 
                } 
            } 
            catch (Exception ex) 
            { 
                MessageBox.Show(ex.Message); 
            } 
        } 
    } 
}