Exemple #1
0
        public List<Company> GetCompany()
        {
            List<Company> result = new List<Company>();

            string sql = "SELECT id, name, area_code, address, contact_person, phone, email, smtp, commission, email_password, qq, msn FROM companies WHERE is_delete = 0 ";
            using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
            {
                while (dr.Read())
                {
                    Company company = new Company();
                    company.Id = dr.GetInt32(0);
                    company.Name = dr.GetString(1);
                    company.AreaCode =EnumConvertor.ConvertToAreaCode(dr.GetByte(2));
                    company.Address = dr.GetString(3);
                    company.ContactPerson = dr.GetString(4);
                    company.Phone = dr.GetString(5);
                    company.Email = dr.GetString(6);
                    company.Smtp = dr.GetString(7);
                    company.Commission = dr.GetDecimal(8);
                    company.EmailPassword = dr.GetString(9);
                    company.QQ = dr.GetString(10);
                    company.MSN = dr.GetString(11);
                    result.Add(company);
                }
            }
            return result;
        }
 public static bool CreateCompany(Company company)
 {
     if (dal.GetCompanyByName(company.Name) != null)
     {
         return false;
     }
     dal.CreateCompany(company);
     return true;
 }
Exemple #3
0
 public static List<Client> SendMailForAnnounce(Company company, List<Client> result, string title, string content)
 {
     List<Client> listClients = new List<Client>();
     content = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + content;
     if (result.Count > 0)
     {
         foreach (Client client in result)
         {
             string msg = "";
             if (!SendMail(company, client, title, content, out msg))
             {
                 listClients.Add(client);
             }
         }
     }
     return listClients;
 }
Exemple #4
0
 public void CreateCompany(Company company)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputNVarcharParameter("@name",50, company.Name),
         SqlUtilities.GenerateInputParameter("@area_code", SqlDbType.TinyInt, (byte)company.AreaCode),
         SqlUtilities.GenerateInputNVarcharParameter("@address", 200, company.Address),
         SqlUtilities.GenerateInputNVarcharParameter("@contact_person", 50, company.ContactPerson),
         SqlUtilities.GenerateInputNVarcharParameter("@phone", 50, company.Phone),
         SqlUtilities.GenerateInputNVarcharParameter("@email", 50, company.Email),
         SqlUtilities.GenerateInputNVarcharParameter("@email_password", 50, company.EmailPassword),
         SqlUtilities.GenerateInputNVarcharParameter("@smtp", 50, company.Smtp),
         SqlUtilities.GenerateInputParameter("@commission", SqlDbType.Decimal, company.Commission),
         SqlUtilities.GenerateInputNVarcharParameter("@qq", 50, company.QQ),
         SqlUtilities.GenerateInputNVarcharParameter("@msn", 50, company.MSN)
     };
     string sql = "INSERT INTO companies(name, area_code, address, contact_person, phone, email, email_password, smtp, commission, qq, msn) VALUES( @name, @area_code, @address, @contact_person, @phone, @email, @email_password, @smtp, @commission, @qq, @msn)";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
Exemple #5
0
 public static bool SendMailForArrearage(Company company, Client client, decimal money, out string msg)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�����η���Ƿ��" + money.ToString() + " Ԫ������ǰ���˻����ΪRMB " + client.Balance.ToString() + " Ԫ���뼰ʱ��ֵ������Ӱ�����´η��������ö�ȵ����ӣ�");
     return SendMail(company, client, "Ƿ��֪ͨ", sb.ToString(), out msg);
 }
Exemple #6
0
        public static bool SendMailForService(Company company, Client client, WrongOrderDetail wod, out string msg)
        {
            StringBuilder sb = new StringBuilder();
            WrongOrder wrongOrder = WrongOrderOperation.GetWrongOrderById(wod.WrongOrderId);
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;���ķ�����Ϣ�и��£�<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�����룺"+wrongOrder.BarCode+"<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�������ݣ�"+wrongOrder.Reason+"<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�����ʽ�����̣�"+wod.Detail+"<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;��������"+wod.Result+"<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�����ˣ�"+UserOperation.GetUserById(wod.CreateUserId).RealName+"<br/>");

            return SendMail(company, client, "�ͻ������и���", sb.ToString(), out msg);
        }
