Ejemplo n.º 1
0
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdEdit")
            {
                Response.Redirect("EmployeeSalry.aspx?EmpSal=" + e.CommandArgument, true);
            }
            else if (e.CommandName == "cmdstatus")
            {
                EmployeeSalaryDAL objemp = new EmployeeSalaryDAL();
                int      EmpSal_ID       = 0;
                bool     bStatus         = false;
                string[] strStatus       = Convert.ToString(e.CommandArgument).Split(new char[] { '_' });
                if (strStatus.Length > 1)
                {
                    EmpSal_ID = Convert.ToInt32(strStatus[0]);
                    if (Convert.ToBoolean(strStatus[1]) == true)
                    {
                        bStatus = false;
                    }
                    else
                    {
                        bStatus = true;
                    }

                    Int32 value = objemp.UpdateStatus(EmpSal_ID, bStatus);

                    if (value > 0)
                    {
                        this.BindGrid();
                        ShowMessage("Status updated successfully.");
                    }
                    else
                    {
                        ShowMessageErr("Status not updated!");
                    }
                }
            }
            else if (e.CommandName == "cmddelete")
            {
                EmployeeSalaryDAL objsal   = new EmployeeSalaryDAL();
                Int32             intValue = objsal.Delete(Convert.ToInt32(e.CommandArgument));

                if (intValue > 0)
                {
                    this.BindGrid();
                    ShowMessage("Record deleted successfully.");
                }
                else
                {
                    ShowMessage("Record not deleted!");
                }
            }
        }
Ejemplo n.º 2
0
        private void BindEmployees()
        {
            EmployeeSalaryDAL objemp = new EmployeeSalaryDAL();
            var lst = objemp.FetchEmployeeName();

            ddlEmpName.DataSource     = lst;
            ddlEmpName.DataTextField  = "Acnt_Name";
            ddlEmpName.DataValueField = "Acnt_Idno";
            ddlEmpName.DataBind();
            ddlEmpName.Items.Insert(0, new ListItem("< Choose emp name >", "0"));
        }
Ejemplo n.º 3
0
        private void BindGrid()
        {
            EmployeeSalaryDAL objSalry   = new EmployeeSalaryDAL();
            string            strEmpName = txtEmpName.Text.Trim();

            var lstGridData = objSalry.SelectForSearch(strEmpName);

            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("EmpSal_ID", typeof(string));
                dt.Columns.Add("Acnt_Name", typeof(string));
                dt.Columns.Add("EmpSal_Salary", typeof(string));
                dt.Columns.Add("EmpSal_Year", typeof(string));
                dt.Columns.Add("EmpSal_Status", typeof(string));

                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["EmpSal_ID"]     = Convert.ToString(i + 1);
                    dr["Acnt_Name"]     = Convert.ToString(DataBinder.Eval(lstGridData[i], "Acnt_Name"));
                    dr["EmpSal_Salary"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "EmpSal_Salary"));
                    dr["EmpSal_Year"]   = Convert.ToString(DataBinder.Eval(lstGridData[i], "EmpSal_Year"));
                    dr["EmpSal_Status"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "EmpSal_Status"));

                    dt.Rows.Add(dr);
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }
                //
                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record(s): " + lstGridData.Count;

                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();
                lblcontant.Visible  = true;
                imgBtnExcel.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;
            }
        }
Ejemplo n.º 4
0
        private void PopulateEmpDetl(Int32 EmpID)
        {
            EmployeeSalaryDAL objEmpSal = new EmployeeSalaryDAL();
            var vartblEmpSal            = objEmpSal.SelectEmployeeDetailAtEditTime(EmpID);

            if (vartblEmpSal != null)
            {
                ddlEmpName.SelectedValue = Convert.ToString(DataBinder.Eval(vartblEmpSal[0], "EmpSal_EmpID"));
                txtSalary.Text           = Convert.ToString(DataBinder.Eval(vartblEmpSal[0], "EmpSal_Salary"));
                ddlMonth.SelectedValue   = Convert.ToString(DataBinder.Eval(vartblEmpSal[0], "EmpSal_Month"));
                ddlYear.SelectedValue    = Convert.ToString(DataBinder.Eval(vartblEmpSal[0], "EmpSal_Year"));

                chkStatus.Checked = Convert.ToBoolean(DataBinder.Eval(vartblEmpSal[0], "EmpSal_Status"));
            }
        }
Ejemplo n.º 5
0
        protected void lnkbtnSave_OnClick(object sender, EventArgs e)
        {
            EmployeeSalaryDAL Empobj  = new EmployeeSalaryDAL();
            Int64             value   = 0;
            string            Date    = DateTime.Now.Date.ToString("dd-MM-yyyy");
            DateTime          DateAdd = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Date));

            using (TransactionScope dbTran = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    if (string.IsNullOrEmpty(hdnQry.Value) == true)
                    {
                        value = Empobj.InsertEmployeeDetl(Convert.ToInt64(ddlEmpName.SelectedValue), Convert.ToDouble(txtSalary.Text.Trim()), Convert.ToInt32(ddlMonth.SelectedValue), Convert.ToInt32(ddlYear.SelectedValue), chkStatus.Checked, DateAdd);
                    }
                    else
                    {
                        value = Empobj.UpdateEmployeeDetl(Convert.ToInt64(hdnQry.Value), Convert.ToInt64(ddlEmpName.SelectedValue), Convert.ToDouble(txtSalary.Text.Trim()), Convert.ToInt32(ddlMonth.SelectedValue), Convert.ToInt32(ddlYear.SelectedValue), chkStatus.Checked, DateAdd);
                    }


                    if (value > 0)
                    {
                        if (string.IsNullOrEmpty(hdnQry.Value) == true)
                        {
                            ShowMessage("Records successfully inserted.");
                        }
                        else
                        {
                            lnkbtnNew.Visible = false;
                            ShowMessage("Records successfully updated.");
                        }
                        dbTran.Complete();
                        this.ClearAllData();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(hdnQry.Value) == true)
                        {
                            ShowMessageErr("Records not inserted!");
                        }
                        else
                        {
                            ShowMessageErr("Records not updated!");
                        }
                        dbTran.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    if (string.IsNullOrEmpty(hdnQry.Value) == true)
                    {
                        ShowMessageErr("Error in records inserting!");
                    }
                    else
                    {
                        ShowMessageErr("Error in Records updating!");
                    }
                }
            }
        }