예제 #1
0
 public ClientAddress GetClientAddressById(int id)
 {
     ClientAddress ca = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", id)
     };
     string sql = "SELECT id, client_id, sender_name, phone, email, postcode, address, remark, fax, province FROM client_address WHERE id = @id";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             ca = new ClientAddress();
             ca.Id = dr.GetInt32(0);
             ca.ClientId = dr.GetInt32(1);
             ca.SenderName = dr.GetString(2);
             ca.Phone = dr.GetString(3);
             ca.Email = dr.GetString(4);
             ca.Postcode = dr.GetString(5);
             ca.Address = dr.GetString(6);
             ca.Remark = dr.GetString(7);
             ca.Fax = dr.GetString(8);
             ca.Province = dr.GetString(9);
         }
     }
     return ca;
 }
예제 #2
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string address = Request.Form[txtAddress.ID].Trim();
        string email = Request.Form[txtEmail.ID].Trim();
        string senderName = Request.Form[txtSenderName.ID].Trim();
        string fax = Request.Form[textFax.ID].Trim();
        string phone = Request.Form[txtPhone.ID].Trim();
        string postcode = Request.Form[txtPostCode.ID].Trim();
        string province = Request.Form["slProvince"].Trim();
        string remark = Request.Form[txtRemark.ID].Trim();

        if (province == "0")
        {
            lblMsg.Text = "请选择所在地区!";
            return;
        }

        if (string.IsNullOrEmpty(senderName) || Validator.IsMatchLessThanChineseCharacter(senderName, 50))
        {
            lblMsg.Text = "发件人姓名不能为空,且不能超过" + 50 + "个字符!";
            return;
        }

        if (!string.IsNullOrEmpty(phone) && Validator.IsMatchLessThanChineseCharacter(phone, 20))
        {
            lblMsg.Text = "联系电话不能超过" + 20 + "个字符!";
            return;
        }
        if (!string.IsNullOrEmpty(email) && Validator.IsMatchLessThanChineseCharacter(email, 40))
        {
            lblMsg.Text = "电子邮件不能超过" + 40 + "个字符!";
            return;
        }
        if (!string.IsNullOrEmpty(fax) && Validator.IsMatchLessThanChineseCharacter(fax, 20))
        {
            lblMsg.Text = "传真不能超过" + 20 + "个字符!";
            return;
        }

        if (string.IsNullOrEmpty(address) || Validator.IsMatchLessThanChineseCharacter(address, 200))
        {
            lblMsg.Text = "地址不能为空,且不能超过" + 200 + "个字符!";
            return;
        }

        ClientAddress ca = new ClientAddress();
        ca.Address = address;
        ca.ClientId = clientSession.Id;
        ca.Email = email;
        ca.Fax = fax;
        ca.Phone = phone;
        ca.Postcode = postcode;
        ca.Province = province;
        ca.Remark = remark;
        ca.SenderName = senderName;

        ClientAddressOpreation.CreateClientAddress(ca);
        lblMsg.Text = "添加成功!";
    }
예제 #3
0
 public void CreateClientAddress(ClientAddress ca)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@client_id",  ca.ClientId),
         SqlUtilities.GenerateInputNVarcharParameter("@province", 50, ca.Province),
         SqlUtilities.GenerateInputNVarcharParameter("@sender_name", 50, ca.SenderName),
         SqlUtilities.GenerateInputNVarcharParameter("@phone", 50, ca.Phone),
         SqlUtilities.GenerateInputNVarcharParameter("@email", 50, ca.Email),
         SqlUtilities.GenerateInputNVarcharParameter("@postcode", 50, ca.Postcode),
         SqlUtilities.GenerateInputNVarcharParameter("@address", 200, ca.Address),
         SqlUtilities.GenerateInputNVarcharParameter("@remark", 500, ca.Remark),
         SqlUtilities.GenerateInputNVarcharParameter("@fax", 50, ca.Fax),
     };
     string sql = "INSERT INTO client_address(client_id, sender_name, phone, email, postcode, address, remark, fax, province) VALUES(@client_id, @sender_name, @phone, @email, @postcode, @address, @remark, @fax, @province)";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
예제 #4
0
 public static void CreateClientAddress(ClientAddress ca)
 {
     dal.CreateClientAddress(ca);
 }