Exemple #7
0
 public static bool SendMailForReceiveMoney(Company company, Client client, decimal money, out string msg)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;��˾���յ������θ���RMB "+money.ToString()+" Ԫ������ǰ���˻����ΪRMB "+client.Balance.ToString()+" Ԫ����˶ԣ���������������ҵ����Ա��ϵ��");
     return SendMail(company, client, "�տ�֪ͨ", sb.ToString(), out msg);
 }
Exemple #8
0
        public static bool SendMail(Company company, Client client, string title, string content, out string msg)
        {
            string mailFrom = company.Email;
            string mailAccount = mailFrom.Substring(0, mailFrom.IndexOf('@'));
            string mailPwd = company.EmailPassword;
            string smtp = company.Smtp;
            string mailTo = client.Email;

            Setting setting = SettingOperation.LoadSetting();

            StringBuilder sb = new StringBuilder();
            sb.Append("<table border='0' cellspacing='0' cellpadding='0' width='100%' style='font-size:12px; line-height:24px;'>");
            sb.Append("<tr><td align='left' valign='top'>�𾴵�" + client.RealName + "��<br/>");
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;���ã�<br/>");
            sb.Append("</td></tr>");
            sb.Append("<tr><td align='left' valign='top'>");
            sb.Append(content);
            sb.Append("</td></tr>");
            sb.Append("<tr><td align='left' valign='top'>");
            sb.Append("<br/><br/><br/>");
            sb.Append("˳ף������<br/>");
            sb.Append("�ڶ�����<br/>");
            sb.Append(DateTime.Now.ToShortDateString() + "<br/><br/>");
            sb.Append("���ʼ�Ϊϵͳ�ʼ�������ֱ�ӻظ���<br/>");
            sb.Append("���������뷢�ʼ����ͷ����䣺"+setting.Email+" �����磺"+company.Phone+"");
            sb.Append("</td></tr>");
            sb.Append("</table>");

            MailMessage objMailMessage = new MailMessage();
            objMailMessage.From = mailFrom;
            objMailMessage.To = mailTo;
            objMailMessage.Subject = title;
            objMailMessage.Body = sb.ToString();
            objMailMessage.BodyFormat = MailFormat.Html;
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            //�û���
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mailAccount);
            //����
            objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", mailPwd);
            SmtpMail.SmtpServer = smtp;

            if (client.IsMessage)
            {
                try
                {
                    SmtpMail.Send(objMailMessage);
                    msg = "�����ɹ����ʼ��ѳɹ����ͣ�";
                    return true;
                }
                catch (Exception ex)
                {
                    msg = "�����ɹ�������˾��ͻ����������ʼ�����ʧ�ܣ�";
                    return false;
                }
            }
            else
            {
                msg = "�����ɹ���";
                return false;
            }
        }
