private bool SaveData()
    {
        objCommon = new clsCommon();
        if (objCommon.IsRecordExists("tblCouponCode", tblCouponCode.ColumnNames.AppCouponCode, tblCouponCode.ColumnNames.AppCouponCodeID, txtCouponCode.Text, hdnPKID.Value))
        {
            DInfo.ShowMessage("Coupon Code alredy exits.", Enums.MessageType.Error);
            return(false);
        }

        objCouponCode = new tblCouponCode();
        if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
        {
            objCouponCode.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
        }
        else
        {
            objCouponCode.AddNew();
        }
        objCouponCode.AppCouponCode    = txtCouponCode.Text;
        objCouponCode.s_AppDiscountPer = txtDiscountPer.Text;
        objCouponCode.s_AppStartDate   = txtStartDate.Text;
        objCouponCode.s_AppEndDate     = txtEndDate.Text;
        objCouponCode.AppIsActive      = chkIsActive.Checked;
        objCouponCode.s_AppType        = ddlType.SelectedValue;
        objCouponCode.Save();
        intPkId       = objCouponCode.AppCouponCodeID;
        objCouponCode = null;
        objCommon     = null;
        return(true);
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         lnkSaveAndAddnew.Visible = HasAdd;
         ViewState["SortOrder"]   = appFunctions.Enum_SortOrderBy.Asc;
         ViewState["SortColumn"]  = "";
         SetRegulerExpression();
         objCommon = new clsCommon();
         objCommon.BindEnumtoDDL(typeof(Enums.Enum_CouponCodeType), ddlType, "-- Select Type --");
         objCouponCode = null;
         if ((Request.QueryString.Get("ID") != null))
         {
             objEncrypt = new clsEncryption();
             try
             {
                 hdnPKID.Value = objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey);
             }
             catch (Exception ex)
             {
                 // noIdFoundRedirect("Employee.aspx");
             }
             objEncrypt = null;
             SetValuesToControls();
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "HideTab()", true);
         }
     }
 }
Exemplo n.º 3
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objCouponCode = new tblCouponCode();
        if (objCouponCode.LoadByPrimaryKey(intPKID))
        {
            objCouponCode.MarkAsDeleted();
            objCouponCode.Save();
            retval = true;
        }

        objCouponCode = null;
        return(retval);
    }
Exemplo n.º 4
0
    private void LoadDataGrid(bool IsResetPageIndex, bool IsSort)
    {
        objCouponCode = new tblCouponCode();
        objDataTable  = objCouponCode.LoadGridData(ddlFields.SelectedValue, txtSearch.Text.Trim(), ddlDateType.SelectedValue, txtStartDate.Text, txtEndDate.Text);
        if (IsResetPageIndex)
        {
            if (dgvGridView.PageCount > 0)
            {
                dgvGridView.PageIndex = 0;
            }
        }
        dgvGridView.DataSource = null;
        dgvGridView.DataBind();
        lblCount.Text        = 0.ToString();
        hdnSelectedIDs.Value = "";

        if (objDataTable.Rows.Count <= 0)
        {
            DInfo.ShowMessage("No data found", Enums.MessageType.Information);
            return;
        }
        else
        {
            if (ddlPerPage.SelectedItem.Text.ToLower() == "all")
            {
                dgvGridView.AllowPaging = false;
            }
            else
            {
                dgvGridView.AllowPaging = true;
                dgvGridView.PageSize    = Convert.ToInt32(ddlPerPage.SelectedItem.Text);
            }

            lblCount.Text          = objDataTable.Rows.Count.ToString();
            objDataTable           = SortDatatable(objDataTable, ViewState["SortColumn"].ToString(), (appFunctions.Enum_SortOrderBy)ViewState["SortOrder"], IsSort);
            dgvGridView.DataSource = objDataTable;
            dgvGridView.DataBind();
        }
        objCouponCode = null;
    }
 private void SetValuesToControls()
 {
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objCouponCode = new tblCouponCode();
         if (objCouponCode.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
         {
             ddlType.SelectedValue = objCouponCode.s_AppType;
             hdnType.Value         = objCouponCode.s_AppType;
             txtCouponCode.Text    = objCouponCode.s_AppCouponCode;
             txtDiscountPer.Text   = objCouponCode.s_AppDiscountPer;
             txtStartDate.Text     = objCouponCode.AppStartDate.ToString("dd-MM-yyyy");
             txtEndDate.Text       = objCouponCode.AppEndDate.ToString("dd-MM-yyyy");
             chkIsActive.Checked   = objCouponCode.AppIsActive;
             if (objCouponCode.AppType == Convert.ToInt32(Enums.Enum_CouponCodeType.General))
             {
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "HideTab()", true);
             }
             LoadAllData();
         }
         objCouponCode = null;
     }
 }
