예제 #1
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string ctName = Request.Form[txtName.ID].Trim();

        if (string.IsNullOrEmpty(ctName) || Validator.IsMatchLessThanChineseCharacter(ctName, CONST_NAME_LENGTH))
        {
            lblMsg.Text = "结算方式名称不能为空,并且长度不能超过 " + CONST_NAME_LENGTH + " 个字符!";
            return;
        }

        CalculateType ct = new CalculateType();
        ct.Name = ctName;

        if (CalculateTypeOperation.CreateCalculateType(ct))
        {
            lblMsg.Text = "添加成功!";
        }
        else
        {
            lblMsg.Text = "此结算方式名称已经存在!";
            return;
        }
        RpCalculateTypeDataBind();
        tbCalculateTypeCreate.Visible = false;
        lbtnCreate.Visible = true;
    }
예제 #2
0
 public void CreateCalculateType(CalculateType ct)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputNVarcharParameter("@name", 50, ct.Name)
     };
     string sql = "INSERT INTO calculate_types(name) VALUES(@name)";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
예제 #3
0
 public static bool CreateCalculateType(CalculateType ct)
 {
     if (dal.GetCalculateTypeByName(ct.Name) != null)
     {
         return false;
     }
     dal.CreateCalculateType(ct);
     return true;
 }
예제 #4
0
 public List<CalculateType> GetCalculateType()
 {
     List<CalculateType> result = new List<CalculateType>();
     string sql = "SELECT id, name FROM calculate_types";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, null))
     {
         while (dr.Read())
         {
             CalculateType ct = new CalculateType();
             ct.Id = dr.GetInt32(0);
             ct.Name = dr.GetString(1);
             result.Add(ct);
         }
     }
     return result;
 }
예제 #5
0
 public CalculateType GetCalculateTypeByName(string name)
 {
     CalculateType ct = null;
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputNVarcharParameter("@name", 50, name)
     };
     string sql = "SELECT id, name FROM calculate_types WHERE name = @name";
     using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sql, param))
     {
         while (dr.Read())
         {
             ct = new CalculateType();
             ct.Id = dr.GetInt32(0);
             ct.Name = dr.GetString(1);
         }
     }
     return ct;
 }
예제 #6
0
 public void UpdateCalculateType(CalculateType ct)
 {
     SqlParameter[] param = new SqlParameter[] {
         SqlUtilities.GenerateInputIntParameter("@id", ct.Id),
         SqlUtilities.GenerateInputNVarcharParameter("@name", 50, ct.Name)
     };
     string sql = "UPDATE calculate_types SET name = @name WHERE id = @id";
     SqlHelper.ExecuteNonQuery(CommandType.Text, sql, param);
 }
예제 #7
0
 public static void UpdateCalculateType(CalculateType ct)
 {
     dal.UpdateCalculateType(ct);
 }