Ejemplo n.º 1
0
        public static long Insert(MailConfig cus)
        {
            string sql = @"INSERT INTO MailConfig
           ([Code]
           ,[User]
           ,[Pass]
           ,[MailFrom]
           ,[DislayName]
           ,[Spmt]
           ,[Port]
           ,[EnableSsl]
           ,[Timeout]
           ,[UseCredentials]
           ,[Signature]
           ,[Default])
         VALUES
           ('" + cus.Code + @"'
             ,'" + cus.User + @"'
           ,'" + cus.Pass + @"'
           ,'" + cus.MailFrom + @"'
            ,'" + cus.DislayName + @"'
            ,'" + cus.Spmt + @"'
            ," + cus.Port + @"
             ," + ((cus.EnableSsl == true)?1:0).ToString() + @"
             ," + cus.Timeout + @"
             ," + ((cus.UseCredentials == true)?1:0).ToString() + @"
             ,'" + cus.Signature + @"'
             ," + ((cus.Default == true)?1:0).ToString() + @")";

            Provider.ExecuteNonQuery(sql);
            return(long.Parse(Provider.ExecuteScalar("Select @@IDENTITY").ToString()));
        }
Ejemplo n.º 2
0
        public static long Insert(MailConfig cus)
        {

            string sql = @"INSERT INTO MailConfig
           ([Code]
           ,[User]
           ,[Pass]
           ,[MailFrom]
           ,[DislayName]
           ,[Spmt]
           ,[Port]
           ,[EnableSsl]
           ,[Timeout]
           ,[UseCredentials]
           ,[Signature]
           ,[Default])
         VALUES
           ('" + cus.Code + @"'
             ,'" + cus.User + @"'
           ,'" + cus.Pass + @"'
           ,'" + cus.MailFrom + @"'
            ,'" + cus.DislayName + @"'
            ,'" + cus.Spmt + @"'
            ," + cus.Port + @"
             ," + ((cus.EnableSsl==true)?1:0).ToString() + @"
             ," + cus.Timeout + @"
             ," + ((cus.UseCredentials==true)?1:0).ToString() + @"
             ,'" + cus.Signature + @"'
             ," + ((cus.Default==true)?1:0).ToString() + @")";
            Provider.ExecuteNonQuery(sql);
            return long.Parse(Provider.ExecuteScalar("Select @@IDENTITY").ToString());
         
        }
Ejemplo n.º 3
0
 private void lkProfile_EditValueChanged(object sender, EventArgs e)
 {
     if (lkProfile.EditValue != null)
     {
         long ID = long.Parse(lkProfile.EditValue.ToString());
         mailConfig = MailConfig.Get(ID);
         ClearFormInfo();
         SetFormInfo();
         SetFormStatus("EDIT");
         btnDelete.Enabled = true;
     }
 }
Ejemplo n.º 4
0
        public static MailConfig GetByDefault()
        {
            Type      Default = typeof(MailConfig);
            string    sql     = @"select * from MailConfig where Default=Yes ";
            DataTable dtTable = Provider.ExecuteToDataTable(sql);

            if (dtTable.Rows.Count > 0)
            {
                MailConfig cus = new MailConfig();
                return((MailConfig)Common.GetObjectValue(dtTable.Rows[0], Default, cus));
            }
            return(null);
        }
Ejemplo n.º 5
0
        public static void Update(MailConfig cus)
        {
            string sql = @"UPDATE [MailConfig]
               SET [Code] = '" + cus.Code + @"'
                  ,[User] = '" + cus.User + @"'
                  ,[Pass] = '" + cus.Pass + @"'
                  ,[MailFrom] = '" + cus.MailFrom + @"'
                  ,[DislayName] = '" + cus.DislayName + @"' 
                  ,[Spmt] = '" + cus.Spmt + @"' 
                  ,[Port] = " + cus.Port + @" 
                 ,[EnableSsl] = " + ((cus.EnableSsl == true)?1:0).ToString() + @"
                 ,[Timeout] = " + cus.Timeout + @" 
                 ,[UseCredentials] = " + ((cus.UseCredentials == true)?1:0).ToString() + @" 
                 ,[Signature] = '" + cus.Signature + @"' 
                 ,[Default] = " + ((cus.Default == true)?1:0).ToString() + @"
             WHERE ID=" + cus.ID;

            Provider.ExecuteNonQuery(sql);
        }
