Example #1
0
    protected void onEdit(object source, CommandEventArgs e)
    {
        ImageButton Imgbtn = (ImageButton)source;

        int    rowcount      = ucCustomPagerItems.isCountRecord;
        string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
        int?   sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
        {
            sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
        }


        BLL_Crew_Admin objBLL = new BLL_Crew_Admin();
        DataTable      dt     = objBLL.CRUD_OilMajors("", "", "R", 0, Convert.ToInt32(Imgbtn.Attributes["rel"]), "", sortbycoloumn, sortdirection
                                                      , ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, txtRemarks.Text, 0, "", ref rowcount, ref Result);
        string imagefile = "";

        if (dt.Rows.Count > 0)
        {
            hdnOilMajorID.Value  = Convert.ToString(dt.Rows[0]["ID"]);
            txtOilMajorName.Text = Convert.ToString(dt.Rows[0]["Oil_Major_Name"]);
            txtDisplayName.Text  = Convert.ToString(dt.Rows[0]["Display_Name"]);
            txtRemarks.Text      = Convert.ToString(dt.Rows[0]["Remarks"]);
            imagefile            = Convert.ToString(dt.Rows[0]["Oil_Major_Logo"]);

            string[]        filePaths = Directory.GetFiles(Server.MapPath("~/Uploads/OilMajorLogo/"));
            List <ListItem> files     = new List <ListItem>();
            string          fileName  = Path.GetFileName(imagefile);
            files.Add(new ListItem(fileName, "~/Uploads/OilMajorLogo/" + fileName));
        }

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "EditControl", " $(\"#divadd_dvModalPopupTitle\").text(\"Add/Edit Oil Major\"); showModal('divadd', false);", true);
    }
Example #2
0
    /// <summary>
    /// Delete Oil Major
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void onDelete(object source, CommandEventArgs e)
    {
        try
        {
            int            rowcount = 0;
            BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
            DataTable      dt       = objBLL.CRUD_OilMajors("", "", "D", GetSessionUserID(), Convert.ToInt32(e.CommandArgument.ToString()), null, "", null, null, null, "", 0, "", ref rowcount, ref Result);
            if (Result > 0)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ShowMessage", "alert('Record deleted successfully')", true);
            }

            BindOilMajors();
        }
        catch (Exception ex) { UDFLib.WriteExceptionLog(ex); }
    }
Example #3
0
    /// <summary>
    /// Bind Oil Majors
    /// </summary>
    public void BindOilMajors()
    {
        try
        {
            int rowcount = ucCustomPagerItems.isCountRecord;

            string sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
            int?   sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
            {
                sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
            }

            BLL_Crew_Admin objBLL = new BLL_Crew_Admin();
            DataTable      dt     = objBLL.CRUD_OilMajors("", "", "R", 0, 0, txtfilter.Text != "" ? txtfilter.Text.Trim() : null, sortbycoloumn, sortdirection
                                                          , ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, txtRemarks.Text, 0, "", ref rowcount, ref Result);


            if (ucCustomPagerItems.isCountRecord == 1)
            {
                ucCustomPagerItems.CountTotalRec = rowcount.ToString();
                ucCustomPagerItems.BuildPager();
            }
            gvOilMajors.DataSource = dt;
            gvOilMajors.DataBind();

            if (dt.Rows.Count > 0)
            {
                ImgExpExcel.Visible = true;
            }
            else
            {
                ImgExpExcel.Visible = false;
            }
        }
        catch (Exception ex) { UDFLib.WriteExceptionLog(ex); }
    }
Example #4
0
    /// <summary>
    /// To save or update oil major
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnsave_OnClick(object sender, EventArgs e)
    {
        string path         = "";
        int    ActiveStatus = 0;

        if (chkIsActive.Checked == true)
        {
            ActiveStatus = 1;
        }
        else
        {
            ActiveStatus = 0;
        }
        try
        {
            if (hdnUploadFileName.Value != "")
            {
                FileInfo fn       = new FileInfo(hdnUploadFileName.Value);
                Guid     gid      = Guid.NewGuid();
                string   filename = "OLM_" + gid + fn.Extension;
                path = "~/Uploads/OilMajorLogo/" + filename;

                FileUpload1.SaveAs(Server.MapPath("~/Uploads/OilMajorLogo/" + filename));
            }
            if (txtDisplayName.Text == "")
            {
                txtDisplayName.Text = txtOilMajorName.Text.Trim();
            }
            if (Convert.ToInt32(hdnOilMajorID.Value) > 0)
            {
                OperationMode = "Add/Edit Oil Major";

                int            rowcount = 0;
                BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
                DataTable      dt       = objBLL.CRUD_OilMajors(txtOilMajorName.Text.Trim(), txtDisplayName.Text.Trim(), "U", GetSessionUserID(), Convert.ToInt32(hdnOilMajorID.Value), null, "", null, null, null, txtRemarks.Text, ActiveStatus, path, ref rowcount, ref Result);

                ///Result == 2 Already exists
                if (Result < 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("InformationMessage/DataExists") + "');showModal('divadd', false);", true);
                }
                if (Result > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/UpdateMessage") + "');hideModal('divadd');", true);
                    hdnUploadFileName.Value = "";
                    BindOilMajors();
                }
            }
            else
            {
                OperationMode = "Add Oil Major";
                int            rowcount = 0;
                BLL_Crew_Admin objBLL   = new BLL_Crew_Admin();
                DataTable      dt       = objBLL.CRUD_OilMajors(txtOilMajorName.Text.Trim(), txtDisplayName.Text.Trim(), "I", GetSessionUserID(), 0, null, "", null, null, null, txtRemarks.Text, ActiveStatus, path, ref rowcount, ref Result);

                ///Result == 2 Already exists
                if (Result < 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("InformationMessage/DataExists") + "');showModal('divadd', false);", true);
                }
                if (Result > 0)
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlreadyExists", "alert('" + UDFLib.GetException("SuccessMessage/SaveMessage") + "');hideModal('divadd');", true);
                    BindOilMajors();
                }
            }
            // it will clear all the values and avoid adding the Duplicate records !Desc:- when one intend to page refreseh ,javascript alert msg raise, says it will perform the same action again,so value might gets duplicate , so we can avoid this by below code
            //Response.Redirect(Request.Url.AbsoluteUri);
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }