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; } } }