Esempio n. 1
0
        protected void lnkbtnSaveGroup_OnClick(object sender, EventArgs e)
        {
            string          strMsg             = string.Empty;
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            Int64           intIGrpIdno        = 0;
            int             IGrpType           = Convert.ToInt32(ddlItemGropForPopup.SelectedValue);
            Int32           empIdno            = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());

            intIGrpIdno = objclsItmGrpMaster.Insert(txtGroupNameForPopup.Text.Trim(), IGrpType, true, empIdno);

            objclsItmGrpMaster = null;
            if (intIGrpIdno > 0)
            {
                BindGroupType();
                strMsg = "Record saved successfully.";

                this.ClearControlsForGroup();
            }
            else if (intIGrpIdno < 0)
            {
                strMsg = "Record already exists.";
            }
            else
            {
                strMsg = "Record not saved.";
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
        }
        protected void lnkgrpsave_Click(object sender, EventArgs e)
        {
            Int32           empIdno            = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string          strMsg             = string.Empty;
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            Int64           intIGrpIdno        = 0;
            int             IGrpType           = 0;

            if (txtGName.Text != "")
            {
                intIGrpIdno = objclsItmGrpMaster.Insert(txtGName.Text.Trim(), IGrpType, Convert.ToBoolean(chkactive.Checked), empIdno);
            }

            if ((intIGrpIdno > 0))
            {
                strMsg        = "Record saved successfully";
                txtGName.Text = "";
                BindGroupType();
                ddlGroupType.SelectedValue = Convert.ToString(intIGrpIdno);
                ddlGroupType.Focus();
            }
            else if (intIGrpIdno == -1)
            {
                strMsg = "Record already exists!";
            }
            else
            {
                strMsg = "Oops technical error occurs!";
            }
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
        }
        private void BindGrid()
        {
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            var             lstGridData        = objclsItmGrpMaster.SelectAll(Convert.ToString(txtGName.Text.Trim()));

            objclsItmGrpMaster = null;

            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("S.No", typeof(string));
                dt.Columns.Add("Item Group Name", typeof(string));
                dt.Columns.Add("Status", typeof(string));
                int c = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["S.No"]            = ++c;
                    dr["Item Group Name"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "IGrp_Name"));
                    if (Convert.ToBoolean(DataBinder.Eval(lstGridData[i], "Status")) == true)
                    {
                        dr["Status"] = "Active";
                    }
                    else
                    {
                        dr["Status"] = "Inactive";
                    }
                    dt.Rows.Add(dr);
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }


                grdMain.DataSource = lstGridData;
                grdMain.DataBind();

                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString();

                lblTotalRecord.Text = "T. Record(s): " + lstGridData.Count;
                imgBtnExcel.Visible = true;
                lblcontant.Visible  = true;
                divpaging.Visible   = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record(s): 0 ";
                imgBtnExcel.Visible = false;
                lblcontant.Visible  = false;
                divpaging.Visible   = false;
            }
        }
        public void BindItemType()
        {
            ItmGrpMasterDAL objDAL = new ItmGrpMasterDAL();
            var             Lst    = objDAL.BindItemType();

            if (Lst != null && Lst.Count > 0)
            {
                ddlItemType.DataSource     = Lst;
                ddlItemType.DataTextField  = "ItemName";
                ddlItemType.DataValueField = "ItemType";
                ddlItemType.DataBind();
                ddlItemType.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
            }
        }
        /// <summary>
        /// To Populate Data
        /// </summary>
        /// <param name="ColrIdno"></param>
        private void Populate(int IGrpIdno)
        {
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            var             objIgrpMast        = objclsItmGrpMaster.SelectById(IGrpIdno);

            objclsItmGrpMaster = null;
            if (objIgrpMast != null)
            {
                txtGName.Text             = Convert.ToString(objIgrpMast.IGrp_Name);
                ddlItemType.SelectedValue = Convert.ToString(objIgrpMast.IGrp_Type);
                //  ddlGroupType.SelectedValue = Convert.ToString(objIgrpMast.IGrp_Type);
                chkStatus.Checked     = Convert.ToBoolean(objIgrpMast.Status);
                hidIGrpMastidno.Value = Convert.ToString(objIgrpMast.IGrp_Idno);
                // ddlGroupType.Focus();
            }
        }
        protected void lnkbtnSave_OnClick(object sender, EventArgs e)
        {
            Int32           empIdno            = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
            string          strMsg             = string.Empty;
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            Int64           intIGrpIdno        = 0;
            int             IGrpType           = Convert.ToInt32(ddlItemType.SelectedValue);

            if (string.IsNullOrEmpty(hidIGrpMastidno.Value) == true)
            {
                intIGrpIdno = objclsItmGrpMaster.Insert(txtGName.Text.Trim(), IGrpType, Convert.ToBoolean(chkStatus.Checked), empIdno);
            }
            else
            {
                intIGrpIdno = objclsItmGrpMaster.Update(txtGName.Text.Trim(), IGrpType, Convert.ToBoolean(chkStatus.Checked), Convert.ToInt32(hidIGrpMastidno.Value), empIdno);
            }
            objclsItmGrpMaster = null;
            if (intIGrpIdno > 0)
            {
                if (string.IsNullOrEmpty(hidIGrpMastidno.Value) == false)
                {
                    ShowMessage("Record updated successfully.");
                }
                else
                {
                    ShowMessage("Record saved successfully.");
                }
                this.ClearControls();
                lnkbtnNew.Visible = false;
            }
            else if (intIGrpIdno < 0)
            {
                ShowMessageErr("Record already exists.");
            }
            else
            {
                if (string.IsNullOrEmpty(hidIGrpMastidno.Value) == false)
                {
                    ShowMessageErr("Record not updated.");
                }
                else
                {
                    ShowMessageErr("Record not saved.");
                }
            }
        }
        protected void grdMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgBtnStatus = (ImageButton)e.Row.FindControl("imgBtnStatus");
                bool        status       = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "Status"));

                // Used to hide Delete button if ItemgrpId exists in Item Master,Fleet Mgmt ItemMast
                ImageButton lnkbtnDelete = (ImageButton)e.Row.FindControl("lnkbtnDelete");
                string      IGrpIdno     = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "IGrp_Idno"));
                if (IGrpIdno != "")
                {
                    ItmGrpMasterDAL obj = new ItmGrpMasterDAL();
                    var             ItemGrpExistInItemMast = obj.CheckItemGrpExistInItemMaster(Convert.ToInt32(IGrpIdno));
                    if (ItemGrpExistInItemMast != null && ItemGrpExistInItemMast.Count > 0)
                    {
                        lnkbtnDelete.Visible = false;
                    }
                    else
                    {
                        lnkbtnDelete.Visible = true;
                    }
                }
                // end----

                imgBtnStatus.Visible = true;

                if (status == false)
                {
                    imgBtnStatus.ImageUrl = "~/Images/inactive.png";
                }
                else
                {
                    imgBtnStatus.ImageUrl = "~/Images/active.png";
                }
            }
        }
