Example #1
0
    protected void GrdSMSCredit_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Label     lblId = (Label)GrdSMSCredit.Rows[e.RowIndex].FindControl("lblId");
        DataTable dt    = Session["data_sms_credit"] as DataTable;

        DataRow[]     foundRows = dt.Select("sms_credit_id=" + lblId.Text);
        DataRow       row       = foundRows[0];
        SMSCreditData smsCredit = SMSCreditDataDB.Load(row);


        try
        {
            SMSCreditDataDB.Delete(smsCredit.SMSCreditID);
        }
        catch (ForeignKeyConstraintException fkcEx)
        {
            if (Utilities.IsDev())
            {
                SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message);
            }
            else
            {
                SetErrorMessage("Can not delete because other records depend on this");
            }
        }

        FillGrid();
    }
Example #2
0
    protected void GrdSMSCredit_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        Label   lblId     = (Label)GrdSMSCredit.Rows[e.RowIndex].FindControl("lblId");
        TextBox txtAmount = (TextBox)GrdSMSCredit.Rows[e.RowIndex].FindControl("txtAmount");

        DataTable dt = Session["data_sms_credit"] as DataTable;

        DataRow[]     foundRows = dt.Select("sms_credit_id=" + lblId.Text);
        DataRow       row       = foundRows[0];
        SMSCreditData smsCredit = SMSCreditDataDB.Load(row);

        if (Convert.ToDecimal(txtAmount.Text) >= 1000000.00M)
        {
            SetErrorMessage("Amount must be less than 1000000.00");
            return;
        }

        SMSCreditDataDB.Update(smsCredit.SMSCreditID, Convert.ToDecimal(txtAmount.Text), smsCredit.DatetimeAdded);

        GrdSMSCredit.EditIndex = -1;
        FillGrid();
    }