private bool SaveData() { objCommon = new clsCommon(); if (objCommon.IsRecordExists("tblDeal", tblDeal.ColumnNames.AppProductID, tblDeal.ColumnNames.AppDealID, ddlProduct.SelectedValue, hdnPKID.Value)) { DInfo.ShowMessage("Deal with this product already exists", Enums.MessageType.Error); return(false); } objDeal = new tblDeal(); if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objDeal.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); } else { objDeal.AddNew(); objDeal.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblDeal", tblDeal.ColumnNames.AppDisplayOrder); } objDeal.s_AppProductID = ddlProduct.SelectedValue; objDeal.AppTitle = txtTitle.Text; objDeal.AppDescription = txtDescription.Text; objDeal.AppDiscountPer = Convert.ToDecimal(txtDiscount.Text); objDeal.AppIsActive = chkIsActive.Checked; objDeal.Save(); intPkId = objDeal.AppDealID; objDeal = null; objCommon = null; return(true); }
private void SetValuesToControls() { if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objDeal = new tblDeal(); if (objDeal.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value))) { ddlProduct.SelectedValue = objDeal.s_AppProductID; txtTitle.Text = objDeal.AppTitle; txtDiscount.Text = objDeal.AppDiscountPer.ToString(); txtDescription.Text = objDeal.AppDescription; chkIsActive.Checked = objDeal.AppIsActive; objProduct = new tblProduct(); objDataTable = objProduct.LoadProductImageByProductID(objDeal.s_AppProductID); if (objDataTable.Rows.Count > 0) { img.Visible = true; img.ImageUrl = objDataTable.Rows[0][tblProductImage.ColumnNames.AppSmallImage].ToString(); } objProduct = null; } objDeal = null; } }
protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { objCommon = new clsCommon(); if (e.CommandName == "Up") { LinkButton inkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)inkButton.Parent.Parent; if (drCurrent.RowIndex > 0) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex - 1]; objCommon.SetDisplayOrder("tblDeal", tblDeal.ColumnNames.AppDealID, tblDeal.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]); LoadDataGrid(false, false); objCommon = null; } } else if (e.CommandName == "Down") { LinkButton lnkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)lnkButton.Parent.Parent; if (drCurrent.RowIndex < dgvGridView.Rows.Count - 1) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex + 1]; objCommon.SetDisplayOrder("tblDeal", tblDeal.ColumnNames.AppDealID, tblDeal.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]); LoadDataGrid(false, false); objCommon = null; } } else if (e.CommandName == "IsActive") { objDeal = new tblDeal(); if (objDeal.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()))) { if (objDeal.AppIsActive == true) { objDeal.AppIsActive = false; } else if (objDeal.AppIsActive == false) { objDeal.AppIsActive = true; } objDeal.Save(); LoadDataGrid(false, false); } objDeal = null; } } }
public void LoadBestDeal() { objDeal = new tblDeal(); objDataTable = objDeal.LoadBestDeal(); dicBestDeal.Style.Add("display", "block"); divDeal.Visible = true; if (objDataTable.Rows.Count <= 0) { dicBestDeal.Visible = false; divDeal.Visible = false; } rptBestDeal.DataSource = objDataTable; rptBestDeal.DataBind(); objDeal = null; }
private void LoadDataGrid(bool IsResetPageIndex, bool IsSort, string strFieldName = "", string strFieldValue = "") { objDeal = new tblDeal(); objDataTable = objDeal.LoadGridData(ddlFields.SelectedValue, txtSearch.Text.Trim()); //'Reset PageIndex of gridviews if (IsResetPageIndex) { if (dgvGridView.PageCount > 0) { dgvGridView.PageIndex = 0; } } dgvGridView.DataSource = null; dgvGridView.DataBind(); lblCount.Text = 0.ToString(); hdnSelectedIDs.Value = ""; //'Check for data into datatable 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(); } objDeal = null; }
private bool Delete(int intPKID) { bool retval = false; objDeal = new tblDeal(); var _with1 = objDeal; if (_with1.LoadByPrimaryKey(intPKID)) { _with1.MarkAsDeleted(); _with1.Save(); } retval = true; objDeal = null; return(retval); }