public WeightCharge WeightChargeIDatareader(IDataReader dr)
 {
     WeightCharge obj = new WeightCharge();
     obj.ID = (dr["ID"] is DBNull) ? string.Empty : dr["ID"].ToString();
     obj.Name = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].ToString();
     obj.Charge = (dr["Charge"] is DBNull) ? string.Empty : dr["Charge"].ToString();
     obj.Description = (dr["Description"] is DBNull) ? string.Empty : dr["Description"].ToString();
     return obj;
 }
 public List<WeightCharge> GetAllWeightCharge()
 {
     List<WeightCharge> list = new List<WeightCharge>();
     using (SqlCommand cmd = GetCommand("getAllWeightCharge", CommandType.StoredProcedure))
     {
         WeightCharge weightCharge = new WeightCharge();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(weightCharge.WeightChargeIDatareader(dr));
                 }
             }
         }
         weightCharge = null;
     }
     return list;
 }
 public List<WeightCharge> GetWeightChargeByID(string id)
 {
     List<WeightCharge> list = new List<WeightCharge>();
     using (SqlCommand cmd = GetCommand("getWeightChargeByID", CommandType.StoredProcedure))
     {
         AddParameter(cmd, "@ID", Convert.ToInt32(id));
         WeightCharge weightCharge = new WeightCharge();
         using (SqlDataReader dr = ExeDataReader(cmd))
         {
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     list.Add(weightCharge.WeightChargeIDatareader(dr));
                 }
             }
         }
         weightCharge = null;
     }
     return list;
 }
 protected void btnCreate_Click(object sender, EventArgs e)
 {
     if (checkName() && checkChargeFormat() && Page.IsValid)
     {
         WeightCharge weightCharge = new WeightCharge();
         weightCharge.Name = txtName.Text;
         weightCharge.Charge = txtCharge.Text;
         weightCharge.Description = txtDescription.Text;
         bool result = WeightChargeBLL.InsertWeightCharge(weightCharge);
         if (result)
         {
             lblStatusCreate.Text = "Create Weight Charge successful!";
             Response.AddHeader("REFRESH", "2;URL=WeightManagement.aspx");
         }
         else
         {
             lblStatusCreate.Text = "Can not create new Weight Charge!";
             return;
         }
     }
 }
 public static bool UpdateWeightCharge(WeightCharge weightCharge)
 {
     return db.UpdateWeightCharge(weightCharge);
 }
 public static bool InsertWeightCharge(WeightCharge weightCharge)
 {
     return db.InsertWeightCharge(weightCharge);
 }
 private void LoadWeightCharge()
 {
     WeightCharge weightCharge = new WeightCharge();
     weightCharge = WeightChargeBLL.GetWeightChargeByID(WeightChargeID)[0];
     txtName.Text = weightCharge.Name;
     txtCharge.Text = Convert.ToDecimal(weightCharge.Charge).ToString("F");
     txtDescription.Text = weightCharge.Description;
 }
        public bool InsertWeightCharge(WeightCharge weightCharge)
        {
            using (SqlCommand cmd = GetCommand("insertWeightCharge", CommandType.StoredProcedure))
            {
                AddParameter(cmd, "@Name", weightCharge.Name);
                AddParameter(cmd, "@Charge", weightCharge.Charge);
                AddParameter(cmd, "@Description", weightCharge.Description);

                int result = ExeNonQuery(cmd);
                return result > 0;
            }
        }