Example #1
0
    //protected void btn_Upload_Click(object sender, EventArgs e)
    //{
    //    if (FUpload.HasFile)
    //    {
    //        string fileExt = System.IO.Path.GetExtension(FUpload.FileName);

    //        if (fileExt == ".jpeg" || fileExt == ".jpg" || fileExt == ".png")
    //        {
    //            if (FUpload.HasFile)
    //            {
    //                strPath = "~/Recruitment/RecCostPics/" + FUpload.FileName;
    //                FUpload.PostedFile.SaveAs(Server.MapPath("~/Recruitment/RecCostPics/") + FUpload.FileName); //+ txt_AppLastName.Text
    //                RBI_BU_Image.ImageUrl = strPath;
    //                RBI_BU_Image.Visible = true;
    //                lblMsg.Visible = true;
    //                lblMsg.Text = Convert.ToString(strPath);
    //            }
    //            else
    //            {
    //                BLL.ShowMessage(this, "Please Upload Image");
    //                return;
    //            }
    //        }
    //        else
    //        {
    //            BLL.ShowMessage(this, "Only .jpeg and .png files are allowed!");
    //        }
    //    }
    //    else
    //    {
    //        BLL.ShowMessage(this, "You have not specified a file");
    //    }
    //}

    protected void BTN_SAVE_Click(object sender, EventArgs e)
    {
        try
        {
            bool status = false;

            DataTable dtRecCostExists = new DataTable();

            if (lblMsg.Text == string.Empty)
            {
                BLL.ShowMessage(this, "Please Select a File to Upload..");
                return;
            }

            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_SAVE":
                _obj_smhr_recruitment_cost.OPERATION     = operation.Insert;
                _obj_smhr_recruitment_cost.COST_REQ_ID   = Convert.ToInt32(rcmb_RscReq.SelectedValue);
                _obj_smhr_recruitment_cost.COST_TYPE_ID  = Convert.ToInt32(rad_TypCost.SelectedValue);
                _obj_smhr_recruitment_cost.COST_FILEPATH = Convert.ToString(lblMsg.Text);
                _obj_smhr_recruitment_cost.COST_AMOUNT   = Convert.ToDouble(rad_Amount.Text);
                _obj_smhr_recruitment_cost.COST_DATE     = Convert.ToDateTime(rdtp_Date.SelectedDate);
                _obj_smhr_recruitment_cost.CREATEDBY     = Convert.ToInt32(Session["USER_ID"]);
                _obj_smhr_recruitment_cost.CREATEDDATE   = DateTime.Now;
                _obj_smhr_recruitment_cost.BUID          = Convert.ToInt32(Rcb_BusinessUnit.SelectedValue);

                dtRecCostExists = Recruitment_BLL.checkRecCostExists(_obj_smhr_recruitment_cost);

                if (Convert.ToInt32(dtRecCostExists.Rows[0]["COUNT"]) == 0)
                {
                    status = Recruitment_BLL.set_SMHR_RECRUITMENT_COST(_obj_smhr_recruitment_cost);

                    if (status == true)
                    {
                        BLL.ShowMessage(this, "Information Successfully Saved");
                    }
                }
                else
                {
                    BLL.ShowMessage(this, "This Record Already Exists");
                    return;
                }
                break;

            case "BTN_UPDATE":

                _obj_smhr_recruitment_cost.OPERATION     = operation.Update;
                _obj_smhr_recruitment_cost.COST_ID       = Convert.ToInt32(ViewState["COST_ID"]);
                _obj_smhr_recruitment_cost.COST_REQ_ID   = Convert.ToInt32(rcmb_RscReq.SelectedValue);
                _obj_smhr_recruitment_cost.COST_TYPE_ID  = Convert.ToInt32(rad_TypCost.SelectedValue);
                _obj_smhr_recruitment_cost.COST_FILEPATH = Convert.ToString(lblMsg.Text);
                _obj_smhr_recruitment_cost.COST_AMOUNT   = Convert.ToDouble(rad_Amount.Text);
                _obj_smhr_recruitment_cost.COST_DATE     = Convert.ToDateTime(rdtp_Date.SelectedDate);
                _obj_smhr_recruitment_cost.LASTMDFBY     = Convert.ToInt32(Session["USER_ID"]);
                _obj_smhr_recruitment_cost.LASTMDFDATE   = DateTime.Now;

                status = Recruitment_BLL.set_SMHR_RECRUITMENT_COST(_obj_smhr_recruitment_cost);

                if (status == true)
                {
                    BLL.ShowMessage(this, "Information Updated Successfully");
                }

                break;
            }
            Rm_HDPT_page.SelectedIndex = 0;
            LoadRecruitmentCostGrid();
            Rg_RecmntCost.DataBind();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_RecruitmentCost", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }