public static HR_OthersDocuments GetHR_OthersDocumentsByOthersDocumentsID(int OthersDocumentsID)
 {
     HR_OthersDocuments hR_OthersDocuments = new HR_OthersDocuments();
     SqlHR_OthersDocumentsProvider sqlHR_OthersDocumentsProvider = new SqlHR_OthersDocumentsProvider();
     hR_OthersDocuments = sqlHR_OthersDocumentsProvider.GetHR_OthersDocumentsByOthersDocumentsID(OthersDocumentsID);
     return hR_OthersDocuments;
 }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        HR_OthersDocuments hR_OthersDocuments = new HR_OthersDocuments ();
        hR_OthersDocuments.OthersDocumentsID=  int.Parse(Request.QueryString["ID"].ToString());
        hR_OthersDocuments.EmployeeID = Profile.card_id;
        hR_OthersDocuments.DocumentsType = ddlDocumentType.SelectedValue;
        //hR_OthersDocuments.DocumentName=  txtDocumentName.Text;
        if (uplFile.PostedFile != null && uplFile.PostedFile.ContentLength > 0)
        {
        //try
        //{
            string dirUrl = "../HR/upload/employeer";
            string dirPath = Server.MapPath(dirUrl);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            string fileName = Path.GetFileName(uplFile.PostedFile.FileName);
            string fileUrl = dirUrl + "/" + Path.GetFileName(uplFile.PostedFile.FileName);
            string filePath = Server.MapPath(fileUrl);
            uplFile.PostedFile.SaveAs(filePath);

            hR_OthersDocuments.DocumentName = dirUrl + "/" + fileName;
        //}
        //catch (Exception ex)
        //{
        //    lblMessage.Text = ex.Message.ToString();
        //    lblMessage.Text = lblMessage.Text + "<br />Please rename your file. ";
        //}
        }
        else
        {
        hR_OthersDocuments.DocumentName = hR_OthersDocuments.DocumentName;
        }
        hR_OthersDocuments.AddedBy=  Profile.card_id;
        hR_OthersDocuments.AddedDate=  DateTime.Now;
        hR_OthersDocuments.ModifiedBy=  Profile.card_id;
        hR_OthersDocuments.ModifiedDate=  DateTime.Now;
        bool  resutl =HR_OthersDocumentsManager.UpdateHR_OthersDocuments(hR_OthersDocuments);
        Response.Redirect("AdminDisplayHR_OthersDocuments.aspx");
    }
    public bool UpdateHR_OthersDocuments(HR_OthersDocuments hR_OthersDocuments)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateHR_OthersDocuments", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@OthersDocumentsID", SqlDbType.Int).Value = hR_OthersDocuments.OthersDocumentsID;
            cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = hR_OthersDocuments.EmployeeID;
            cmd.Parameters.Add("@DocumentsType", SqlDbType.NVarChar).Value = hR_OthersDocuments.DocumentsType;
            cmd.Parameters.Add("@DocumentName", SqlDbType.NVarChar).Value = hR_OthersDocuments.DocumentName;
            cmd.Parameters.Add("@ModifiedBy", SqlDbType.NVarChar).Value = hR_OthersDocuments.ModifiedBy;
            cmd.Parameters.Add("@ModifiedDate", SqlDbType.DateTime).Value = hR_OthersDocuments.ModifiedDate;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
    public HR_OthersDocuments GetHR_OthersDocumentsFromReader(IDataReader reader)
    {
        try
        {
            HR_OthersDocuments hR_OthersDocuments = new HR_OthersDocuments
                (

                     DataAccessObject.IsNULL<int>(reader["OthersDocumentsID"]),
                     DataAccessObject.IsNULL<string>(reader["EmployeeID"].ToString()),
                     DataAccessObject.IsNULL<string>(reader["DocumentsType"]),
                     DataAccessObject.IsNULL<string>(reader["DocumentName"]),
                     DataAccessObject.IsNULL<string>(reader["AddedBy"].ToString()),
                     DataAccessObject.IsNULL<DateTime>(reader["AddedDate"]),
                     DataAccessObject.IsNULL<string>(reader["ModifiedBy"].ToString()),
                     DataAccessObject.IsNULL<DateTime>(reader["ModifiedDate"])
                );
             return hR_OthersDocuments;
        }
        catch(Exception ex)
        {
            return null;
        }
    }
Exemple #5
0
    protected void btnAddOtherDocuments_Click(object sender, EventArgs e)
    {
        if (hfEmployeeID.Value != null)
        {
            HR_OthersDocuments hR_OthersDocuments = new HR_OthersDocuments();
            //	hR_OthersDocuments.OthersDocumentsID=  int.Parse(ddlOthersDocumentsID.SelectedValue);
            hR_OthersDocuments.EmployeeID = hfEmployeeID.Value.ToString();
            hR_OthersDocuments.DocumentsType = ddlDocumentType.SelectedValue;
            //hR_OthersDocuments.DocumentName=  txtDocumentName.Text;

            if (uplFile.PostedFile != null && uplFile.PostedFile.ContentLength > 0)
            {
                //try
                //{
                string dirUrl = "../HR/upload/employeer";
                string dirPath = Server.MapPath(dirUrl);

                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }
                string fileName = Path.GetFileName(uplFile.PostedFile.FileName);

                string[] fileNameSpilt = fileName.Split('.');

                if (fileNameSpilt.Length == 2)
                {
                    if (fileNameSpilt[1] != "txt" && fileNameSpilt[1] != "pdf" && fileNameSpilt[1] != "doc" && fileNameSpilt[1] != "docx")
                    {
                        lblOtherDocumentsMessage.Text = "Document is not valid formated.(Valid documents are .txt, .pdf, .doc, .docx)";
                        lblOtherDocumentsMessage.ForeColor = System.Drawing.Color.Red;
                        return;
                    }
                }

                string fileUrl = dirUrl + "/" + Path.GetFileName(uplFile.PostedFile.FileName);
                string filePath = Server.MapPath(fileUrl);
                uplFile.PostedFile.SaveAs(filePath);

                hR_OthersDocuments.DocumentName = fileName;
                //}
                //catch (Exception ex)
                //{
                //    lblMessage.Text = ex.Message.ToString();
                //    lblMessage.Text = lblMessage.Text + "<br />Please rename your file. ";
                //}
            }
            else
            {
                hR_OthersDocuments.DocumentName = "Not loaded any document";
            }
            string userID = Profile.card_id;
            hR_OthersDocuments.AddedBy = userID;
            hR_OthersDocuments.AddedDate = DateTime.Now;
            hR_OthersDocuments.ModifiedBy = userID;
            hR_OthersDocuments.ModifiedDate = DateTime.Now;
            int resutl = HR_OthersDocumentsManager.InsertHR_OthersDocuments(hR_OthersDocuments);
            hdnOtherDocumentsID.Value = resutl.ToString();
            //Response.Redirect("AdminDisplayHR_OthersDocuments.aspx");
            lblOtherDocumentsMessage.Text = "Documents is saved";
            lblOtherDocumentsMessage.ForeColor = System.Drawing.Color.Green;
        }
        else
        {

            lblOtherDocumentsMessage.Text = "Employee is not specified.";
            lblOtherDocumentsMessage.ForeColor = System.Drawing.Color.Red;
        }
    }
 public static int InsertHR_OthersDocuments(HR_OthersDocuments hR_OthersDocuments)
 {
     SqlHR_OthersDocumentsProvider sqlHR_OthersDocumentsProvider = new SqlHR_OthersDocumentsProvider();
     return sqlHR_OthersDocumentsProvider.InsertHR_OthersDocuments(hR_OthersDocuments);
 }
 public static bool UpdateHR_OthersDocuments(HR_OthersDocuments hR_OthersDocuments)
 {
     SqlHR_OthersDocumentsProvider sqlHR_OthersDocumentsProvider = new SqlHR_OthersDocumentsProvider();
     return sqlHR_OthersDocumentsProvider.UpdateHR_OthersDocuments(hR_OthersDocuments);
 }
    private void showHR_OthersDocumentsData()
    {
        HR_OthersDocuments hR_OthersDocuments  = new HR_OthersDocuments ();
         	hR_OthersDocuments = HR_OthersDocumentsManager.GetHR_OthersDocumentsByOthersDocumentsID(Int32.Parse(Request.QueryString["ID"]));

         	//txtDocumentName.Text =hR_OthersDocuments.DocumentName.ToString();
    }