Esempio n. 8
0
        protected void imgBtnSave_Click(object sender, EventArgs e)
        {
            string          strMsg             = string.Empty;
            ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
            Int64           intIGrpIdno        = 0;
            int             IGrpType           = Convert.ToInt32(ddlItemType.SelectedValue);
            Int32           empIdno            = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());

            intIGrpIdno = objclsItmGrpMaster.Insert(txtGName.Text.Trim(), IGrpType, Convert.ToBoolean(chkStatus.Checked), empIdno);

            objclsItmGrpMaster = null;
            if (intIGrpIdno > 0)
            {
                //lnkbtnNew.Visible = false;
            }
            else if (intIGrpIdno < 0)
            {
                strMsg = "Record already exists.";
            }
            else
            {
                strMsg = "Record not saved.";
            }
        }
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("ItmGrpMaster.aspx?IGrp_Idno=" + e.CommandArgument, true);
            }
            else if (e.CommandName == "cmddelete")
            {
                ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
                Int32           intValue           = objclsItmGrpMaster.Delete(Convert.ToInt32(e.CommandArgument));
                objclsItmGrpMaster = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    //  ddlGroupType.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                this.BindGrid();
            }
            else if (e.CommandName == "cmdstatus")
            {
                Int32    empIdno     = Convert.ToInt32((Session["UserIdno"] == null) ? "0" : Session["UserIdno"].ToString());
                int      intIGrpIdno = 0;
                bool     bStatus     = false;
                string[] strStatus   = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strStatus.Length > 1)
                {
                    intIGrpIdno = Convert.ToInt32(strStatus[0]);
                    if (Convert.ToBoolean(strStatus[1]) == true)
                    {
                        bStatus = false;
                    }
                    else
                    {
                        bStatus = true;
                    }
                    ItmGrpMasterDAL objclsItmGrpMaster = new ItmGrpMasterDAL();
                    int             value = objclsItmGrpMaster.UpdateStatus(intIGrpIdno, bStatus, empIdno);
                    objclsItmGrpMaster = null;
                    if (value > 0)
                    {
                        this.BindGrid();
                        strMsg = "Status updated successfully.";
                        //ddlGroupType.Focus();
                    }
                    else
                    {
                        strMsg = "Status not updated.";
                    }
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
                }
            }
            //ddlGroupType.Focus();
        }