Exemple #9
0
        public static bool SendMailForConsign(Company company, Client client, Order order, out string msg)
        {
            StringBuilder sb = new StringBuilder();
            List<OrderDetail> result = OrderDetailOperation.GetOrderDetailByOrderId(order.Id);

            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�����������εĻ��˵���<br/><br/>");
            sb.Append("<table border='1' cellspacing='0' cellpadding='0' width='100%' style='font-size:12px;'>");
            sb.Append("<tr>");
            sb.Append("<td width='9%' align='right' valign='middle'>�ռ�����:</td><td width='36%' align='left' valign='middle'>&nbsp;" + order.Encode + "</td>");
            sb.Append("<td width='9%' align='right' valign='middle'>�ռ�����:</td><td width='18%' align='left' valign='middle'>&nbsp;" + order.ReceiveDate.ToShortDateString() + "</td>");
            sb.Append("<td width='9%' align='right' valign='middle'>�ͻ����:</td><td width='19%' align='left' valign='middle'>&nbsp;" + order.Client.Id + "</td></tr>");
            sb.Append("<tr>");
            sb.Append("<td align='right' valign='middle'>�ͻ�����:</td><td align='left' valign='middle'>&nbsp;" + order.Client.RealName + "</td>");
            sb.Append("<td align='right' valign='middle'>��ϵ��:</td><td align='left' valign='middle'>&nbsp;" + order.Client.RealName + "</td>");
            sb.Append("<td align='right' valign='middle'>��ϵ�绰:</td><td align='left' valign='middle'>&nbsp;" + order.Client.Phone + "</td></tr>");
            sb.Append("<tr>");
            sb.Append("<td align='right' valign='middle'>��ϵ��ַ:</td><td align='left' valign='middle'>&nbsp;" + order.Client.Address + "</td>");
            sb.Append("<td align='right' valign='middle'>Ӧ���ܼ�:</td><td colspan='3' align='left' valign='middle'>&nbsp;" + order.Costs + " Ԫ</td></tr>");
            sb.Append("<tr>");
            sb.Append("<td width='9%' align='right' valign='middle'>��ע:</td><td colspan='5' align='left' valign='middle'>&nbsp;"+order.Remark+"</td></tr>");
            sb.Append("<tr><td colspan='6' height='8'></td></tr>");

            sb.Append("<tr><td colspan='6' valign='top'>");
            sb.Append("<table border='1' cellspacing='0' cellpadding='0' width='100%' style='border-top:0px; border-bottom:0px; border-left:0px; border-right:0px; line-height:18px;font-size:12px;'>");
            sb.Append("<tr>");
            sb.Append("<td width='4%' align='center' valign='middle'>���</td><td width='8%' align='right' valign='middle'>������</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>�ʼ�����</td><td width='8%' align='right' valign='middle'>����(KG)</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>�˷�(��)</td><td width='8%' align='right' valign='middle'>�Һŷ�(��)</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>ƫԶ��(��)</td><td width='7%' align='right' valign='middle'>�����(��)</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>ȡ����(��)</td><td width='7%' align='right' valign='middle'>���Ϸ�(��)</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>���۷�(��)</td><td width='7%' align='right' valign='middle'>������(��)</td>");
            sb.Append("<td width='7%' align='right' valign='middle'>ȼ�ͷ�(��)</td>");
            sb.Append("<td width='10%' align='right' valign='middle'>Ӧ������(��)</td></tr>");
            foreach (OrderDetail od in result)
            {
                int i=1;
                sb.Append("<tr>");
                sb.Append("<td align='center' valign='middle'>"+i.ToString()+"</td><td align='right' valign='middle'>"+od.CarrierEncode+"</td>");
                sb.Append("<td align='right' valign='middle'>"+od.Count.ToString()+"</td><td align='right' valign='middle'>"+od.Weight.ToString()+"</td>");
                sb.Append("<td align='right' valign='middle'>"+od.PostCosts.ToString()+"</td><td align='right' valign='middle'>"+od.RegisterCosts.ToString()+"</td>");
                sb.Append("<td align='right' valign='middle'>"+od.RemoteCosts.ToString()+"</td><td align='right' valign='middle'>"+od.DisposalCosts.ToString()+"</td>");
                sb.Append("<td align='right' valign='middle'>"+od.FetchCosts.ToString()+"</td><td align='right' valign='middle'>"+od.MaterialCosts.ToString()+"</td>");
                sb.Append("<td align='right' valign='middle'>"+od.InsureCosts.ToString()+"</td><td align='right' valign='middle'>"+od.OtherCosts.ToString()+"</td>");
                sb.Append("<td align='right' valign='middle'>" + od.FuelCosts.ToString() + "</td>");
                sb.Append("<td align='right' valign='middle'>"+od.TotalCosts.ToString()+"</td></tr>");
                i++;
            }
            sb.Append("</table></td></tr>");
            sb.Append("<tr><td colspan='6' height='10'></td></tr>");
            sb.Append("<tr>");
            sb.Append("<td colspan='6' align='left' style='line-height:20px;'>");
            sb.Append("&nbsp;���Ļ����Ѿ��ﵽ���ǵĴ������ģ�������Сʱ�Ĵ����Ժ󼴽�����.<br />");
            sb.Append("&nbsp;����ϸ�˶Ի��˵�������,��������������ҵ����Ա��ϵ.<br />");
            sb.Append("&nbsp;����ĸ����������������վ(<a href='http://www.eadu.com.cn' target='_blank'>http://www.eadu.com.cn</a>)�ϲ�ѯ. <br />");
            sb.Append("&nbsp;�����˻����: <span style='color:#0000FF;'>" + client.Balance.ToString() + "</span> Ԫ </td></tr></table>");

            return SendMail(company, client, "���˵�", sb.ToString(), out msg);
        }
Exemple #10
0
        public static bool SendMailForBill(DateTime startDate, DateTime endDate, Company company, Client client, List<SearchOrderDetail> result, out string msg)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;�������� "+startDate.ToShortDateString()+" �� "+endDate.ToShortDateString()+" �Ķ��˵���<br/><br/>");
            sb.Append("<table border='1' cellspacing='0' cellpadding='0' width='100%' style='line-height:18px;font-size:12px;'>");
            sb.Append("<tr style='font-weight:bold;'>");
            sb.Append("<td align='left' valign='middle'>&nbsp;����</td>");
            sb.Append("<td align='left' valign='middle'>&nbsp;������</td><td align='left' valign='middle'>&nbsp;��������</td>");
            sb.Append("<td align='left' valign='middle'>&nbsp;����</td><td align='right' valign='middle'>����(KG)</td>");
            sb.Append("<td align='right' valign='middle'>����</td><td align='right' valign='middle'>����(��)</td>");
            sb.Append("</tr>");
            decimal totalMoney = 0;
            foreach (SearchOrderDetail sod in result)
            {
                sb.Append("<tr>");
                sb.Append("<td align='left' valign='middle'>&nbsp;" + sod.CreateTime.ToShortDateString() + "</td>");
                sb.Append("<td align='left' valign='middle'>&nbsp;" + CarrierOperation.GetCarrierByEncode(sod.CarrierEncode).Name + "</td><td align='left' valign='middle'>&nbsp;" + sod.BarCode + "</td>");
                sb.Append("<td align='left' valign='middle'>&nbsp;" + sod.ToCountry + "</td><td align='right' valign='middle'>&nbsp;" + sod.Weight.ToString() + "</td>");
                sb.Append("<td align='right' valign='middle'>&nbsp;" + sod.Count.ToString() + "</td>");
                sb.Append("<td align='right' valign='middle'>&nbsp;" + sod.TotalCosts.ToString() + "</td></tr>");

                totalMoney += sod.TotalCosts;
            }
            sb.Append("<tr style='font-weight:bold;'><td align='left'>&nbsp;�ϼƣ�</td><td colspan='5'>&nbsp;</td><td align='right'>&nbsp;" + totalMoney.ToString() + "</td></tr>");
            sb.Append("</table>");
            return SendMail(company, client, "���˵�", sb.ToString(), out msg);
        }
Exemple #11
0
        public PaginationQueryResult<Company> GetCompany(PaginationQueryCondition condition)
        {
            PaginationQueryResult<Company> result=new PaginationQueryResult<Company>();

            string sql = "SELECT TOP " + condition.PageSize + " id, name, area_code, address, contact_person, phone, email, smtp, commission, email_password, qq, msn FROM companies WHERE id_delete = 0";
            if (condition.CurrentPage > 1)
            {
                sql += " AND id<(SELECT MIN(id) FROM (SELECT TOP " + condition.PageSize * (condition.CurrentPage - 1) + " id FROM companies WHERE is_delete = 0 ORDER BY id DESC) AS D)";
            }
            sql += " ORDER BY id DESC; SELECT COUNT(*) FROM companies WHERE id_delete = 0";
            using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
            {
                while (dr.Read())
                {
                    Company company = new Company();
                    company.Id = dr.GetInt32(0);
                    company.Name = dr.GetString(1);
                    company.AreaCode = EnumConvertor.ConvertToAreaCode(dr.GetByte(2));
                    company.Address = dr.GetString(3);
                    company.ContactPerson = dr.GetString(4);
                    company.Phone = dr.GetString(5);
                    company.Email = dr.GetString(6);
                    company.Smtp = dr.GetString(7);
                    company.Commission = dr.GetDecimal(8);
                    company.EmailPassword = dr.GetString(9);
                    company.QQ = dr.GetString(10);
                    company.MSN = dr.GetString(11);
                    result.Results.Add(company);
                }
                dr.NextResult();
                while (dr.Read())
                {
                    result.TotalCount = dr.GetInt32(0);
                }
            }
            return result;
        }