Ejemplo n.º 6
0
        public static void Update(MailConfig cus)
        {
            string sql = @"UPDATE [MailConfig]
               SET [Code] = '" + cus.Code + @"'
                  ,[User] = '" + cus.User + @"'
                  ,[Pass] = '" + cus.Pass + @"'
                  ,[MailFrom] = '" + cus.MailFrom + @"'
                  ,[DislayName] = '" + cus.DislayName + @"' 
                  ,[Spmt] = '" + cus.Spmt + @"' 
                  ,[Port] = " + cus.Port + @" 
                 ,[EnableSsl] = " + ((cus.EnableSsl==true)?1:0).ToString() + @"
                 ,[Timeout] = " + cus.Timeout + @" 
                 ,[UseCredentials] = " + ((cus.UseCredentials==true)?1:0).ToString() + @" 
                 ,[Signature] = '" + cus.Signature + @"' 
                 ,[Default] = " + ((cus.Default==true)?1:0).ToString() + @"
             WHERE ID=" + cus.ID;
            Provider.ExecuteNonQuery(sql);
            

        }
Ejemplo n.º 7
0
 private MailConfig GetFormInfo()
 {
     MailConfig cf = new MailConfig();
     cf.Code = txtCode.Text;
     cf.MailFrom = txtFromEmail.Text;
     cf.DislayName = txtDislayName.Text;
     cf.Spmt = txtSPMT.Text;
     cf.Port = int.Parse(calPort.EditValue.ToString());
     cf.Default = chkDefault.Checked;
     cf.EnableSsl = chkEnableSsl.Checked;
     cf.Timeout = int.Parse(calTimeout.EditValue.ToString());
     cf.User = txtUser.Text;
     cf.Pass = txtPass.Text;
     cf.Signature = htmlEditor1.BodyHtml;
     cf.UseCredentials = false;
     return cf;
 }
Ejemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtCode.Text.Trim() == "")
            {
                MessageBox.Show("Vui lòng nhập mã profile","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }
            if (mailConfig == null && status == "NEW")
            {
                MailConfig cf = GetFormInfo();
                if (chkDefault.Checked)
                {
                    MailConfig.ResetDefault();

                }
                long ID=MailConfig.Insert(cf);
                MessageBox.Show("Thêm mới profile thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadMailSetting();

            }
            else if(mailConfig!=null&&status=="EDIT")
            {
                MailConfig cf = GetFormInfo();
                if (chkDefault.Checked)
                {
                    MailConfig.ResetDefault();

                }
                cf.ID = mailConfig.ID;
                MailConfig.Update(cf);
                mailConfig = cf;
                MessageBox.Show("Cập nhập profile thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 9
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     
     lkProfile.EditValue = null;
     ClearFormInfo();
     mailConfig = null;
     SetFormStatus("NEW");
     btnDelete.Enabled = false;
 }
Ejemplo n.º 10
0
        private void SetFormStatus(string s)
        {
            status = s;
            if (s == "NEW")
            {
                txtCode.Enabled = true;
                mailConfig = null;

            }
            else if (s == "EDIT")
            {

                txtCode.Enabled = false;

            }
        }
Ejemplo n.º 11
0
        public static MailConfig GetByDefault()
        {
            Type Default = typeof(MailConfig);
            string sql = @"select * from MailConfig where Default=Yes ";
            DataTable dtTable = Provider.ExecuteToDataTable(sql);
            if (dtTable.Rows.Count > 0)
            {
                MailConfig cus = new MailConfig();
                return (MailConfig)Common.GetObjectValue(dtTable.Rows[0], Default, cus);

            }
            return null;

        }
Ejemplo n.º 12
0
 public void SetSender(MailConfig mailConfig)
 {
     Sender = mailConfig;
 }
Ejemplo n.º 13
0
 public void SetSender(MailConfig mailConfig)
 {
     lblMailFrom.Text = mailConfig.DislayName+" <"+mailConfig.MailFrom+">";
 }