protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { objCommon = new clsCommon(); hdnPKID.Value = e.CommandArgument.ToString(); 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("tblBanner", tblBanner.ColumnNames.AppBannerID, tblBanner.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("tblBanner", tblBanner.ColumnNames.AppBannerID, tblBanner.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") { objBanner = new tblBanner(); if (objBanner.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value))) { if (objBanner.AppIsActive == true) { objBanner.AppIsActive = false; } else if (objBanner.AppIsActive == false) { objBanner.AppIsActive = true; } objBanner.Save(); LoadDataGrid(false, false, "", ""); } objBanner = null; } } }
private bool SaveData() { if (FileUploadImg.HasFile) { objClsCommon = new clsCommon(); objBanner = new tblBanner(); if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objBanner.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); } else { objBanner.AddNew(); objBanner.AppDisplayOrder = objClsCommon.GetNextDisplayOrder("tblBanner", tblBanner.ColumnNames.AppDisplayOrder); } objBanner.AppTitle = txtBannerTitle.Text; objBanner.AppIsActive = chkIsActive.Checked; objBanner.AppUrl = txtappUrl.Text; objBanner.AppDescription = txtDescription.Text; if (FileUploadImg.HasFile) { string strError = ""; string Time = Convert.ToString(DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second); string strPath = objClsCommon.FileUpload_Images(FileUploadImg.PostedFile, txtBannerTitle.Text.Trim().Replace(" ", "_") + "_" + Time, "Uploads/Banner/", ref strError, 0, objBanner.s_AppImage, false, 600, 1600); if (strError == "") { objBanner.AppImage = strPath; } else { DInfo.ShowMessage(strError, Enums.MessageType.Error); return(false); } } objBanner.Save(); iBannerID = objBanner.AppBannerID; objBanner = null; objClsCommon = null; return(true); } else { DInfo.ShowMessage("Select Image First", Enums.MessageType.Error); return(false); } }