Exemplo n.º 6
0
 protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
     {
         if (e.CommandName == "IsActive")
         {
             objCouponCode = new tblCouponCode();
             if (objCouponCode.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())))
             {
                 if (objCouponCode.AppIsActive == true)
                 {
                     objCouponCode.AppIsActive = false;
                 }
                 else if (objCouponCode.AppIsActive == false)
                 {
                     objCouponCode.AppIsActive = true;
                 }
                 objCouponCode.Save();
                 LoadDataGrid(false, false);
             }
             objCouponCode = null;
         }
     }
 }
    //protected void btnCheckPincode_Click(object sender, EventArgs e)
    //{
    //    tblPinCode objPinCode = new tblPinCode();
    //    objPinCode.Where.AppPinCode.Value = txtPincode.Text;
    //    objPinCode.Query.Load();
    //    if (objPinCode.RowCount > 0)
    //    {
    //        lblAvailability.Visible = true;
    //        lblAvailability.Text = "Available";
    //        lblAvailability.ForeColor = System.Drawing.Color.Green;
    //    }
    //    else
    //    {
    //        lblAvailability.Visible = true;
    //        lblAvailability.Text = "Not Available";
    //        lblAvailability.ForeColor = System.Drawing.Color.Red;
    //    }
    //    objPinCode = null;
    //}


    protected void btnCheckCouponCode_Click(object sender, EventArgs e)
    {
        decimal       decprice         = 0;
        decimal       decpricediscount = 0;
        tblCouponCode objCouponCode    = new tblCouponCode();

        objDataTable  = objCouponCode.CheckCouponCodeExists(txtCouponCode.Text);
        objCouponCode = null;
        if (objDataTable.Rows.Count > 0 && lblDiscount.Text == "")
        {
            //decprice = Convert.ToDecimal(SpanPrice.InnerText.ToString().Split('.')[1] + "." + SpanPrice.InnerText.ToString().Split('.')[2]);
            decprice         = Convert.ToDecimal(SpanPrice.InnerText.ToString().Split('.')[1]);
            decpricediscount = (Convert.ToDecimal(objDataTable.Rows[0][tblCouponCode.ColumnNames.AppDiscountPer].ToString()) * decprice) / 100;

            DataTable            dtTemp = new DataTable();
            tblCouponCodeProduct objCouponCodeProduct = new tblCouponCodeProduct();
            if (objDataTable.Rows[0][tblCouponCode.ColumnNames.AppType].ToString() == Convert.ToInt32(Enums.Enum_CouponCodeType.General).ToString())
            {
                lblCouponCode.Text      = "Price after discount: " + Convert.ToInt32(Math.Round((decprice - decpricediscount), 0));
                lblCouponCode.ForeColor = System.Drawing.Color.Green;
                hdnPriceDiscount.Value  = Convert.ToInt32(Math.Round(decpricediscount, 0)).ToString();
            }
            else if (objDataTable.Rows[0][tblCouponCode.ColumnNames.AppType].ToString() == Convert.ToInt32(Enums.Enum_CouponCodeType.Category).ToString())
            {
                dtTemp = objCouponCodeProduct.GetReferenceIDByCouponID(objDataTable.Rows[0][tblCouponCode.ColumnNames.AppCouponCodeID].ToString(), Convert.ToInt32(Enums.Enum_CouponCodeType.Category), hdnPKID.Value);
                objCouponCodeProduct = null;
                if (dtTemp.Rows.Count > 0)
                {
                    lblCouponCode.Text      = "Price after discount: " + Convert.ToInt32(Math.Round((decprice - decpricediscount), 0));
                    lblCouponCode.ForeColor = System.Drawing.Color.Green;
                    hdnPriceDiscount.Value  = Convert.ToInt32(Math.Round(decpricediscount, 0)).ToString();
                }
                else
                {
                    lblCouponCode.Text      = "This coupon code does not exist for this product.";
                    lblCouponCode.ForeColor = System.Drawing.Color.Red;
                    hdnPriceDiscount.Value  = "0";
                }
            }
            else if (objDataTable.Rows[0][tblCouponCode.ColumnNames.AppType].ToString() == Convert.ToInt32(Enums.Enum_CouponCodeType.SubCategory).ToString())
            {
                dtTemp = objCouponCodeProduct.GetReferenceIDByCouponID(objDataTable.Rows[0][tblCouponCode.ColumnNames.AppCouponCodeID].ToString(), Convert.ToInt32(Enums.Enum_CouponCodeType.SubCategory), hdnPKID.Value);
                objCouponCodeProduct = null;
                if (dtTemp.Rows.Count > 0)
                {
                    lblCouponCode.Text      = "Price after discount: " + Convert.ToInt32(Math.Round((decprice - decpricediscount), 0));
                    lblCouponCode.ForeColor = System.Drawing.Color.Green;
                    hdnPriceDiscount.Value  = Convert.ToInt32(Math.Round(decpricediscount, 0)).ToString();
                }
                else
                {
                    lblCouponCode.Text = "This coupon code does not exist for this product.";

                    lblCouponCode.ForeColor = System.Drawing.Color.Red;
                    hdnPriceDiscount.Value  = "0";
                }
            }
            else if (objDataTable.Rows[0][tblCouponCode.ColumnNames.AppType].ToString() == Convert.ToInt32(Enums.Enum_CouponCodeType.Product).ToString())
            {
                dtTemp = objCouponCodeProduct.GetReferenceIDByCouponID(objDataTable.Rows[0][tblCouponCode.ColumnNames.AppCouponCodeID].ToString(), Convert.ToInt32(Enums.Enum_CouponCodeType.Product), hdnPKID.Value);
                objCouponCodeProduct = null;
                if (dtTemp.Rows.Count > 0)
                {
                    lblCouponCode.Text      = "Price after discount: " + Convert.ToInt32(Math.Round((decprice - decpricediscount), 0));
                    lblCouponCode.ForeColor = System.Drawing.Color.Green;
                    hdnPriceDiscount.Value  = Convert.ToInt32(Math.Round(decpricediscount, 0)).ToString();
                }
                else
                {
                    lblCouponCode.Text      = "This coupon code does not exist for this product.";
                    lblCouponCode.ForeColor = System.Drawing.Color.Red;
                    hdnPriceDiscount.Value  = "0";
                }
            }
            objCouponCodeProduct = null;
            dtTemp = null;
        }
        else
        {
            hdnPriceDiscount.Value  = Convert.ToInt32(Math.Round(decpricediscount, 0)).ToString();
            lblCouponCode.Text      = "This coupon code does not exist for this product.";
            lblCouponCode.ForeColor = System.Drawing.Color.Red;
        }
    }