protected void dgvCourierRate_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
        {
            objCommon = new clsCommon();
            hdnCourierRateId.Value = e.CommandArgument.ToString();
            if (e.CommandName == "IsCOD")
            {
                objCourierRate = new tblCourierRate();

                if (objCourierRate.LoadByPrimaryKey(Convert.ToInt32(hdnCourierRateId.Value)))
                {
                    if (objCourierRate.AppIsCOD == true)
                    {
                        objCourierRate.AppIsCOD = false;
                    }
                    else if (objCourierRate.AppIsCOD == false)
                    {
                        objCourierRate.AppIsCOD = true;
                    }
                    objCourierRate.Save();
                    LoadCourierRateData(false, false);
                }
                objCourierRate = null;
            }
        }
    }
    private bool DeleteCourierRate(int intPKID)
    {
        bool retval = false;

        objCourierRate = new tblCourierRate();
        var _with1 = objCourierRate;

        if (_with1.LoadByPrimaryKey(intPKID))
        {
            _with1.MarkAsDeleted();
            _with1.Save();
        }
        retval         = true;
        objCourierRate = null;
        return(retval);
    }
    public void LoadCourierRateData(bool IsResetPageIndex, bool IsSort, string strFieldName = "", string strFieldValue = "")
    {
        objCourierRate = new tblCourierRate();

        objDataTable = objCourierRate.LoadCourierRateGridData(hdnPKID.Value);

        //'Reset PageIndex of gridviews
        if (IsResetPageIndex)
        {
            if (dgvCourierRate.PageCount > 0)
            {
                dgvCourierRate.PageIndex = 0;
            }
        }

        dgvCourierRate.DataSource = null;
        dgvCourierRate.DataBind();
        lblCourierRateCount.Text = 0.ToString();
        hdnSelectedIDs.Value     = "";

        //'Check for data into datatable
        if (objDataTable.Rows.Count <= 0)
        {
            DinfoBranchGrid.ShowMessage("No data found", Enums.MessageType.Information);
            return;
        }
        else
        {
            if (ddlCourierRatePerPage.SelectedItem.Text.ToLower() == "all")
            {
                dgvCourierRate.AllowPaging = false;
            }
            else
            {
                dgvCourierRate.AllowPaging = true;
                dgvCourierRate.PageSize    = Convert.ToInt32(ddlCourierRatePerPage.SelectedItem.Text);
            }

            lblCourierRateCount.Text  = objDataTable.Rows.Count.ToString();
            objDataTable              = SortDatatable(objDataTable, ViewState["SortColumn"].ToString(), (appFunctions.Enum_SortOrderBy)ViewState["SortOrder"], IsSort);
            dgvCourierRate.DataSource = objDataTable;
            dgvCourierRate.DataBind();
        }

        objCourierRate = null;
    }
    private bool SaveCourierRateData()
    {
        if (hdnPKID.Value != "")
        {
            objCommon = new clsCommon();
            if (objCommon.IsRecordExists("tblCourierRate", tblCourierRate.ColumnNames.AppPinCodeID, tblCourierRate.ColumnNames.AppCourierRateID, ddlPINCode.SelectedValue, "", tblCourierRate.ColumnNames.AppCourierCompanyID + "=" + hdnPKID.Value + " and " + tblCourierRate.ColumnNames.AppMinWeight + "=" + txtMinWeight.Text + " and " + tblCourierRate.ColumnNames.AppMaxWeight + "=" + txtMaxWeight.Text + " and " + tblCourierRate.ColumnNames.AppIsCOD + "='" + chkIsCOD.Checked + "'"))
            {
                ddlPINCode.SelectedIndex = 0;
                DInfoSubCategory.ShowMessage("Data for the same already exits.", Enums.MessageType.Error);
                return(false);
            }
            objCourierRate = new tblCourierRate();

            if (!string.IsNullOrEmpty(hdnCourierRateId.Value) && hdnCourierRateId.Value != "")
            {
                objCourierRate.LoadByPrimaryKey(Convert.ToInt32(hdnCourierRateId.Value));
            }
            else
            {
                objCourierRate.AddNew();
            }
            objCourierRate.AppPinCodeID          = Convert.ToInt32(ddlPINCode.SelectedValue.ToString());
            objCourierRate.s_AppCourierCompanyID = hdnPKID.Value;
            objCourierRate.s_AppMinWeight        = txtMinWeight.Text;
            objCourierRate.s_AppMaxWeight        = txtMaxWeight.Text;
            objCourierRate.s_AppRate             = txtRate.Text;
            objCourierRate.AppIsCOD = chkIsCOD.Checked;
            objCourierRate.Save();
            objCourierRate = null;
            objCommon      = null;
            return(true);
        }
        else
        {
            return(false);
        }
    }