Example #1
0
    protected void SaveData(string IsDelete)
    {
        int intFmID = grEmpFamilyInfo.Rows.Count + 1;

        if (hfIsUpadate.Value == "N")
        {
            hfFmId.Value = intFmID.ToString();
        }
        clsEmpFamilyInfo objFam = new clsEmpFamilyInfo(txtEmpID.Text, hfFmId.Value, txtName.Text,
                                                       txtOccupation.Text, ddlRelation.SelectedValue, txtDob.Text, ddlBloodGroup.SelectedValue,
                                                       chkIsDependant.Checked == true ? "Y" : "N",
                                                       Session["USERID"].ToString(), Common.SetDate(DateTime.Now.ToString()),
                                                       txtInsID.Text.Trim(), txtIncusionDate.Text.Trim(), txtRenewalDate.Text.Trim(), hfFmImage.Value.ToString());

        EmpFamilyManager objFamilyMgr = new EmpFamilyManager();

        objFamilyMgr.InsertEmpFamily(objFam, hfIsUpadate.Value, IsDelete);
        if (hfIsUpadate.Value == "N")
        {
            lblMsg.Text = "Record Saved Successfully";
        }
        else
        {
            lblMsg.Text = "Record Updated Successfully";
        }
        this.EntryMode(false);
        this.OpenRecord();
    }
Example #2
0
    protected void grEmpFamilyInfo_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView _gridView = (GridView)sender;
        // Get the selected index and the command name
        int    _selectedIndex = int.Parse(e.CommandArgument.ToString());
        string _commandName   = e.CommandName;

        _gridView.SelectedIndex = _selectedIndex;
        switch (_commandName)
        {
        case ("DoubleClick"):
            hfFmId.Value     = grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[1].ToString().Trim();
            txtName.Text     = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[2].Text);
            ddlRelation.Text = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[3].Text);
            if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[4].Text.Trim()) != "")
            {
                txtDob.Text = grEmpFamilyInfo.SelectedRow.Cells[4].Text;
            }
            chkIsDependant.Checked = (grEmpFamilyInfo.SelectedRow.Cells[5].Text == "Y" ? true:false);
            txtInsID.Text          = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[6].Text.Trim());
            if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[7].Text.Trim()) != "")
            {
                txtIncusionDate.Text = grEmpFamilyInfo.SelectedRow.Cells[7].Text.Trim();
            }
            if (Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[8].Text.Trim()) != "")
            {
                txtRenewalDate.Text = grEmpFamilyInfo.SelectedRow.Cells[8].Text.Trim();
            }
            hfFmImage.Value = Common.CheckNullString(grEmpFamilyInfo.SelectedRow.Cells[9].Text.Trim());

            if (string.IsNullOrEmpty(hfFmImage.Value) == false)
            {
                imgEmp.ImageUrl = "~/EmployeeImage/" + hfFmImage.Value;
                //hfEmpImage.Value = string.IsNullOrEmpty(tt["EmpPicLoc"].ToString().Trim()) == true ? "" : tt["EmpPicLoc"].ToString().Trim();
            }
            else
            {
                imgEmp.ImageUrl = "~/EmployeeImage/NoImage.jpg";
                hfFmImage.Value = "";
            }
            this.EntryMode(true);
            break;

        case ("RowDeleting"):
            clsEmpFamilyInfo objFam = new clsEmpFamilyInfo(grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[0].ToString().Trim(),
                                                           grEmpFamilyInfo.DataKeys[_gridView.SelectedIndex].Values[1].ToString().Trim(), grEmpFamilyInfo.SelectedRow.Cells[2].Text,
                                                           grEmpFamilyInfo.SelectedRow.Cells[3].Text, grEmpFamilyInfo.SelectedRow.Cells[4].Text,
                                                           grEmpFamilyInfo.SelectedRow.Cells[5].Text, grEmpFamilyInfo.SelectedRow.Cells[6].Text,
                                                           grEmpFamilyInfo.SelectedRow.Cells[7].Text, Session["USERID"].ToString(), Common.SetDate(DateTime.Now.ToString()), txtInsID.Text.Trim(),
                                                           txtIncusionDate.Text.Trim(), txtRenewalDate.Text.Trim(), hfFmImage.Value.ToString());

            EmpFamilyManager objMgr = new EmpFamilyManager();
            objMgr.InsertEmpFamily(objFam, "N", "Y");
            if (string.IsNullOrEmpty(hfFmImage.Value) == false)
            {
                string FolderPath = ConfigurationManager.AppSettings["EmployeeImagePath"];
                string FileName   = hfFmImage.Value.ToString();
                //string Extension = Path.GetExtension(FileName);
                string   FilePath = Server.MapPath(FolderPath + FileName);
                FileInfo File     = new FileInfo(FilePath);
                File.Delete();
                imgEmp.ImageUrl = "";
                hfFmImage.Value = "";
            }
            this.EntryMode(false);
            this.OpenRecord();
            break;
        }
    }