/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filePath        = MapPath("~/App_Data/" + e.FileName);
        string fileContentType = e.ContentType;
        int    fileSize        = e.FileSize;
        string fileName        = e.FileName;
        string path            = MapPath("~/App_Data/" + e.FileName);

        AjaxFileUpload1.SaveAs(path);
        //e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);

        FileInfo fileInfo = new FileInfo(filePath);
        string   ID       = Path.GetFileNameWithoutExtension(path);

        // The byte[] to save the data in
        byte[] data = new byte[fileInfo.Length];

        // Load a filestream and put its content into the byte[]
        using (FileStream fs = fileInfo.OpenRead())
        {
            fs.Read(data, 0, data.Length);
        }

        byte[] EncryptData     = CryptoImage.EncryptBytes(data);
        int    EncryptfileSize = EncryptData.Length;

        System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection();

        sqlConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
        String SqlCmdText1 = "UPDATE VisitorsCard SET VisImage =@VisImage,VisImageContentType=@VisImageContentType,VisImageLength=@VisImageLength WHERE VisIdentityNo = @VisIdentityNo";

        System.Data.SqlClient.SqlCommand sqlCmdObj1 = new System.Data.SqlClient.SqlCommand(SqlCmdText1, sqlConnection);

        sqlCmdObj1.Parameters.Add("@VisIdentityNo", System.Data.SqlDbType.VarChar, 100).Value       = ID;
        sqlCmdObj1.Parameters.Add("@VisImage", System.Data.SqlDbType.Binary, EncryptfileSize).Value = EncryptData;
        sqlCmdObj1.Parameters.Add("@VisImageContentType", System.Data.SqlDbType.VarChar, 255).Value = fileContentType;
        sqlCmdObj1.Parameters.Add("@VisImageLength", System.Data.SqlDbType.Int).Value = EncryptfileSize;

        sqlConnection.Open();
        sqlCmdObj1.ExecuteNonQuery();
        sqlConnection.Close();
    }
Example #2
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void FillPropeties()
    {
        try
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            ProClass.DateType = FormSession.DateType;

            ProClass.VisCardID     = txtVisCardID.Text;
            ProClass.VisIdentityNo = txtVisIdentityNo.Text;
            ProClass.VisNameAr     = txtVisNameAr.Text;
            if (!string.IsNullOrEmpty(txtVisNameEn.Text))
            {
                ProClass.VisNameEn = txtVisNameEn.Text;
            }
            if (!string.IsNullOrEmpty(txtVisMobileNo.Text))
            {
                ProClass.VisMobileNo = txtVisMobileNo.Text;
            }

            ProClass.StartDate  = calStartDate.getDate();
            ProClass.ExpiryDate = calExpiryDate.getDate();

            ProClass.VisRegion1 = chkbRegion.Items.FindByValue("Region1").Selected;
            ProClass.VisRegion2 = chkbRegion.Items.FindByValue("Region2").Selected;
            ProClass.VisRegion3 = chkbRegion.Items.FindByValue("Region3").Selected;
            ProClass.VisRegion4 = chkbRegion.Items.FindByValue("Region4").Selected;
            ProClass.VisRegion5 = chkbRegion.Items.FindByValue("Region5").Selected;
            ProClass.VisRegion6 = chkbRegion.Items.FindByValue("Region6").Selected;
            ProClass.VisRegion7 = chkbRegion.Items.FindByValue("Region7").Selected;
            ProClass.VisRegion8 = chkbRegion.Items.FindByValue("Region8").Selected;
            ProClass.VisRegion9 = chkbRegion.Items.FindByValue("Region9").Selected;

            if (!string.IsNullOrEmpty(txtDescription.Text))
            {
                ProClass.Description = txtDescription.Text;
            }

            if (ddlTmpID.SelectedIndex > 0)
            {
                ProClass.TmpID = ddlTmpID.SelectedValue;
            }

            ProClass.CopiesCount   = (Convert.ToInt16(FindCount(txtVisIdentityNo.Text)) + 1).ToString();
            ProClass.CardStatus    = "0";
            ProClass.isPrinted     = false;
            ProClass.TransactionBy = FormSession.LoginUsr;

            ////////
            Byte[] pImage            = new Byte[0];
            string pImageContentType = "";
            int    pImageLength      = 0;
            VisImage.GetImage(out pImage, out pImageContentType, out pImageLength);

            if (pImageLength != 0)
            {
                ProClass.VisImage = CryptoImage.EncryptBytes(pImage);
            }
            else
            {
                ProClass.VisImage = pImage;
            }
            ProClass.VisImageContentType = pImageContentType;
            ProClass.VisImageLength      = pImageLength;
            ////////
        }
        catch (Exception ex) { DBFun.InsertError(FormSession.PageName, "FillPropeties"); }
    }
Example #3
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void FillPropeties()
    {
        try
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            ProClass.DateType      = FormSession.DateType;
            ProClass.EmpID         = txtEmpIdentity.Text;
            ProClass.EmpType       = ddlEmpType.SelectedValue;
            ProClass.EmpNameEn     = txtEmpNameEn.Text;
            ProClass.EmpNameAr     = txtEmpNameAr.Text;
            ProClass.EmpBirthDate  = CalBirthDate.getDate();
            ProClass.EmpJobTitleAr = txtJobTitleAr.Text;
            ProClass.EmpJobTitleEn = txtJobTitleEn.Text;
            ProClass.EmpNationalID = txtEmpNationalID.Text;
            ProClass.EmpHireDate   = CalHireDate.getDate();
            ProClass.EmpMobileNo   = txtMobile.Text;
            ProClass.EmpEmailID    = txtEmail.Text;

            if (ddlNatID.SelectedIndex > 0)
            {
                ProClass.NatID = ddlNatID.SelectedValue;
            }
            if (ddlBloodGroup.SelectedIndex > 0)
            {
                ProClass.EmpBloodGroup = ddlBloodGroup.SelectedValue;
            }
            if (ddlCompID.SelectedIndex > 0)
            {
                ProClass.CompID = ddlCompID.SelectedValue;
            }
            if (ddlSecID.SelectedIndex > 0)
            {
                ProClass.SecID = ddlSecID.SelectedValue;
            }
            if (rdlGender.SelectedIndex > -1)
            {
                ProClass.EmpGender = Convert.ToChar(rdlGender.SelectedValue);
            }

            ProClass.TransactionBy   = FormSession.LoginUsr;
            ProClass.TransactionDate = DateTime.Now.ToShortDateString();
            //////////////////////////////////////////////
            Byte[] pImage            = new Byte[0];
            string pImageContentType = "";
            int    pImageLength      = 0;
            EmpImage.GetImage(out pImage, out pImageContentType, out pImageLength);

            if (pImageLength != 0)
            {
                ProClass.EmpImage = CryptoImage.EncryptBytes(pImage);
            }
            else
            {
                ProClass.EmpImage = pImage;
            }
            ProClass.EmpImageContentType = pImageContentType;
            ProClass.EmpImageLength      = pImageLength;
            //////////////////////////////////////////////
        }
        catch (Exception Ex)
        {
            DBFun.InsertError(FormSession.PageName, "FillPropeties");
            MessageFun.ShowAdminMsg(this, Ex.Message);
        }
    }