Exemple #12
0
 public void UpdateCompany(Company company)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", company.Id),
         SqlUtilities.GenerateInputNVarcharParameter("@name",50, company.Name),
         SqlUtilities.GenerateInputParameter("@area_code", SqlDbType.TinyInt, (byte)company.AreaCode),
         SqlUtilities.GenerateInputNVarcharParameter("@address", 200, company.Address),
         SqlUtilities.GenerateInputNVarcharParameter("@contact_person", 50, company.ContactPerson),
         SqlUtilities.GenerateInputNVarcharParameter("@phone", 50, company.Phone),
         SqlUtilities.GenerateInputNVarcharParameter("@email", 50, company.Email),
         SqlUtilities.GenerateInputNVarcharParameter("@email_password", 50, company.EmailPassword),
         SqlUtilities.GenerateInputNVarcharParameter("@smtp", 50, company.Smtp),
         SqlUtilities.GenerateInputParameter("@commission", SqlDbType.Decimal, company.Commission),
         SqlUtilities.GenerateInputNVarcharParameter("@qq", 50, company.QQ),
         SqlUtilities.GenerateInputNVarcharParameter("@msn", 50, company.MSN)
     };
     string sql = "UPDATE companies SET name =@name, area_code =@area_code, address =@address, contact_person =@contact_person, phone =@phone, email =@email, email_password = @email_password, smtp =@smtp, commission =@commission, qq = @qq, msn = @msn WHERE id = @id";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
Exemple #13
0
 public Company GetCompanyByName(string name)
 {
     Company company = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputNVarcharParameter("@name", 50, name),
     };
     string sql = "SELECT id, name, area_code, address, contact_person, phone, email, smtp, commission, email_password, qq, msn FROM companies WHERE name = @name";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             company = new Company();
             company.Id = dr.GetInt32(0);
             company.Name = dr.GetString(1);
             company.AreaCode =EnumConvertor.ConvertToAreaCode(dr.GetByte(2));
             company.Address = dr.GetString(3);
             company.ContactPerson = dr.GetString(4);
             company.Phone = dr.GetString(5);
             company.Email = dr.GetString(6);
             company.Smtp = dr.GetString(7);
             company.Commission = dr.GetDecimal(8);
             company.EmailPassword = dr.GetString(9);
             company.QQ = dr.GetString(10);
             company.MSN = dr.GetString(11);
         }
     }
     return company;
 }
 public static void UpdateCompany(Company company)
 {
     dal.UpdateCompany(company);
 }
Exemple #15
0
 public Company GetCompanyById(int id)
 {
     Company company = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id),
     };
     string sql = "SELECT id, name, area_code, address, contact_person, phone, email, smtp, commission, email_password, qq, msn FROM companies WHERE id = @id; SELECT CA.module_id, CA.accessible, CA.writable FROM company_authorizations AS CA, companies AS C WHERE C.id = CA.company_id and C.id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             company = new Company();
             company.Id = dr.GetInt32(0);
             company.Name = dr.GetString(1);
             company.AreaCode =EnumConvertor.ConvertToAreaCode(dr.GetByte(2));
             company.Address = dr.GetString(3);
             company.ContactPerson = dr.GetString(4);
             company.Phone = dr.GetString(5);
             company.Email = dr.GetString(6);
             company.Smtp = dr.GetString(7);
             company.Commission = dr.GetDecimal(8);
             company.EmailPassword = dr.GetString(9);
             company.QQ = dr.GetString(10);
             company.MSN = dr.GetString(11);
         }
         if (company != null)
         {
             dr.NextResult();
             company.ModuleAuthorizations = new List<ModuleAuthorization>();
             while (dr.Read())
             {
                 ModuleAuthorization ma = new ModuleAuthorization();
                 ma.ModuleId = dr.GetInt32(0);
                 ma.Accessible = dr.GetBoolean(1);
                 ma.Writable = dr.GetBoolean(2);
                 company.ModuleAuthorizations.Add(ma);
             }
         }
     }
     return company;
 }