Beispiel #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //byte[] a;
        //byte[] pic;//=new byte[204800];
        //byte[] c = new byte[ 524343323 ];
        //pic.Initialize();
        if (!FileUpload1.HasFile || !FileUpload2.HasFile)
        {
            Label1.Text = "No File/Photo Selected...";
        }
        else
        {
            // //FileUpload1.SaveAs(Server.MapPath(@"~/temp/") + FileUpload1.FileName);
            // //string image_ext = System.IO.Path.GetExtension(FileUpload1.FileName);
            fileext = System.IO.Path.GetExtension(FileUpload2.FileName);
            try
            {
                Bitmap image11;
                string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
                filename1 = Path.GetFileName(FileUpload2.PostedFile.FileName);

                FileUpload1.SaveAs(Server.MapPath("Files/" + filename));
                string ImagePath = Server.MapPath(@"Files/" + filename);
                //string ImagePath = FileUpload1.FileName;

                FileUpload2.SaveAs(Server.MapPath("Files/" + filename1));
                string pathSource = Server.MapPath(@"Files/" + filename1);
                // string pathSource = FileUpload2.FileName;
                image11 = new Bitmap(ImagePath, true);
                //image1 = new Bitmap(@"E:\Users\Public\Pictures\Sample Pictures\1.jpg", true);
                // string pathSource = @"I:\praveen\praveen_code\imp_links.txt";

                FileStream fsSource       = new FileStream(pathSource, FileMode.Open, FileAccess.Read);
                byte[]     bytes          = new byte[fsSource.Length];
                int        numBytesToRead = (int)fsSource.Length;
                // Session["file_size"] = numBytesToRead;
                fsSource.Read(bytes, 0, numBytesToRead);

                //int ImageSize= FileUpload1.PostedFile.ContentLength;
                range     = FileUpload2.PostedFile.ContentLength;
                imagesize = FileUpload1.PostedFile.InputStream.Length;
                //int TotalPixel = image11.Width * image11.Height;
                //int size_of_file_in_image = (int)((TotalPixel * 3) / 8);
                //int TotalFilesNeeded = (int)((numBytesToRead / size_of_file_in_image) + 1);
                //int count = TotalFilesNeeded;
                int TotalPixel            = image11.Width * image11.Height;
                int size_of_file_in_image = Convert.ToInt32(TotalPixel / 3);
                int TotalFilesNeeded      = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(numBytesToRead) / Convert.ToDecimal(size_of_file_in_image)));
                int count = TotalFilesNeeded;
                //if(TotalFilesNeeded==1)
                //    save_file(image11, pathSource, count);
                //else

                byte[][] byte_2_array = new byte[TotalFilesNeeded][];

                for (int j = 0; j < TotalFilesNeeded; j++)
                {
                    if (j < TotalFilesNeeded - 1)
                    {
                        byte_2_array[j] = new byte[size_of_file_in_image];
                        for (int x = 0; x < byte_2_array[j].Length; x++)
                        {
                            byte_2_array[j][x] = bytes[j * size_of_file_in_image + x];
                            //if((j*byte_2_array[j].Length + x)<bytes.Length)
                            //Label2.Text = Label2.Text + "<br/>" + (j * size_of_file_in_image + x).ToString() + ": " + byte_2_array[j][x];
                        }
                        //Response.Write("Error");
                    }
                    else
                    {
                        byte_2_array[j] = new byte[numBytesToRead - j * size_of_file_in_image];
                        for (int x = 0; x < byte_2_array[j].Length; x++)
                        {
                            byte_2_array[j][x] = bytes[j * size_of_file_in_image + x];
                            //Label2.Text = Label2.Text + "<br/>" + (j * size_of_file_in_image + x).ToString() + ": " + byte_2_array[j][x];
                        }
                    }
                }

                for (int i = 0; i < TotalFilesNeeded; i++)
                {
                    image11 = new Bitmap(ImagePath, true);
                    //save_file(image11, pathSource,count);
                    encrypt(image11, ref byte_2_array[i], i + 1);
                }
                //saving_files(a, pic, file_path, filename, fileext);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            //}
        }
    }
Beispiel #2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     path1 = "~/images/" + FileUpload2.FileName;
     FileUpload2.SaveAs(Server.MapPath(path1));
     Image2.ImageUrl = path1;
 }
    protected void btn_submit_Click(object sender, ImageClickEventArgs e)
    {
        string cosname;

        cosname = (string)Session["userid"];


        try
        {
            string path = Server.MapPath("images/");
            if (FileUpload1.HasFile && FileUpload2.HasFile)
            {
                string ext = Path.GetExtension(FileUpload1.FileName);

                if (ext == ".jpg" || ext == ".png" || ext == ".jpeg")
                {
                    string sUserID  = "satishkarwar";
                    string sPwd     = "password123";
                    string sNumber  = "91" + Label16.Text;
                    string sSID     = "websms";
                    string sMessage = "hello " + cosname + ",\nYou Have Been Sucessfully Posted Your Ad. \nYour Details : \n category-" + listbox_category.Text + "\n State-" + state.Text + "\n City-" + city.Text + "\n Email-" + email.Text + "\n Price-" + txtbox_price.Text + " \n Thank You Visiting www.scraps.in";
                    string sURL     = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=" + sNumber + "&sid=" + sSID + "&msg=" + sMessage + "&mt=0&fl=0";
                    string sResponse = GetResponse(sURL);


                    connect();
                    FileUpload1.SaveAs(path + FileUpload1.FileName);
                    string name1 = "~/images/" + FileUpload1.FileName;
                    FileUpload2.SaveAs(path + FileUpload2.FileName);
                    string name2 = "~/images/" + FileUpload2.FileName;



                    cmd.CommandText = "insert into post_ads(userid,username,category,phoneno,address,city,state,email,photo1,photo2,price)values(?,?,?,?,?,?,?,?,?,?,?)";
                    // cmd.Parameters.AddWithValue("sr_no", Label13.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("userid", Label13.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("username", txtbox_username.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("category", listbox_category.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("phoneno", Label16.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("address", txtbox_address.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("city", city.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("state", state.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("email", email.Text.ToString().Trim());
                    cmd.Parameters.AddWithValue("photo1", name1.ToString());
                    cmd.Parameters.AddWithValue("photo2", name2.ToString());
                    cmd.Parameters.AddWithValue("price", txtbox_price.Text.ToString().Trim());

                    cmd.ExecuteNonQuery();
                    disconnect();
                    Response.Redirect("home.aspx");
                }


                else
                {
                    Label10.Text = "can upload only jpg and png";
                }
            }
            else
            {
                Label10.Text = "select both images";
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('Error In Internet Connection. Please Try Again!!!')</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Name.Text != null && Price.Text != null && Selling.Text != null && Brand.SelectedItem.Value != null && Category.SelectedItem.Value != null && Sub.SelectedItem.Value != null && Gender.SelectedItem.Value != null && Description.Text != null && MetCare.Text != null && Productdtl.Text != null)
        {
            string path1 = "";
            path1 = "~/Img/" + FileUpload1.FileName;
            FileUpload1.SaveAs(Server.MapPath(path1));

            string path2 = "";
            path2 = "~/Img/" + FileUpload2.FileName;
            FileUpload2.SaveAs(Server.MapPath(path2));

            string path3 = "";
            path3 = "~/Img/" + FileUpload3.FileName;
            FileUpload3.SaveAs(Server.MapPath(path3));

            string path4 = "";
            path4 = "~/Img/" + FileUpload4.FileName;
            FileUpload4.SaveAs(Server.MapPath(path4));

            string path5 = "";
            path5 = "~/Img/" + FileUpload5.FileName;
            FileUpload5.SaveAs(Server.MapPath(path5));

            SqlCommand cmd = new SqlCommand("sp_Project", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PName", Name.Text);
            cmd.Parameters.AddWithValue("@PPrice", Price.Text);
            cmd.Parameters.AddWithValue("@PSellPrice", Selling.Text);
            cmd.Parameters.AddWithValue("@PBrand", Brand.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@PCatId", Category.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@SubCatId", Sub.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@PGender", Gender.SelectedItem.Value);
            cmd.Parameters.AddWithValue("@PDesc", Description.Text);
            cmd.Parameters.AddWithValue("@PDetail", Productdtl.Text);
            cmd.Parameters.AddWithValue("@PMet", MetCare.Text);
            cmd.Parameters.AddWithValue("@P1", path1);
            cmd.Parameters.AddWithValue("@P2", path2);
            cmd.Parameters.AddWithValue("@P3", path3);
            cmd.Parameters.AddWithValue("@P4", path4);
            cmd.Parameters.AddWithValue("@P5", path5);

            if (free.Checked == true)
            {
                cmd.Parameters.AddWithValue("@free", 1.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@free", 0.ToString());
            }

            if (txtcod.Checked == true)
            {
                cmd.Parameters.AddWithValue("@COD", 1.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@COD", 0.ToString());
            }
            if (txt30.Checked == true)
            {
                cmd.Parameters.AddWithValue("@replace", 1.ToString());
            }
            else
            {
                cmd.Parameters.AddWithValue("@replace", 0.ToString());
            }
            con.Open();
            int k = (int)cmd.ExecuteNonQuery();

            if (k == 1)
            {
                Response.Write("<Script>alert('Data recorded');/<Script>");
            }
            else
            {
                Response.Write("<Script>alert('Data not recorded');/<Script>");
            }

            con.Close();


            Name.Text    = string.Empty;
            Price.Text   = string.Empty;
            Selling.Text = string.Empty;
            Brand.ClearSelection();
            Category.ClearSelection();
            Sub.ClearSelection();
            Gender.ClearSelection();
            Description.Text = string.Empty;
            MetCare.Text     = string.Empty;
            Productdtl.Text  = string.Empty;
        }
        else
        {
            Response.Write("<Script>alert('Product Cannot be Added');</Script>");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {
            string path = Server.MapPath("Images/");
            //image1
            if (FileUpload1.HasFile)
            {
                string ext = Path.GetExtension(FileUpload1.FileName);
                if (ext == ".jpg" || ext == ".png")
                {
                    FileUpload1.SaveAs(path + FileUpload1.FileName);
                    string name = "Images/" + FileUpload1.FileName;
                    string ss   = "update buy set image1='" + name + "' where id='" + Session["id"] + "'";

                    con.Open();
                    cmd = new SqlCommand(ss, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }


            //image2
            if (FileUpload2.HasFile)
            {
                string ext = Path.GetExtension(FileUpload2.FileName);
                if (ext == ".jpg" || ext == ".png")
                {
                    FileUpload2.SaveAs(path + FileUpload2.FileName);
                    string name = "Images/" + FileUpload2.FileName;
                    string ss   = "update buy set image2='" + name + "' where id='" + Session["id"] + "'";

                    con.Open();
                    cmd = new SqlCommand(ss, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }


            //image3
            if (FileUpload3.HasFile)
            {
                string ext = Path.GetExtension(FileUpload3.FileName);
                if (ext == ".jpg" || ext == ".png")
                {
                    FileUpload3.SaveAs(path + FileUpload3.FileName);
                    string name = "Images/" + FileUpload3.FileName;
                    string ss   = "update buy set image3='" + name + "' where id='" + Session["id"] + "'";

                    con.Open();
                    cmd = new SqlCommand(ss, con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }



            //content
            con.Open();
            cmd = new SqlCommand("update buy set rooms='" + TextBox1.Text + "',area='" + TextBox2.Text + "',floor='" + TextBox3.Text + "', price='" + TextBox4.Text + "',contact_agent='" + TextBox5.Text + "',description='" + TextBox6.Text + "',transactions='" + TextBox7.Text + "',address='" + TextBox8.Text + "',bed_rooms='" + TextBox9.Text + "',bath_rooms='" + TextBox10.Text + "',store_rooms='" + TextBox11.Text + "',flooring='" + TextBox12.Text + "',landmarks='" + TextBox13.Text + "',overlooking='" + TextBox14.Text + "',age_of_construction='" + TextBox15.Text + "',authority_verification='" + TextBox16.Text + "',title='" + TextBox17.Text + "',category='" + TextBox19.Text + "',City='" + TextBox21.Text + "' where id='" + Session["id"] + "'", con);
            cmd.ExecuteNonQuery();
            con.Close();

            count++;



            Button1.Visible     = true;
            Button2.Visible     = false;
            Button3.Visible     = false;
            Label1.Visible      = true; Label2.Visible = true; Label3.Visible = true; Label4.Visible = true; Label4.Visible = true; Label5.Visible = true; Label6.Visible = true;
            Label7.Visible      = true; Label8.Visible = true; Label9.Visible = true; Label10.Visible = true; Label11.Visible = true; Label12.Visible = true; Label13.Visible = true;
            Label14.Visible     = true; Label15.Visible = true; Label16.Visible = true; Label17.Visible = true; Label19.Visible = true; Label21.Visible = true;
            TextBox1.Visible    = false; TextBox2.Visible = false; TextBox3.Visible = false; TextBox4.Visible = false; TextBox4.Visible = false; TextBox5.Visible = false; TextBox6.Visible = false;
            TextBox7.Visible    = false; TextBox8.Visible = false; TextBox9.Visible = false; TextBox10.Visible = false; TextBox11.Visible = false; TextBox12.Visible = false; TextBox13.Visible = false;
            TextBox14.Visible   = false; TextBox15.Visible = false; TextBox16.Visible = false; TextBox17.Visible = false; TextBox19.Visible = false;
            TextBox21.Visible   = false;
            FileUpload1.Visible = false; FileUpload2.Visible = false; FileUpload3.Visible = false;
            Response.Redirect("buy-content-page.aspx");
        }

        catch (Exception) {
            Label18.ForeColor = System.Drawing.Color.Red;
            Label18.Text      = "Something Went Wrong";

            Label18.Visible = true;
            Label20.Visible = true;
            Button1.Visible = false;
        }
    }
Beispiel #6
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (btnsubmit.Text == "Submit")
        {
            product.Product_name = txtproductname.Text;
            product.Cat_id       = Convert.ToInt32(drpcat.SelectedValue);
            product.Status       = chkstatus.Checked;
            //product.Cdate = Convert.ToDateTime(DateTime.Now.ToShortDateString());

            product.Our_latest_product = chklatest.Checked;
            product.OurBestProduct     = chkbest.Checked;
            product.HomePage           = chkhome.Checked;
            product.HomePage2          = chkhome2.Checked;
            product.Product_Dec        = txtdescription.Text;
            product.Product_Price      = txtprice.Text;
            product.Product_Unit       = txtunit.Text;

            string gid = Guid.NewGuid().ToString().Substring(0, 4);

            if (FileUpload1.HasFile)
            {
                string filename = FileUpload1.FileName;
                FileUpload1.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image = gid + filename;
            }



            if (FileUpload2.HasFile)
            {
                string filename = FileUpload2.FileName;
                FileUpload2.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image1 = gid + filename;
            }


            if (FileUpload3.HasFile)
            {
                string filename = FileUpload3.FileName;
                FileUpload3.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image2 = gid + filename;
            }


            if (FileUpload4.HasFile)
            {
                string filename = FileUpload4.FileName;
                FileUpload4.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image3 = gid + filename;
            }


            if (FileUpload5.HasFile)
            {
                string filename = FileUpload5.FileName;
                FileUpload5.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image4 = gid + filename;
            }

            db.Tb_Product.Add(product);
            db.SaveChanges();
            clear();
            Response.Redirect("~/Admin/ShowProduct.aspx?msg=" + "Svd");
        }
        else
        {
            product = db.Tb_Product.Find(Convert.ToInt32(ViewState["id"]));
            product.Product_name = txtproductname.Text;
            product.Cat_id       = Convert.ToInt32(drpcat.SelectedValue);
            product.Status       = chkstatus.Checked;
            //product.Cdate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            product.Status        = chkstatus.Checked;
            product.Product_Dec   = txtdescription.Text;
            product.Product_Price = txtprice.Text;
            product.Product_Unit  = txtunit.Text;

            string gid = Guid.NewGuid().ToString().Substring(0, 4);

            if (FileUpload1.HasFile)
            {
                string filename = FileUpload1.FileName;
                FileUpload1.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image = gid + filename;
            }



            if (FileUpload2.HasFile)
            {
                string filename = FileUpload2.FileName;
                FileUpload2.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image1 = gid + filename;
            }


            if (FileUpload3.HasFile)
            {
                string filename = FileUpload3.FileName;
                FileUpload3.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image2 = gid + filename;
            }


            if (FileUpload4.HasFile)
            {
                string filename = FileUpload4.FileName;
                FileUpload4.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image3 = gid + filename;
            }


            if (FileUpload5.HasFile)
            {
                string filename = FileUpload5.FileName;
                FileUpload5.SaveAs(Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString()));
                //  jp.IPath = Server.MapPath("~\\Upload\\Product\\" + gid + filename.ToString());
                product.Product_Image4 = gid + filename;
            }
            else
            {
                product.Product_Image = ViewState["image"].ToString();
            }
            db.SaveChanges();
            clear();
            Response.Redirect("~/Admin/ShowProduct.aspx?msg=" + "upd");
        }
    }
        //RUTINA PARA SUBIR UN EXCEL
        protected void Upload2(object sender, EventArgs e)
        {
            //Upload and save the file
            string csvPath = Server.MapPath("~/Files/") + Path.GetFileName(FileUpload2.PostedFile.FileName);

            FileUpload2.SaveAs(csvPath);

            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[11] {
                new DataColumn("codigoInterno", typeof(string)),
                new DataColumn("numeroEspediente", typeof(string)),
                new DataColumn("idConvocatoria", typeof(int)),
                new DataColumn("idLocalidad", typeof(int)),
                new DataColumn("titulo", typeof(string)),
                new DataColumn("montoTotalCofecyt", typeof(decimal)),
                new DataColumn("montoSolicitadoCofecyt", typeof(decimal)),
                new DataColumn("montoContraparteCofecyt", typeof(decimal)),
                new DataColumn("beneficiarios", typeof(string)),
                new DataColumn("contraparte", typeof(string)),
                new DataColumn("observaciones", typeof(string))
                //new DataColumn("fechaPresentacion", typeof(DateTime)),
            });

            string csvData = File.ReadAllText(csvPath);

            //Execute a loop over the rows.
            foreach (string row in csvData.Split('\n'))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    dt.Rows.Add();
                    int i = 0;

                    //Execute a loop over the columns.
                    foreach (string cell in row.Split(';'))
                    {
                        dt.Rows[dt.Rows.Count - 1][i] = cell;
                        i++;
                    }
                }
            }

            foreach (DataRow row in dt.Rows)
            {
                string codigoCsv = row[0].ToString();

                ProyectoCofecyt proyectoCofecyt = proyectoCofecytNego.ObtenerProyectoCofecyt(codigoCsv);

                if (proyectoCofecyt != null)
                {
                    ProyectoCofecyt proy = new ProyectoCofecyt();

                    proy.IdProyectoCofecyt = proyectoCofecytNego.TraerIdSegunCodigo(codigoCsv);

                    proy.CodigoInterno          = proyectoCofecyt.CodigoInterno;
                    proy.NumeroEspedienteCopade = proyectoCofecyt.NumeroEspedienteCopade;
                    proy.IdConvocatoria         = proyectoCofecyt.IdConvocatoria;
                    proy.IdLocalidad            = proyectoCofecyt.IdLocalidad;
                    proy.Titulo                  = proyectoCofecyt.Titulo;
                    proy.MontoTotalCofecyt       = proyectoCofecyt.MontoTotalCofecyt;
                    proy.MontoSolicitadoCofecyt  = proyectoCofecyt.MontoSolicitadoCofecyt;
                    proy.MontoContraparteCofecyt = proyectoCofecyt.MontoContraparteCofecyt;
                    proy.Beneficiarios           = proyectoCofecyt.Beneficiarios;
                    proy.Contraparte             = proyectoCofecyt.Contraparte;
                    proy.Observaciones           = proyectoCofecyt.Observaciones;
                    //proy.FechaPresentacion = proyectoCofecyt.FechaPresentacion;

                    proyectoCofecytNego.ActualizarProyectoCofecyt(proy);
                }
                else if (proyectoCofecyt == null)
                {
                    ProyectoCofecyt proy = new ProyectoCofecyt();

                    proy.CodigoInterno          = row[0].ToString();
                    proy.NumeroEspedienteCopade = row[1].ToString();
                    proy.IdConvocatoria         = Convert.ToInt32(row[2].ToString());
                    proy.IdLocalidad            = Convert.ToInt32(row[3].ToString());
                    proy.Titulo                  = row[4].ToString();
                    proy.MontoTotalCofecyt       = Convert.ToDecimal(row[5].ToString());
                    proy.MontoSolicitadoCofecyt  = Convert.ToDecimal(row[6].ToString());
                    proy.MontoContraparteCofecyt = Convert.ToDecimal(row[7].ToString());
                    proy.Beneficiarios           = row[8].ToString();
                    proy.Contraparte             = row[9].ToString();
                    proy.Observaciones           = row[10].ToString();
                    //proy.FechaPresentacion = Convert.ToDateTime(row[8].ToString());

                    proy.Objetivos = null;

                    proyectoCofecytNego.GuardarProyectoCofecyt(proy);
                }
            }
            Response.Redirect("AltaProyectoCofecyt.aspx");
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Boolean isValid = true;

            StatusEnum status = (StatusEnum)Enum.Parse(typeof(StatusEnum), this.jobSample.job_status.ToString(), true);

            switch (status)
            {
            case StatusEnum.CHEMIST_TESTING:

                if (FileUpload2.HasFile)    // && (Path.GetExtension(FileUpload2.FileName).Equals(".doc") || Path.GetExtension(FileUpload2.FileName).Equals(".docx")))
                {
                    string yyyy = DateTime.Now.ToString("yyyy");
                    string MM   = DateTime.Now.ToString("MM");
                    string dd   = DateTime.Now.ToString("dd");

                    String source_file     = String.Format(Configurations.PATH_SOURCE, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload2.FileName));
                    String source_file_url = String.Format(Configurations.PATH_URL, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload2.FileName));


                    if (!Directory.Exists(Path.GetDirectoryName(source_file)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(source_file));
                    }
                    FileUpload2.SaveAs(source_file);
                    this.jobSample.ad_hoc_tempalte_path = source_file_url;
                }

                this.jobSample.job_status            = Convert.ToInt32(StatusEnum.SR_CHEMIST_CHECKING);
                this.jobSample.step2owner            = userLogin.id;
                this.jobSample.date_chemist_complete = DateTime.Now;

                break;

            case StatusEnum.SR_CHEMIST_CHECKING:
                StatusEnum srChemistApproveStatus = (StatusEnum)Enum.Parse(typeof(StatusEnum), ddlStatus.SelectedValue, true);
                switch (srChemistApproveStatus)
                {
                case StatusEnum.SR_CHEMIST_APPROVE:
                    this.jobSample.job_status = Convert.ToInt32(StatusEnum.ADMIN_CONVERT_WORD);
                    #region ":: STAMP COMPLETE DATE"


                    this.jobSample.date_srchemist_complate = DateTime.Now;
                    #endregion
                    break;

                case StatusEnum.SR_CHEMIST_DISAPPROVE:
                    this.jobSample.job_status = Convert.ToInt32(StatusEnum.CHEMIST_TESTING);
                    #region "LOG"
                    job_sample_logs jobSampleLog = new job_sample_logs
                    {
                        ID            = 0,
                        job_sample_id = this.jobSample.ID,
                        log_title     = String.Format("Sr.Chemist DisApprove"),
                        job_remark    = txtRemark.Text,
                        is_active     = "0",
                        date          = DateTime.Now
                    };
                    jobSampleLog.Insert();
                    #endregion
                    break;
                }
                this.jobSample.step4owner = userLogin.id;
                break;

            case StatusEnum.LABMANAGER_CHECKING:
                StatusEnum labApproveStatus = (StatusEnum)Enum.Parse(typeof(StatusEnum), ddlStatus.SelectedValue, true);
                switch (labApproveStatus)
                {
                case StatusEnum.LABMANAGER_APPROVE:
                    this.jobSample.job_status = Convert.ToInt32(StatusEnum.ADMIN_CONVERT_PDF);

                    this.jobSample.date_labman_complete = DateTime.Now;
                    break;

                case StatusEnum.LABMANAGER_DISAPPROVE:
                    this.jobSample.job_status = Convert.ToInt32(ddlAssignTo.SelectedValue);
                    #region "LOG"
                    job_sample_logs jobSampleLog = new job_sample_logs
                    {
                        ID            = 0,
                        job_sample_id = this.jobSample.ID,
                        log_title     = String.Format("Lab Manager DisApprove"),
                        job_remark    = txtRemark.Text,
                        is_active     = "0",
                        date          = DateTime.Now
                    };
                    jobSampleLog.Insert();
                    #endregion
                    break;
                }
                this.jobSample.step5owner = userLogin.id;
                break;

            case StatusEnum.ADMIN_CONVERT_WORD:
                if (FileUpload1.HasFile)    // && (Path.GetExtension(FileUpload1.FileName).Equals(".doc") || Path.GetExtension(FileUpload1.FileName).Equals(".docx")))
                {
                    string yyyy = DateTime.Now.ToString("yyyy");
                    string MM   = DateTime.Now.ToString("MM");
                    string dd   = DateTime.Now.ToString("dd");

                    String source_file     = String.Format(Configurations.PATH_SOURCE, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload1.FileName));
                    String source_file_url = String.Format(Configurations.PATH_URL, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload1.FileName));


                    if (!Directory.Exists(Path.GetDirectoryName(source_file)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(source_file));
                    }
                    FileUpload1.SaveAs(source_file);
                    this.jobSample.path_word  = source_file_url;
                    this.jobSample.job_status = Convert.ToInt32(StatusEnum.LABMANAGER_CHECKING);
                }
                else
                {
                    errors.Add("Invalid File. Please upload a File with extension .doc|.docx");
                }
                this.jobSample.step6owner = userLogin.id;
                break;

            case StatusEnum.ADMIN_CONVERT_PDF:
                if (FileUpload1.HasFile)    // && (Path.GetExtension(FileUpload1.FileName).Equals(".pdf")))
                {
                    string yyyy = DateTime.Now.ToString("yyyy");
                    string MM   = DateTime.Now.ToString("MM");
                    string dd   = DateTime.Now.ToString("dd");

                    String source_file     = String.Format(Configurations.PATH_SOURCE, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload1.FileName));
                    String source_file_url = String.Format(Configurations.PATH_URL, yyyy, MM, dd, this.jobSample.job_number, Path.GetFileName(FileUpload1.FileName));


                    if (!Directory.Exists(Path.GetDirectoryName(source_file)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(source_file));
                    }
                    FileUpload1.SaveAs(source_file);
                    this.jobSample.path_pdf   = source_file_url;
                    this.jobSample.job_status = Convert.ToInt32(StatusEnum.JOB_COMPLETE);
                    this.jobSample.step7owner = userLogin.id;

                    //lbMessage.Text = string.Empty;
                }
                else
                {
                    errors.Add("Invalid File. Please upload a File with extension .pdf");
                    //lbMessage.Attributes["class"] = "alert alert-error";
                    //isValid = false;
                }
                break;
            }

            if (errors.Count > 0)
            {
                litErrorMessage.Text = MessageBox.GenWarnning(errors);
                modalErrorList.Show();
            }
            else
            {
                litErrorMessage.Text = String.Empty;
                //########
                this.jobSample.Update();
                //Commit
                GeneralManager.Commit();

                removeSession();
                MessageBox.Show(this.Page, Resources.MSG_SAVE_SUCCESS, PreviousPath);
            }
        }
Beispiel #9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            String photo = Path.GetFileName(FileUpload1.FileName);
            FileUpload1.SaveAs(Server.MapPath("~/Teacher/pic/" + photo));

            string        conn   = ConfigurationManager.ConnectionStrings["totalschoolConnectionString"].ConnectionString;
            SqlConnection objcon = new SqlConnection(conn);
            objcon.Open();
            SqlCommand objcmd = new SqlCommand("spgal", objcon);
            objcmd.CommandType = CommandType.StoredProcedure;

            SqlParameter p2 = new SqlParameter();
            p2.ParameterName = "@pic";
            p2.SqlDbType     = SqlDbType.NVarChar;
            p2.Value         = FileUpload1.FileName;
            objcmd.Parameters.Add(p2);

            SqlParameter p3 = new SqlParameter();
            p3.ParameterName = "@id";
            p3.SqlDbType     = SqlDbType.NVarChar;
            p3.Value         = lblid.Text;
            objcmd.Parameters.Add(p3);

            SqlParameter p1 = new SqlParameter();
            p1.ParameterName = "@school";
            p1.SqlDbType     = SqlDbType.NVarChar;
            p1.Value         = lblsch.Text;
            objcmd.Parameters.Add(p1);


            //Class1.WebMsgBox.Show("1 Added successfully");
            objcmd.ExecuteNonQuery();
            // Response.Write("Created Successfully");
            objcon.Close();
        }

        if (FileUpload2.HasFile)
        {
            String photo1 = Path.GetFileName(FileUpload2.FileName);
            FileUpload2.SaveAs(Server.MapPath("~/Teacher/pic/" + photo1));

            string        conn1   = ConfigurationManager.ConnectionStrings["totalschoolConnectionString"].ConnectionString;
            SqlConnection objcon1 = new SqlConnection(conn1);
            objcon1.Open();
            SqlCommand objcmd1 = new SqlCommand("spgal", objcon1);
            objcmd1.CommandType = CommandType.StoredProcedure;

            SqlParameter p21 = new SqlParameter();
            p21.ParameterName = "@pic";
            p21.SqlDbType     = SqlDbType.NVarChar;
            p21.Value         = FileUpload2.FileName;
            objcmd1.Parameters.Add(p21);

            SqlParameter p31 = new SqlParameter();
            p31.ParameterName = "@id";
            p31.SqlDbType     = SqlDbType.NVarChar;
            p31.Value         = lblid.Text;
            objcmd1.Parameters.Add(p31);

            SqlParameter p1 = new SqlParameter();
            p1.ParameterName = "@school";
            p1.SqlDbType     = SqlDbType.NVarChar;
            p1.Value         = lblsch.Text;
            objcmd1.Parameters.Add(p1);

            //Class1.WebMsgBox.Show("2 Added successfully");
            objcmd1.ExecuteNonQuery();
            // Response.Write("Created Successfully");
            objcon1.Close();
        }

        if (FileUpload3.HasFile)
        {
            String photo2 = Path.GetFileName(FileUpload3.FileName);
            FileUpload3.SaveAs(Server.MapPath("~/Teacher/pic/" + photo2));


            string        conn2   = ConfigurationManager.ConnectionStrings["totalschoolConnectionString"].ConnectionString;
            SqlConnection objcon2 = new SqlConnection(conn2);
            objcon2.Open();
            SqlCommand objcmd2 = new SqlCommand("spgal", objcon2);
            objcmd2.CommandType = CommandType.StoredProcedure;

            SqlParameter p22 = new SqlParameter();
            p22.ParameterName = "@pic";
            p22.SqlDbType     = SqlDbType.NVarChar;
            p22.Value         = FileUpload3.FileName;
            objcmd2.Parameters.Add(p22);

            SqlParameter p32 = new SqlParameter();
            p32.ParameterName = "@id";
            p32.SqlDbType     = SqlDbType.NVarChar;
            p32.Value         = lblid.Text;
            objcmd2.Parameters.Add(p32);

            SqlParameter p1 = new SqlParameter();
            p1.ParameterName = "@school";
            p1.SqlDbType     = SqlDbType.NVarChar;
            p1.Value         = lblsch.Text;
            objcmd2.Parameters.Add(p1);

            //Class1.WebMsgBox.Show("3 Added successfully");
            objcmd2.ExecuteNonQuery();
            // Response.Write("Created Successfully");
            objcon2.Close();
        }

        if (FileUpload4.HasFile)
        {
            String photo3 = Path.GetFileName(FileUpload4.FileName);
            FileUpload4.SaveAs(Server.MapPath("~/Teacher/pic/" + photo3));

            string        conn3   = ConfigurationManager.ConnectionStrings["totalschoolConnectionString"].ConnectionString;
            SqlConnection objcon3 = new SqlConnection(conn3);
            objcon3.Open();
            SqlCommand objcmd3 = new SqlCommand("spgal", objcon3);
            objcmd3.CommandType = CommandType.StoredProcedure;

            SqlParameter p23 = new SqlParameter();
            p23.ParameterName = "@pic";
            p23.SqlDbType     = SqlDbType.NVarChar;
            p23.Value         = FileUpload4.FileName;
            objcmd3.Parameters.Add(p23);

            SqlParameter p33 = new SqlParameter();
            p33.ParameterName = "@id";
            p33.SqlDbType     = SqlDbType.NVarChar;
            p33.Value         = lblid.Text;
            objcmd3.Parameters.Add(p33);

            SqlParameter p1 = new SqlParameter();
            p1.ParameterName = "@school";
            p1.SqlDbType     = SqlDbType.NVarChar;
            p1.Value         = lblsch.Text;
            objcmd3.Parameters.Add(p1);

            // Class1.WebMsgBox.Show("4 Added successfully");
            objcmd3.ExecuteNonQuery();
            // Response.Write("Created Successfully");
            objcon3.Close();
        }

        if (FileUpload5.HasFile)
        {
            String photo4 = Path.GetFileName(FileUpload5.FileName);
            FileUpload5.SaveAs(Server.MapPath("~/Teacher/pic/" + photo4));

            string        conn4   = ConfigurationManager.ConnectionStrings["totalschoolConnectionString"].ConnectionString;
            SqlConnection objcon4 = new SqlConnection(conn4);
            objcon4.Open();
            SqlCommand objcmd4 = new SqlCommand("spgal", objcon4);
            objcmd4.CommandType = CommandType.StoredProcedure;

            SqlParameter p24 = new SqlParameter();
            p24.ParameterName = "@pic";
            p24.SqlDbType     = SqlDbType.NVarChar;
            p24.Value         = FileUpload5.FileName;
            objcmd4.Parameters.Add(p24);

            SqlParameter p34 = new SqlParameter();
            p34.ParameterName = "@id";
            p34.SqlDbType     = SqlDbType.NVarChar;
            p34.Value         = lblid.Text;
            objcmd4.Parameters.Add(p34);

            SqlParameter p1 = new SqlParameter();
            p1.ParameterName = "@school";
            p1.SqlDbType     = SqlDbType.NVarChar;
            p1.Value         = lblsch.Text;
            objcmd4.Parameters.Add(p1);

            //Class1.WebMsgBox.Show("5 Added successfully");
            objcmd4.ExecuteNonQuery();
            // Response.Write("Created Successfully");
            objcon4.Close();
        }

        Class1.WebMsgBox.Show("Pics Added to Gallery Successfully");
    }
Beispiel #10
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (FileUpload2.HasFile == false)//HasFile用来检查FileUpload是否有指定文件
        {
            Response.Write("<script>alert('请您选择Excel文件')</script> ");
            return;                                                                            //当无文件时,返回
        }
        string IsXls = System.IO.Path.GetExtension(FileUpload2.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名

        if (IsXls != ".xls" && IsXls != ".xlsx")
        {
            Response.Write("<script>alert('只可以选择Excel文件')</script>");
            return;                                                                       //当选择的不是Excel文件时,返回
        }
        string filename = DateTime.Now.ToString("yyyymmddhhMMss") + FileUpload2.FileName; //获取Execle文件名  DateTime日期函数
        string savePath = Server.MapPath(("~\\upfiles\\") + filename);                    //Server.MapPath 获得虚拟服务器相对路径

        FileUpload2.SaveAs(savePath);                                                     //SaveAs 将上传的文件内容保存在服务器上
        DataSet ds = Util.ExecleDs(savePath, filename);                                   //调用自定义方法

        DataRow[] dr      = ds.Tables[0].Select();                                        //定义一个DataRow数组
        int       rowsnum = ds.Tables[0].Rows.Count;
        DataTable dt      = Util.GetTeacherTableSchema();

        if (rowsnum == 0)
        {
            Response.Write("<script>alert('Excel表为空表,无数据!')</script>");   //当Excel表为空时,对用户进行提示
        }
        else
        {
            using (SqlConnection conn = new DB().GetConnection())
            {
                SqlBulkCopy bulkCopy = new SqlBulkCopy(conn);
                bulkCopy.DestinationTableName = "Teachers";
                bulkCopy.BatchSize            = dr.Length;
                conn.Open();
                for (int i = 0; i < dr.Length; i++)
                {
                    DataRow dr1 = dt.NewRow();
                    dr1[1]  = Guid.NewGuid();
                    dr1[2]  = dr[i]["老师姓名"].ToString();
                    dr1[9]  = Util.GetHash(dr[i]["密码"].ToString());
                    dr1[5]  = dr[i]["所属年级"].ToString();
                    dr1[13] = dr[i]["所属班级"].ToString();
                    if (dr[i]["是否班主任"].ToString() == "是")
                    {
                        dr1[12] = 1;
                    }
                    else
                    {
                        dr1[12] = 0;
                    }
                    if (dr[i]["用户角色"].ToString() == "老师")
                    {
                        dr1[10] = "f71786b4-1d45-4191-af29-04a6bb43bb58";
                    }
                    else if (dr[i]["用户角色"].ToString() == "级主任")
                    {
                        dr1[10] = "4baf0678-0d12-4bef-bacd-ba949e06f388";
                    }
                    dr1[11] = 1;
                    dt.Rows.Add(dr1);
                }
                if (dt != null && dt.Rows.Count != 0)
                {
                    bulkCopy.WriteToServer(dt);
                    Response.Write("<script>alert('成功导入数据');location='User_Man.aspx'</script></script> ");
                }
            }
        }
    }
Beispiel #11
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                //upload pics
                if (FileUpload1.HasFile)
                {
                    string fileName    = FileUpload1.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload1.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/ProfilePic/") + txtGuestId.Text + "_Profile.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload1.FileContent.Dispose();
                    FileUpload1.Dispose();
                }

                if (FileUpload2.HasFile)
                {
                    string fileName    = FileUpload2.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload2.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/IDPic/") + txtGuestId.Text + "_IDPic.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload2.FileContent.Dispose();
                    FileUpload2.Dispose();
                }

                var g = (from gu in db.Guests
                         where gu.Id.Equals(Request.QueryString["guestid"])
                         select gu).FirstOrDefault();

                g.GuestId                 = txtGuestId.Text;
                g.FirstName               = txtFirstName.Text;
                g.MiddleName              = txtMiddleName.Text;
                g.LastName                = txtLastName.Text;
                g.CompanyId               = Convert.ToInt32(ddlCompanyName.SelectedValue);
                g.ContactNumber           = txtContactNo.Text;
                g.Email                   = txtEmail.Text;
                g.ValidIDNumber           = txtIdNumber.Text;
                g.PicFilePath             = txtGuestId.Text + "_Profile.png";
                g.IDFilePath              = txtGuestId.Text + "_IDPic.png";
                g.EmergencyContactPerson  = txtContactPerson.Text;
                g.EmergencyContactNumber  = txtContactPersonNumber.Text;
                g.EmergencyContactAddress = txtContactPersonAddress.Text;
                g.CreatedBy               = User.Identity.Name;

                db.SubmitChanges();

                //audit trail
                DBLogger.Log("Update", "Updated Individual Guest", g.GuestId);

                pnlSuccess.Visible = true;

                //load images
                if (!File.Exists(Server.MapPath("~/ProfilePic/") + g.GuestId + "_Profile.png"))
                {
                    imgProfile.ImageUrl = "~/ProfilePic/noImage.png";
                }
                else
                {
                    imgProfile.ImageUrl = "~/ProfilePic/" + g.GuestId + "_Profile.png?t=" + DateTime.Now.ToString();
                }

                if (!File.Exists(Server.MapPath("~/IDPic/") + g.GuestId + "_IDPic.png"))
                {
                    IDPic.ImageUrl = "~/IDPic/noImage.png";
                }
                else
                {
                    IDPic.ImageUrl = "~/IDPic/" + g.GuestId + "_IDPic.png?t=" + DateTime.Now.ToString();
                }
            }
        }
Beispiel #12
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (FileUpload1.HasFile || FileUpload2.HasFile || FileUpload3.HasFile)
            {
                string fileextention  = System.IO.Path.GetExtension(FileUpload1.FileName);
                string fileextention2 = System.IO.Path.GetExtension(FileUpload2.FileName);
                string fileextention3 = System.IO.Path.GetExtension(FileUpload3.FileName);
                if (fileextention.ToLower() != ".jpg" && fileextention.ToLower() != ".jpeg" && fileextention2.ToLower() != ".jpg" && fileextention2.ToLower() != ".jpeg" && fileextention3.ToLower() != ".jpg" && fileextention3.ToLower() != ".jpeg")
                {
                    Label4.Text      = "Please select jpeg";
                    Label4.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    int filesize  = FileUpload1.PostedFile.ContentLength;
                    int filesize2 = FileUpload2.PostedFile.ContentLength;
                    int filesize3 = FileUpload3.PostedFile.ContentLength;

                    if (filesize > 2097152 && filesize2 > 2097152 && filesize3 > 2097152)
                    {
                        Label4.Text      = "select file size with 2 mb";
                        Label4.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);

                        FileUpload1.SaveAs(Server.MapPath("~/Uploads/States/") + Path.GetFileName(FileUpload1.FileName));
                        FileUpload2.SaveAs(Server.MapPath("~/Uploads/States/") + Path.GetFileName(FileUpload2.FileName));
                        FileUpload3.SaveAs(Server.MapPath("~/Uploads/States/") + Path.GetFileName(FileUpload3.FileName));
                        String link  = "Uploads/States/" + Path.GetFileName(FileUpload1.FileName);
                        String link1 = "Uploads/States/" + Path.GetFileName(FileUpload2.FileName);
                        String link2 = "Uploads/States/" + Path.GetFileName(FileUpload3.FileName);
                        string query = "insert into StateData (SName,SImage,SDescription,SImage1,SImage2) values (@state, @image, @description, @image1, @image2)";


                        SqlCommand cmd = new SqlCommand(query, conn);

                        cmd.Parameters.AddWithValue("@state", TextBox1.Text);
                        cmd.Parameters.AddWithValue("@image", link);
                        cmd.Parameters.AddWithValue("@description", TextBox2.Text);
                        cmd.Parameters.AddWithValue("@image1", link1);
                        cmd.Parameters.AddWithValue("@image2", link2);
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();


                        /*FileUpload1.SaveAs(Server.MapPath("~/Uploads/" +FileUpload1.FileName));
                         * Label8.Text = "file uploaded";
                         * Label8.ForeColor = System.Drawing.Color.Green;*/
                        //SqlCommand cmd = new SqlCommand(query, conn);
                        //com.Parameters.AddWithValue("@ID", newGUID.ToString());
                        //cmd.Parameters.AddWithValue("@city", TextBoxCT.Text);
                        //cmd.Parameters.AddWithValue("@package1", TextBoxP1.Text);
                        //cmd.Parameters.AddWithValue("@package2", TextBoxP2.Text);
                        // cmd.Parameters.AddWithValue("@package3", TextBoxP3.Text);

                        //Label2.Text = "Video Data Has Been Uploaded and Saved Successfully";
                        //TextBox1.Text = "";
                        //TextBox2.Text = "";

                        /*string content = " window.onload=function(){ alert('";
                         * content += ");";
                         * content += "window.location='";
                         * content += Request.Url.AbsoluteUri;
                         * content += "';}";
                         * ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", content, true);  */
                    }
                }
            }
            else
            {
                Label4.Text      = "Please select file to upload";
                Label4.ForeColor = System.Drawing.Color.Red;
            }
        }
        catch (Exception ex)
        {
            Response.Write("Error:" + ex.ToString());
        }
    }
Beispiel #13
0
        protected void ingresar_Click(object sender, EventArgs e)
        {
            using (SqlConnection cn = new SqlConnection(@"Data Source=DESKTOP-GN1S5UA\SERVER;Initial Catalog=GestionCitas;Integrated Security=SSPI;"))
            {
                FileUpload1.SaveAs(Request.PhysicalApplicationPath + "/personal/" + FileUpload1.FileName.ToString());
                path = "personal/" + FileUpload1.FileName.ToString();

                FileUpload2.SaveAs(Request.PhysicalApplicationPath + "/aficcion/" + FileUpload2.FileName.ToString());
                path2 = "aficcion/" + FileUpload2.FileName.ToString();

                FileUpload3.SaveAs(Request.PhysicalApplicationPath + "/lugar/" + FileUpload3.FileName.ToString());
                path3 = "lugar/" + FileUpload3.FileName.ToString();

                string query = "INSERT INTO [dbo].[Perfil] ([Nombre],[IdPais],[IdSexo],[FechaNacimiento],[Correo],[IdEducacion],[IdSexoInteres],[IdContexturaInteres],[Clave],ruta,[IdContextura]) VALUES(@Nombre,'" + Select4.Value + "',1,@FechaNacimiento,@Correo,@edu,@interes,2,@Clave,@ruta,@contextura)";



                string query4 = "INSERT INTO [dbo].[Lugar] ([Lugar],[IdPais]) VALUES ('" + lugar.Value + "','" + Select4.Value + "')";
                //id = id - 1;
                using (SqlCommand cmd = new SqlCommand(query, cn))
                {
                    // add parameters and their valuesid UserID
                    cmd.Parameters.Add("@nombre", System.Data.SqlDbType.VarChar, 50).Value   = Nombre.Value;
                    cmd.Parameters.Add("@FechaNacimiento", System.Data.SqlDbType.Date).Value = fecha.Value;
                    cmd.Parameters.Add("@correo", System.Data.SqlDbType.VarChar, 50).Value   = correo.Value;
                    cmd.Parameters.Add("@edu", System.Data.SqlDbType.Int).Value           = Select5.Value;
                    cmd.Parameters.Add("@interes", System.Data.SqlDbType.Int).Value       = Select3.Value;
                    cmd.Parameters.Add("@clave", System.Data.SqlDbType.VarChar, 20).Value = clave.Value;
                    cmd.Parameters.Add("@ruta", System.Data.SqlDbType.VarChar, 100).Value = path.ToString();
                    cmd.Parameters.Add("@contextura", System.Data.SqlDbType.Int).Value    = editprefixes.Value;
                    //  cmd.Parameters.AddWithValue("@foto", imgByte);
                    //   command.Parameters.Add("@foto", System.Data.SqlDbType.Image, img).Value = photo;
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();
                }
                cn.Open();
                SqlCommand ca = cn.CreateCommand();
                ca.CommandText = "SELECT MAX(Id) FROM perfil";
                id             = Convert.ToInt32(ca.ExecuteScalar());
                //id = id ;
                cn.Close();
                string query2 = "INSERT INTO [dbo].[PerfilAficcion] (IdPerfil,[ruta],[IdAficcion]) VALUES ('" + id + "',@ruta,'" + Select1.Value + "')";
                using (SqlCommand cmd = new SqlCommand(query2, cn))
                {
                    // add parameters and their valuesid UserID
                    cmd.Parameters.Add("@ruta", System.Data.SqlDbType.VarChar, 200).Value = path2.ToString();
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();
                }

                using (SqlCommand cmd = new SqlCommand(query4, cn))
                {
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();
                }


                cn.Open();
                SqlCommand caa = cn.CreateCommand();
                caa.CommandText = "SELECT MAX(Id) FROM Lugar";
                id3             = Convert.ToInt32(caa.ExecuteScalar());
                // id3 = id3 - 1;
                cn.Close();
                string query3 = "INSERT INTO [dbo].[PerfilLugar] ([IdPerfil],[ruta],[IdLugar]) VALUES ('" + id + "',@ruta,'" + id3 + "')";
                using (SqlCommand cmd = new SqlCommand(query3, cn))
                {
                    // add parameters and their valuesid UserID
                    cmd.Parameters.Add("@ruta", System.Data.SqlDbType.VarChar, 200).Value = path3.ToString();
                    cn.Open();
                    cmd.ExecuteNonQuery();
                    cn.Close();
                }
                lblErrorMessage.Attributes.Add("style", "display:normal");
                Nombre.Value = "";
                fecha.Value  = "";
                correo.Value = "";
                clave.Value  = "";
            }
        }
        protected void UploadButton_Click(Object sender, EventArgs e)
        {
            // *************************************************************************
            // Process FileUpload1
            // *************************************************************************
            if (FileUpload1.HasFile)
            {
                //WriteToLog("UploadButton_Click-FileUpload1.HasFile");
                Int64  t1        = GetTime();
                string filePath1 = string.Empty;

                string path1 = System.Web.HttpContext.Current.Server.MapPath("~/workfiles/");
                if (!Directory.Exists(path1))
                {
                    Directory.CreateDirectory(path1);
                }
                // Get file path
                filePath1 = path1 + Path.GetFileName(FileUpload1.FileName);
                // Get file extenstion
                string extension = Path.GetExtension(FileUpload1.FileName);
                // Get file Name
                string File1OrigName = FileUpload1.FileName;
                // Get KeyField or Fields
                KeyField      = Request.Form["KeyField"].Replace(", ", ","); // Get one or more field names (comma separated)
                arrKeyField   = KeyField.Split(',');                         // Split the files names into a string array
                KeyFieldCount = arrKeyField.Length;                          // Get the number of key files entered
                // Save file on "workfiles" folder of project
                FileUpload1.SaveAs(filePath1);

                string conString = string.Empty;
                // Check file extension
                switch (extension)
                {
                case ".xls":     // Excel 97-03.
                    //conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    // See (https://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine No.6)
                    conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    break;

                case ".xlsx":     // Excel 07 and above.
                    conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    break;
                }

                // Create datatable object
                conString = string.Format(conString, filePath1);

                // Use OldDb to read excel
                using (OleDbConnection connExcel = new OleDbConnection(conString))
                    using (OleDbCommand cmdExcel = new OleDbCommand())
                        using (OleDbDataAdapter odaExcel = new OleDbDataAdapter())
                        {
                            cmdExcel.Connection = connExcel;

                            // Get the name of First Sheet
                            connExcel.Open();
                            DataTable dtExcelSchema;
                            dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                            string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();

                            // Get the Column Names
                            DataTable dtCols = connExcel.GetSchema("Columns");
                            DataView  dvCols = new DataView(dtCols);
                            dvCols.RowFilter = "TABLE_NAME = '" + sheetName + "'";
                            dvCols.Sort      = "ORDINAL_POSITION ASC";

                            // Read Column Names and stack them up in a string
                            int ColCount = 0;
                            foreach (DataRowView rowView in dvCols)
                            {
                                DataRow row  = rowView.Row;
                                string  rvcn = rowView["COLUMN_NAME"].ToString(); // Get the Column Name
                                // Make sure the Column Name is NOT F(n), ie; F11, F12
                                if (rvcn.Left(2) != "F1")
                                {
                                    dtColumns1 += rowView["COLUMN_NAME"] + ","; // Column Name NOT F(n), so save it

                                    // Get a Column Name
                                    string ColName = rowView["COLUMN_NAME"].ToString();

                                    // Loop through the Key Field(s) Column Name(s) and Compare Column Name to One or more KeyFields
                                    for (int i = 0; i < arrKeyField.Length; i++)
                                    {
                                        // If Column Name matches the Key Field(s)
                                        if (ColName == arrKeyField[i])
                                        {
                                            ColumnsNumsOfKeyFields += ColCount.ToString() + ",";
                                            //liKf.Add(i);
                                            liKf.Add(ColCount);
                                        }
                                    }
                                    ColCount++;
                                }
                            }
                            dtColumns1Count = ColCount;
                            dtColumns1      = dtColumns1.Left(dtColumns1.Length - 1);
                            connExcel.Close();

                            // Insure that Key Field(s) are listed in Column Names
                            if (!CheckKFsInColNames(arrKeyField, dtColumns1))
                            {
                                bHasError   = true;
                                Output.Text = Output.Text + "One or more Key Field is Not Found in Available File 1 Column Names." + cCrLf;
                            }

                            var ColumnNames = dtColumns1.Split(Convert.ToChar(","));
                            // Iterate through each Column Name and Define it
                            foreach (var ColumnName in ColumnNames)
                            {
                                dt1.Columns.Add(ColumnName, Type.GetType("System.String"));
                            }

                            // Read Data from First Sheet into dt
                            connExcel.Open();
                            cmdExcel.CommandText   = "SELECT * FROM [" + sheetName + "A1:" + NumToLetter(ColCount) + "30000]";
                            odaExcel.SelectCommand = cmdExcel;
                            odaExcel.Fill(dt1);
                            iCount1 = dt1.Rows.Count;
                            connExcel.Close();

                            // Sort dt1 by KeyField(s)
                            if (CheckKFsInColNames(arrKeyField, dtColumns1))
                            {
                                DataView dv1 = dt1.DefaultView;
                                dv1.Sort = KeyField;
                                dt1      = dv1.ToTable();
                            }

                            // Set KeyFields with empty values to some unused character
                            for (int i = 0; i < arrKeyField.Length; i++)
                            {
                                DataRow[] krows = dt1.Select("[" + arrKeyField[i] + "] IS NULL");

                                for (int k = 0; k < krows.Length; k++)
                                {
                                    krows[k][arrKeyField[i]] = "^";
                                }
                            }

                            // Read & Save the values for KeyField from dt1
                            foreach (DataRow row in dt1.Rows)
                            {
                                string keyval         = string.Empty;
                                string KeyValueHolder = string.Empty;
                                for (int i = 0; i < arrKeyField.Length; i++)                              //Read through the KeyField(s) array
                                {
                                    string val = FixNull(row[row.Table.Columns[arrKeyField[i]].Ordinal]); // Get the data Value of a KeyField
                                    if (val.Length > 0)
                                    {
                                        keyval          = val;
                                        keyval          = keyval.Replace("'", "''");
                                        KeyValueHolder += keyval;
                                    }
                                }
                                sFile1KeyFieldValues += "'" + KeyValueHolder + "',";
                            }
                            // Trim off trailing comma
                            sFile1KeyFieldValues = sFile1KeyFieldValues.Left(sFile1KeyFieldValues.Length - 1);
                        }

                // Clean up (delete) files in workfiles folder older than 61 days
                DateTime      CutOffDate = DateTime.Now.AddDays(-61);
                DirectoryInfo di         = new DirectoryInfo(path1);
                FileInfo[]    fi         = di.GetFiles();

                for (int i = 0; i < fi.Length; i++)
                {
                    if (fi[i].LastWriteTime < CutOffDate)
                    {
                        File.Delete(fi[i].FullName);
                    }
                }
            }
            else
            {
                // You did not specify a File1 to upload
                bHasError   = true;
                Output.Text = Output.Text + "No File 1 specified for Upload." + cCrLf;
            }
            //WriteToLog("End - FileUpload1.HasFile");


            // *************************************************************************
            // Process FileUpload2
            // *************************************************************************
            if (FileUpload2.HasFile)
            {
                string filePath2 = string.Empty;

                string path2 = System.Web.HttpContext.Current.Server.MapPath("~/workfiles/");
                if (!Directory.Exists(path2))
                {
                    Directory.CreateDirectory(path2);
                }
                // Get file path
                filePath2 = path2 + Path.GetFileName(FileUpload2.FileName);
                // Get file extenstion
                string extension = Path.GetExtension(FileUpload2.FileName);
                // Get file Name
                string File2OrigName = FileUpload2.FileName;
                // Get KeyField or Fields
                KeyField      = Request.Form["KeyField"].Replace(", ", ","); // Get one or more field names (comma separated)
                arrKeyField   = KeyField.Split(',');                         // Split the files names into a string array
                KeyFieldCount = arrKeyField.Length;                          // Get the number of key files entered
                // Save file on "workfiles" folder of project
                FileUpload2.SaveAs(filePath2);

                string conString = string.Empty;
                // Check file extension
                switch (extension)
                {
                case ".xls":     // Excel 97-03.
                    //conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    // See (https://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine No.6)
                    conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    break;

                case ".xlsx":     // Excel 07 and above.
                    conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'";
                    break;
                }

                // Create datatable object
                conString = string.Format(conString, filePath2);

                // Use OldDb to read excel
                using (OleDbConnection connExcel = new OleDbConnection(conString))
                    using (OleDbCommand cmdExcel = new OleDbCommand())
                    {
                        using (OleDbDataAdapter odaExcel = new OleDbDataAdapter())
                        {
                            cmdExcel.Connection = connExcel;

                            // Get the name of First Sheet
                            connExcel.Open();
                            DataTable dtExcelSchema;
                            dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                            string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();

                            // Get the Column Names
                            DataTable dtCols = connExcel.GetSchema("Columns");
                            DataView  dvCols = new DataView(dtCols);
                            dvCols.RowFilter = "TABLE_NAME = '" + sheetName + "'";
                            dvCols.Sort      = "ORDINAL_POSITION ASC";

                            // Read Column Names and stack them up in a string
                            int    ColCount = 0;
                            string ColumnsNumsOfKeyFields = String.Empty;
                            foreach (DataRowView rowView in dvCols)
                            {
                                DataRow row  = rowView.Row;
                                string  rvcn = rowView["COLUMN_NAME"].ToString(); // Get the Column Name
                                                                                  // Make sure the Column Name is NOT F(n), ie; F11, F12
                                                                                  //string rvcn_right = rvcn.Substring(rvcn.Length - 1);
                                if (rvcn.Left(2) != "F1")
                                {
                                    dtColumns2 += rowView["COLUMN_NAME"] + ","; // Column Name NOT F(n), so save it

                                    // Get a Column Name
                                    string ColName = rowView["COLUMN_NAME"].ToString();

                                    // Loop through the Key Field(s) Column Name(s) and Compare Column Name to One or more KeyFields
                                    for (int i = 0; i < arrKeyField.Length; i++)
                                    {
                                        // If Column Name matches the Key Field(s)
                                        if (ColName == arrKeyField[i])
                                        {
                                            ColumnsNumsOfKeyFields += ColCount.ToString() + ",";
                                        }
                                    }
                                    ColCount++;
                                }
                            }
                            dtColumns2Count = ColCount;
                            dtColumns2      = dtColumns2.Left(dtColumns2.Length - 1);
                            // Trim off trailing comma
                            ColumnsNumsOfKeyFields = ColumnsNumsOfKeyFields.Left(ColumnsNumsOfKeyFields.Length - 1);

                            connExcel.Close();

                            // Insure that Key Field(s) are listed in Column Names
                            if (!CheckKFsInColNames(arrKeyField, dtColumns2))
                            {
                                bHasError   = true;
                                Output.Text = Output.Text + "One or more Key Field is Not Found in Available File 2 Column Names." + cCrLf;
                            }

                            var ColumnNames = dtColumns2.Split(Convert.ToChar(","));
                            // Iterate through each Column Name and Define it
                            foreach (var ColumnName in ColumnNames)
                            {
                                dt2.Columns.Add(ColumnName, Type.GetType("System.String"));
                            }

                            // Read Data from First Sheet into dt2
                            connExcel.Open();
                            cmdExcel.CommandText   = "SELECT * FROM [" + sheetName + "A1:" + NumToLetter(ColCount) + "30000]";
                            odaExcel.SelectCommand = cmdExcel;
                            odaExcel.Fill(dt2);
                            iCount2 = dt2.Rows.Count;
                            connExcel.Close();

                            // Sort dt2 by KeyField(s)
                            if (CheckKFsInColNames(arrKeyField, dtColumns2))
                            {
                                DataView dv2 = dt2.DefaultView;
                                dv2.Sort = KeyField;
                                dt2      = dv2.ToTable();
                            }

                            // Set KeyFields with empty values to some unused character
                            for (int i = 0; i < arrKeyField.Length; i++)
                            {
                                DataRow[] krows = dt2.Select("[" + arrKeyField[i] + "] IS NULL");

                                for (int k = 0; k < krows.Length; k++)
                                {
                                    krows[k][arrKeyField[i]] = "^";
                                }
                            }

                            // Read & Save the values for KeyField from dt2
                            foreach (DataRow row in dt2.Rows)
                            {
                                string keyval         = string.Empty;
                                string KeyValueHolder = string.Empty;
                                for (int i = 0; i < arrKeyField.Length; i++)                              //Read through the KeyField(s) array
                                {
                                    string val = FixNull(row[row.Table.Columns[arrKeyField[i]].Ordinal]); // Get the data Value of a KeyField
                                    if (val.Length > 0)
                                    {
                                        keyval          = val;
                                        keyval          = keyval.Replace("'", "''");
                                        KeyValueHolder += keyval;
                                    }
                                }
                                sFile2KeyFieldValues += "'" + KeyValueHolder + "',";
                            }
                            // Trim off trailing comma
                            sFile2KeyFieldValues = sFile2KeyFieldValues.Left(sFile2KeyFieldValues.Length - 1);
                        }
                    }

                OutputDiv.Visible = true;
            }
            else
            {
                // You did not specify a File2 to upload
                bHasError   = true;
                Output.Text = Output.Text + "No File 2 specified for Upload." + cCrLf;
            }

            //WriteToLog("End - FileUpload2.HasFile");

            Output.Text = Output.Text + "File 1 Column Names: " + dtColumns1 + cCrLf;
            Output.Text = Output.Text + "File 1 Record Count: " + iCount1 + cCrLf + cCrLf;

            Output.Text = Output.Text + "File 2 Column Names: " + dtColumns2 + cCrLf;
            Output.Text = Output.Text + "File 2 Record Count: " + iCount2 + cCrLf + cCrLf;

            if (dtColumns1 != dtColumns2)
            {
                bHasError   = true;
                Output.Text = Output.Text + "File 1 and File 2 Column Names DO NOT MATCH." + cCrLf;
            }


            // Timer: With ~18K records in each file: 1 minute to get to here

            if (!bHasError)
            {
                //WriteToLog("Start Compares");
                // Start Compares
                // ********************************
                // Define dtRowsIn1NotIn2 datatable
                // ********************************
                var ColumnNames = dtColumns1.Split(Convert.ToChar(","));
                // Iterate through each Column Name and Define it
                foreach (var ColumnName in ColumnNames)
                {
                    dtRowsIn1NotIn2.Columns.Add(ColumnName, Type.GetType("System.String"));
                }

                // Find Rows in dt1 that are not in dt2 using KeyField(s)
                //([Last Name]+[First Name]) NOT IN
                string query = GetKFsForSelect(arrKeyField) + " NOT IN(" + sFile2KeyFieldValues.Left(sFile2KeyFieldValues.Length - 1) + "')";
                foundRows1 = dt1.Select(query);
                if (foundRows1.Length != 0)
                {
                    dtRowsIn1NotIn2 = foundRows1.CopyToDataTable();
                }

                // Set KeyFields with some unused character back to empty values
                for (int i = 0; i < arrKeyField.Length; i++)
                {
                    DataRow[] krows = dtRowsIn1NotIn2.Select("[" + arrKeyField[i] + "] = '^'");

                    for (int k = 0; k < krows.Length; k++)
                    {
                        krows[k][arrKeyField[i]] = string.Empty;
                    }
                }

                // bind datatable with GridView
                GridView1.DataSource = dtRowsIn1NotIn2;
                GridView1.DataBind();

                // Write dtRowsIn1NotIn2 out as CSV
                //dtRowsIn1NotIn2.WriteToCsvFile(System.Web.HttpContext.Current.Server.MapPath("~/workfiles/") + Path.GetFileName(FileUpload1.FileName) + "_RowsInFile1NotInFile2.csv");


                // ********************************
                // Define dtRowsIn2NotIn1 datatable
                // ********************************
                ColumnNames = dtColumns2.Split(Convert.ToChar(","));
                // Iterate through each Column Name and Define it
                foreach (var ColumnName in ColumnNames)
                {
                    dtRowsIn2NotIn1.Columns.Add(ColumnName, Type.GetType("System.String"));
                }

                // Find Rows in dt2 that are not in dt1 using KeyField
                query      = GetKFsForSelect(arrKeyField) + " NOT IN(" + sFile1KeyFieldValues.Left(sFile1KeyFieldValues.Length - 1) + "')";
                foundRows2 = dt2.Select(query);
                if (foundRows2.Length != 0)
                {
                    dtRowsIn2NotIn1 = foundRows2.CopyToDataTable();
                }

                // Set KeyFields with some unused character back to empty values
                for (int i = 0; i < arrKeyField.Length; i++)
                {
                    DataRow[] krows = dtRowsIn2NotIn1.Select("[" + arrKeyField[i] + "] = '^'");

                    for (int k = 0; k < krows.Length; k++)
                    {
                        krows[k][arrKeyField[i]] = string.Empty;
                    }
                }

                // bind datatable with GridView
                GridView2.DataSource = dtRowsIn2NotIn1;
                GridView2.DataBind();


                // ***********************************
                // Define dtRowsIn2DiffFrom1 datatable
                // ***********************************
                //WriteToLog("Start Define dtRowsIn2DiffFrom1");
                ColumnNames = dtColumns2.Split(Convert.ToChar(","));
                // Iterate through each Column Name
                foreach (var ColumnName in ColumnNames)
                {
                    dt1dt2MatchedRows.Columns.Add(ColumnName, Type.GetType("System.String"));
                }

                // Timer: With ~18K records in each file: 1 minute 30 seconds to get to here

                // Read & Save the values for KeyField from dt1dt2MatchedRows
                dtRowsColsToChgColor.Columns.Add("KeyFieldValue", Type.GetType("System.String"));
                dtRowsColsToChgColor.Columns.Add("Column", Type.GetType("System.Int32"));

                int    ii     = 0;
                int    fr     = 0;
                string frLast = "xx";

                foreach (DataRow rowdt1 in dt1.Rows)    // Read through dt1 for KeyField(s) matches found in dt2
                {
                    int index2 = 0;
                    // Build query w/ func to get KeyField name(s) & func to get actual KeyField(s) data values
                    query = GetKFsForSelect(arrKeyField) + "=" + GetKFsValuesForSelect(rowdt1, arrKeyField);
                    // Query will look something like this: ([Last Name]+[First Name])='AbadirMaher'
                    foundRows3 = dt2.Select(query);
                    // Get the data Value of a KeyField
                    string keyvalueholder = string.Empty;
                    for (int l = 0; l < liKf.Count; l++)
                    {
                        keyvalueholder += FixNull(rowdt1[liKf[l]]).Replace("'", "''");
                    }
                    // See if foundRows3
                    if (foundRows3.Length > 0)  // If we have query hits
                    {
                        if (foundRows3.Length > 1)
                        {
                            index2 = 1;
                        }
                        //Output.Text = Output.Text + "KeyFieldValue: " + keyvalueholder + cCrLf;
                        //Output.Text = Output.Text + "foundRows3.Length: " + foundRows3.Length + cCrLf +"-----------------------------" + cCrLf;
                        for (fr = index2; fr <= foundRows3.GetUpperBound(0); fr++)
                        {
                            //if (frLast == keyvalueholder && foundRows3.GetUpperBound(0) < 3 && foundRows3.GetUpperBound(0) > fr) fr++;
                            if (frLast == keyvalueholder && foundRows3.GetUpperBound(0) < foundRows3.Length && foundRows3.GetUpperBound(0) > fr)
                            {
                                fr++;
                            }
                            var array1 = rowdt1.ItemArray;          // Get record array from dt1
                            var array2 = foundRows3[fr].ItemArray;  // Get record array from foundRows3

                            // Read all Columns
                            bool b1 = false;
                            for (ii = 0; ii <= array1.Length - 1; ii++)     // Process array1 record (from dt1)
                            {
                                // No compares on KeyFields - Yes on Diffs(!=) between array1 (dt1) & array2 (foundRows3)
                                //if (!liKf.Contains(ii) && array1[ii].ToString() != array2[ii].ToString())
                                if (!liKf.Contains(ii) && !string.Equals(array1[ii].ToString(), array2[ii].ToString(), StringComparison.OrdinalIgnoreCase))
                                {
                                    dtRowsColsToChgColor.Rows.Add(keyvalueholder, ii);  // Add keyfields data & the index of column that is !=
                                    b1 = true;
                                }
                            }
                            frLast = keyvalueholder;    // Save off last key value
                            if (!b1)
                            {
                                break;
                            }
                        }
                    }
                } // foreach (DataRow rowdt1 in dt1.Rows)    // Read through dt1 for KeyFiled(s) matches found in dt2

                // Timer: With ~18K records in each file: 20 minutes to get to here

                // ***********************************
                // Define dtFileOneTwoMrg datatable
                // ***********************************
                //WriteToLog("Start Define dtFileOneTwoMrg");
                ColumnNames = dtColumns2.Split(Convert.ToChar(","));
                // Iterate through each Column Name
                foreach (var ColumnName in ColumnNames)
                {
                    dtFileOneTwoMrg.Columns.Add(ColumnName, Type.GetType("System.String"));
                }

                // Read from dtRowsColsToChgColor for KeyFieldValue
                string savedKeyFieldValue = "x";
                foreach (DataRow rowCC in dtRowsColsToChgColor.Rows)
                {
                    if (savedKeyFieldValue != (string)rowCC["KeyFieldValue"])
                    {
                        // Start Find & Add record from dt1 and add row to dtFileOneTwoMrg
                        query = GetKFsForSelect(arrKeyField) + "='" + rowCC["KeyFieldValue"] + "'";
                        // Query will look something like this: ([Last Name]+[First Name])='AaronBenjamin'
                        foundRows1 = dt1.Select(query);
                        if (foundRows1.Length > 0)  // If we have query hits
                        // Read from foundRows1 (dt1) for record hit
                        {
                            var     array1 = foundRows1[0].ItemArray;    // Get record array from foundRows1 (dt1)
                            DataRow row    = dtFileOneTwoMrg.NewRow();

                            for (ii = 0; ii <= array1.Length - 1; ii++)
                            {
                                row[ii] = array1[ii].ToString();
                            }
                            dtFileOneTwoMrg.Rows.Add(row);  // Add dt1.KeyFieldValue row to dtFileOneTwoMrg
                        }
                        // End Find & Add record from dt1 and add row to dtFileOneTwoMrg


                        // Start Find & Add record from dt2 and add row to dtFileOneTwoMrg
                        // Use the same query as above
                        // Query will look something like this: ([Last Name]+[First Name])='AaronBenjamin'
                        foundRows2 = dt2.Select(query);
                        // Read from foundRows2 (dt2) for record hit
                        if (foundRows2.Length > 0)  // If we have query hits
                        {
                            var array2 = foundRows2[0].ItemArray;
                            if (foundRows2.Length > 1)
                            {
                                array2 = foundRows2[1].ItemArray;                           // Get record array from foundRows2 (dt2)
                            }
                            DataRow row = dtFileOneTwoMrg.NewRow();

                            for (ii = 0; ii <= array2.Length - 1; ii++)
                            {
                                row[ii] = array2[ii].ToString();
                            }
                            dtFileOneTwoMrg.Rows.Add(row);  // Add dt2.KeyFieldValue row to dtFileOneTwoMrg
                        }
                        // End Find & Add record from dt2 and add row to dtFileOneTwoMrg
                        savedKeyFieldValue = (string)rowCC["KeyFieldValue"];
                    }
                }

                // Set KeyFields with some unused character back to empty values
                for (int i = 0; i < arrKeyField.Length; i++)
                {
                    DataRow[] krows = dtFileOneTwoMrg.Select("[" + arrKeyField[i] + "] = '^'");

                    for (int k = 0; k < krows.Length; k++)
                    {
                        krows[k][arrKeyField[i]] = string.Empty;
                    }
                }

                // Bind datatable with GridView
                //WriteToLog("Start GridView3.DataBind");

                GridView3.DataSource = dtFileOneTwoMrg;
                GridView3.DataBind();

                // Set the ForeColors for before and after data diffs
                int GV3rowCount = 0;
                savedKeyFieldValue = "x";   // Default savedKeyFieldValue to "x"

                foreach (DataRow rowCC in dtRowsColsToChgColor.Rows)
                {
                    int cc = (int)rowCC["Column"];                            // Save off cc (Cell Count)

                    if (savedKeyFieldValue != (string)rowCC["KeyFieldValue"]) // Process unique KeyFieldValue values
                    {
                        GridView3.Rows[GV3rowCount].Cells[cc].ForeColor     = Color.Green;
                        GridView3.Rows[GV3rowCount + 1].Cells[cc].ForeColor = Color.Red;
                        GV3rowCount += 2;
                    }
                    else
                    {
                        GridView3.Rows[GV3rowCount - 2].Cells[cc].ForeColor = Color.Green;
                        GridView3.Rows[GV3rowCount - 1].Cells[cc].ForeColor = Color.Red;
                    }
                    // Save off KeyFieldValue for next iteration
                    savedKeyFieldValue = (string)rowCC["KeyFieldValue"];
                }
            }

            // Set up for the GridViews exports to Excel
            Microsoft.Office.Interop.Excel._Application app      = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook    workbook = app.Workbooks.Add(Type.Missing);



            // Call the function (ExportToExcel) to export each Gridview to Execel
            ExportToExcel(app, workbook, GridView3, "RowsInFile2DiffThanFile1", 2);
            ExportToExcel(app, workbook, GridView2, "RowsInFile2NotInFile1", 1);
            ExportToExcel(app, workbook, GridView1, "RowsInFile1NotInFile2", 0);

            string url = SaveExportToExcel(workbook);

            url_label.Text = "<a href='" + url + "'" + "target='_blank' />Download Excel Results</a>";
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label19.Visible = true;



            string ins_name = TextBox6.Text;
            string phone1   = TextBox8.Text;
            string phone2   = TextBox9.Text;
            string ins_web  = TextBox10.Text;
            string email1   = TextBox11.Text;
            string street   = TextBox12.Text;
            string email2   = TextBox13.Text;
            string pin      = TextBox7.Text;
            string fax      = TextBox15.Text;
            string hoi      = TextBox17.Text;
            string t_hoi    = TextBox18.Text;
            string desc     = TextBox16.Text;

            if (ins_name == "" || ins_name == null)
            {
                Label19.Text = "Please enter the Institute name";
            }
            else if (phone1 == "" || phone1 == null)
            {
                Label19.Text = "Please enter institute's primary contact number";
            }
            else if (ins_web == "" || ins_web == null)
            {
                Label19.Text = "Please enter the institutes website";
            }
            else if (email1 == "" || email1 == null)
            {
                Label19.Text = "Please enter the institutes primary email id";
            }
            else if (street == "" || street == null)
            {
                Label19.Text = "Please enter the street address of the institute";
            }
            else if (pin == "" || pin == null)
            {
                Label19.Text = "Please enter the pin ";
            }
            else if (hoi == "" || hoi == null)
            {
                Label19.Text = "Please enter the name of head of institute";
            }
            else if (t_hoi == "" || t_hoi == null)
            {
                Label19.Text = "Please enter the title of head of institute";
            }
            else if (desc == "" || desc == null)
            {
                Label19.Text = "Please enter a brief description about ur institute";
            }
            else
            {
                if (phone2 == null || phone2 == "")
                {
                    phone2 = "null";
                }
                if (email2 == null || email2 == "")
                {
                    email2 = "null";
                }
                if (fax == null || fax == "")
                {
                    fax = "null";
                }
                //Uploading Logo
                string path = Server.MapPath("~/Images");
                if (FileUpload1.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload1.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload1.SaveAs(path + FileUpload1.FileName);
                        string pic_name = FileUpload1.FileName.ToString();
                        logo = "http://192.168.1.20:8085/Images/" + pic_name;
                    }
                }
                // Uploading pic
                path = Server.MapPath("~/Images");
                if (FileUpload2.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload2.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload2.SaveAs(path + FileUpload2.FileName);
                        string pic_name = FileUpload1.FileName.ToString();
                        photo = "http://192.168.1.20:8085/Images/" + pic_name;
                    }
                }
                string sql1 = "update Edu_Inst1 set Inst_name='" + ins_name + "',Inst_web='" + ins_web + "',Street='" + street + "',Fax='" + fax + "',Pin='" + pin + "',Inst_phone='" + phone1 + "',Inst_phone2='" + phone2 + "',Inst_email='" + email1 + "',Inst_email2='" + email2 + "',Inst_logo='" + logo + "',Inst_photo='" + photo + "',HOI='" + hoi + "',Title_HOI='" + t_hoi + "',isVerified=" + 0 + ",Modified_on='" + DateTime.Now.ToString() + "',Description='" + desc + "' where Admin_id='" + Session["x"].ToString() + "'";
                cmd = new SqlCommand(sql1, con);
                con.Open();
                int res = cmd.ExecuteNonQuery();
                if (res >= 1)
                {
                    Label19.Visible = true;
                }
                else
                {
                    Label19.Text = "Update failed ! Please try later";
                }
                con.Close();
            }
        }
Beispiel #16
0
        private void saveUpLoadedFilesAZFO()
        {
            _fileSave = false;
            bool fileSave1 = true;
            bool fileSave2 = true;
            bool fileSave3 = true;
            bool fileSave4 = true;

            LabelFileType1.Visible = false;
            LabelFileType2.Visible = false;
            LabelFileType3.Visible = false;
            LabelFileType4.Visible = false;

            string file1          = azfoSubmit.getFileName;
            char   delimiterChars = '.';

            if (FileUpload1.FileName != string.Empty)
            {
                LabelFileType1.Visible = false;

                if (validateFileExtension(FileUpload1))
                {
                    // what kind of file is this
                    //FileInfo f = new FileInfo(FileUpload1.FileName);
                    //string extension = f.Extension;
                    string extension = Path.GetExtension(FileUpload1.FileName).ToLower();

                    _file1Name         = string.Format("{0}_a{1}", file1, extension);
                    _filename1FullPath = string.Format("{0}{1}_a{2}", azfoSubmit.getImagePath, file1, extension);

                    FileUpload1.SaveAs(_filename1FullPath);
                    //_image1 = string.Format("<p><img src='../submittedImages/{0}' width='600' height='464' border='0' align='bottom'></p>", file1Name);
                    _image1 = string.Format("<p><img src='../submittedImages/{0}' border='0' align='bottom' width ='750'></p>", _file1Name);
                }
                else
                {
                    LabelFileType1.Text    = "Only image files are accepted";
                    LabelFileType1.Visible = true;
                    fileSave1 = false;
                }
            }
            if (FileUpload2.FileName != string.Empty)
            {
                LabelFileType2.Visible = false;

                if (validateFileExtension(FileUpload2))
                {
                    // what kind of file is this
                    //FileInfo f = new FileInfo(FileUpload2.FileName);
                    //string extension = f.Extension;
                    string extension = Path.GetExtension(FileUpload2.FileName).ToLower();
                    string file2Name = string.Format("{0}_b{1}", file1, extension);
                    _filename2FullPath = string.Format("{0}{1}_b{2}", azfoSubmit.getImagePath, file1, extension);

                    FileUpload2.SaveAs(_filename2FullPath);
                    _image2 = string.Format("<p><img src='../submittedImages/{0}' border='0' align='bottom' width ='750'></p>", file2Name);
                }
                else
                {
                    LabelFileType2.Text    = "Only image files are accepted";
                    LabelFileType2.Visible = true;
                    fileSave2 = false;
                }
            }
            if (FileUpload3.FileName != string.Empty)
            {
                LabelFileType3.Visible = false;

                if (validateFileExtension(FileUpload3))
                {
                    // what kind of file is this
                    //FileInfo f = new FileInfo(FileUpload3.FileName);
                    //string extension = f.Extension;
                    string extension = Path.GetExtension(FileUpload3.FileName).ToLower();
                    string file3Name = string.Format("{0}_c{1}", file1, extension);
                    _filename3FullPath = string.Format("{0}{1}_c{2}", azfoSubmit.getImagePath, file1, extension);

                    FileUpload3.SaveAs(_filename3FullPath);
                    _image3 = string.Format("<p><img src='../submittedImages/{0}' border='0' align='bottom' width ='750'></p>", file3Name);
                }
                else
                {
                    LabelFileType3.Text    = "Only image files are accepted";
                    LabelFileType3.Visible = true;
                    fileSave3 = false;
                }
            }
            if (FileUpload4.FileName != string.Empty)
            {
                LabelFileType4.Visible = false;

                if (validateFileExtension(FileUpload4))
                {
                    // what kind of file is this
                    //FileInfo f = new FileInfo(FileUpload4.FileName);
                    //string extension = f.Extension;
                    string extension = Path.GetExtension(FileUpload4.FileName).ToLower();
                    string file4Name = string.Format("{0}_d{1}", file1, extension);
                    _filename4FullPath = string.Format("{0}{1}_d{2}", azfoSubmit.getImagePath, file1, extension);

                    FileUpload4.SaveAs(_filename4FullPath);
                    _image4 = string.Format("<p><img src='../submittedImages/{0}' border='0' align='bottom' width ='750'></p>", file4Name);
                }
                else
                {
                    LabelFileType4.Text    = "Only image files are accepted";
                    LabelFileType4.Visible = true;
                    fileSave4 = false;
                }
            }

            if (fileSave1 == true && fileSave2 == true && fileSave3 == true && fileSave4 == true)
            {
                _fileSave = true;
            }
        }
    protected void submit_Click(object sender, EventArgs e)
    {
        String path = Server.MapPath("~/Menu/");

        if (ShopName.Text.Trim().Length == 0)
        {
            AlertMessage("請記得輸入店家名稱!");
            return;
        }

        if (FileUpload1.HasFile)
        {
            FileInfo file = new FileInfo(path + FileUpload1.FileName);
            if (file.Exists)
            {
                AlertMessage("第一個上傳菜單已經有相同名稱的檔名,麻煩請修改檔名再上傳");
                return;
            }
        }
        if (FileUpload2.HasFile)
        {
            FileInfo file = new FileInfo(path + FileUpload2.FileName);
            if (file.Exists)
            {
                AlertMessage("第二個上傳菜單已經有相同名稱的檔名,麻煩請修改檔名再上傳");
                return;
            }
        }

        Guid ShopID = Guid.NewGuid();

        using (SqlConnection conn = new SqlConnection(DBTools.ConnectionString))
        {
            conn.Open();
            string sqlstr = @"insert into ShopHead (ShopID,ShopName,CreateDateTime,IsCancel,CategoryID,IsVegetarianismShop) 
                            values (@ShopID,@ShopName,@CreateDateTime,@IsCancel,@CategoryID,@IsVegetarianismShop)";
            using (SqlCommand cmd = new SqlCommand(sqlstr, conn, conn.BeginTransaction("Order")))
            {
                try
                {
                    cmd.Parameters.Add(new SqlParameter("@ShopID", SqlDbType.UniqueIdentifier));
                    cmd.Parameters[0].Value = ShopID;
                    cmd.Parameters.Add(new SqlParameter("@ShopName", SqlDbType.NVarChar, 20));
                    cmd.Parameters[1].Value = ShopName.Text.Trim();
                    cmd.Parameters.Add(new SqlParameter("@CreateDateTime", SqlDbType.DateTime));
                    cmd.Parameters[2].Value = DateTime.Now;
                    cmd.Parameters.Add(new SqlParameter("@IsCancel", SqlDbType.Bit));
                    cmd.Parameters[3].Value = false;
                    cmd.Parameters.Add(new SqlParameter("@CategoryID", SqlDbType.TinyInt));
                    cmd.Parameters[4].Value = MenuType.SelectedValue;
                    cmd.Parameters.Add(new SqlParameter("@IsVegetarianismShop", SqlDbType.Bit));
                    cmd.Parameters[5].Value = Convert.ToBoolean(IsVegetarianismShop.SelectedValue);
                    cmd.ExecuteNonQuery();

                    if (FileUpload1.HasFile)
                    {
                        cmd.CommandText = "insert into MenuImg (ShopID,FileName) values (@ShopID,@FileName)";
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add(new SqlParameter("@ShopID", SqlDbType.UniqueIdentifier));
                        cmd.Parameters[0].Value = ShopID;
                        cmd.Parameters.Add(new SqlParameter("@FileName", SqlDbType.NVarChar, 20));
                        cmd.Parameters[1].Value = FileUpload1.FileName;
                        cmd.ExecuteNonQuery();
                        FileUpload1.SaveAs(Request.PhysicalApplicationPath + "\\Menu\\" + FileUpload1.FileName);
                    }
                    if (FileUpload2.HasFile)
                    {
                        cmd.CommandText = "insert into MenuImg (ShopID,FileName) values (@ShopID,@FileName)";
                        cmd.Parameters.Clear();
                        cmd.Parameters.Add(new SqlParameter("@ShopID", SqlDbType.UniqueIdentifier));
                        cmd.Parameters[0].Value = ShopID;
                        cmd.Parameters.Add(new SqlParameter("@FileName", SqlDbType.NVarChar, 20));
                        cmd.Parameters[1].Value = FileUpload2.FileName;
                        cmd.ExecuteNonQuery();
                        FileUpload2.SaveAs(Request.PhysicalApplicationPath + "\\Menu\\" + FileUpload2.FileName);
                    }
                    cmd.Transaction.Commit();
                }
                catch (SqlException SE)
                {
                    cmd.Transaction.Rollback();
                    AlertMessage(SE.Message);
                    ErrorLog(SE);
                }
                catch (Exception EX)
                {
                    cmd.Transaction.Rollback();
                    AlertMessage(EX.Message);
                    ErrorLog(EX);
                }
                string blockjs = null;
                if (Request.Browser.Type.Equals("IE8") || Request.Browser.Type.Equals("IE7"))
                {
                    Response.Write("<script>alert('新增店家「" + HttpUtility.HtmlEncode(ShopName.Text) + "」成功');location.href='ShopList.aspx';</script>");
                }
                else
                {
                    blockjs = @"swal({title:""新增店家「" + HttpUtility.HtmlEncode(ShopName.Text.Trim()) + @"」成功"",text: ""三秒後進入店家列表"",type:""success"",timer: 3000,showConfirmButton: false},
                                function(){
                                    location.href='ShopList.aspx';
                                })";
                }
                ShowAlert(blockjs);
            }
        }
    }
Beispiel #18
0
 protected void btnSubmitData_Click(object sender, EventArgs e)
 {
     #region VALidation
     if (txtApplicantName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter your name!');</script>");
         txtApplicantName.Focus();
         return;
     }
     else if (txtFathersName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter father name!');</script>");
         txtApplicantName.Focus();
         return;
     }
     else if (txtMothersName.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter mothers name!');</script>");
         txtMothersName.Focus();
         return;
     }
     else if (txtDOB.Value == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please select Date of birth!');</script>");
         txtDOB.Focus();
         return;
     }
     else if (txtUIDNumber.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter UID Number!');</script>");
         txtUIDNumber.Focus();
         return;
     }
     else if (txt10Schoolname.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 10 School name!');</script>");
         txt10Schoolname.Focus();
         return;
     }
     else if (txt10thBoard.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 10 Board ie. U.p Board/CBSE!');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt10RollNo.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please Enter Roll No');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt10YoP.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter year of passing for 10!');</script>");
         txt10YoP.Focus();
         return;
     }
     else if (txt10TotalMarks.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Total marks fro 10!');</script>");
         txt10TotalMarks.Focus();
         return;
     }
     else if (txt10MarksObtained.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter marks obtained for 10!');</script>");
         txt10MarksObtained.Focus();
         return;
     }
     else if (txt10Percentage.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter percentage for 10!');</script>");
         txt10Percentage.Focus();
         return;
     }
     else if (txt12Schoolname.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 12 School name!');</script>");
         txt10Schoolname.Focus();
         return;
     }
     else if (txt12thBoard.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please enter 12 Board ie. U.p Board/CBSE!');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt12RollNo.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Please Enter Roll No');</script>");
         txt10thBoard.Focus();
         return;
     }
     else if (txt12YoP.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 Year of Passing!');</script>");
         txt12YoP.Focus();
         return;
     }
     else if (txt12TotalMarks.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 total marks!');</script>");
         txt12TotalMarks.Focus();
         return;
     }
     else if (txt12MarksObtained.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 marks obtained!');</script>");
         txt12MarksObtained.Focus();
         return;
     }
     else if (txt12Percentage.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter 12 percentage!');</script>");
         txt12Percentage.Focus();
         return;
     }
     else if (txtAddressCorr.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Correspondence Address!');</script>");
         txtAddressCorr.Focus();
         return;
     }
     else if (txtPinCorr.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter pin code!');</script>");
         txtPinCorr.Focus();
         return;
     }
     else if (ddlDIsrictCorr.SelectedValue == "0")
     {
         Response.Write("<script type='text/javascript'>alert('select District Name!');</script>");
         ddlDIsrictCorr.Focus();
         return;
     }
     else if (txtAddress_per.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Permanent Address!');</script>");
         txtAddress_per.Focus();
         return;
     }
     else if (txtPin_Per.Value.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Pin Code for permanent address!');</script>");
         txtPin_Per.Focus();
         return;
     }
     else if (ddlDIsrictCorr.SelectedValue == "0")
     {
         Response.Write("<script type='text/javascript'>alert('select District!');</script>");
         ddlDIsrictCorr.Focus();
         return;
     }
     else if (txtCategory.Text.Trim() == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Category!');</script>");
         txtCategory.Focus();
         return;
     }
     else if (Session["photoFileName"] == null)
     {
         Response.Write("<script type='text/javascript'>alert('Upload Photograph!');</script>");
         FileUpload1.Focus();
         return;
     }
     else if (Session["SignFileName"] == null)
     {
         Response.Write("<script type='text/javascript'>alert('Upload Signature!');</script>");
         FileUpload2.Focus();
         return;
     }
     else if (email.Text == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Email ID!');</script>");
         email.Focus();
         return;
     }
     else if (phone.Text == string.Empty)
     {
         Response.Write("<script type='text/javascript'>alert('Enter Phone Number!');</script>");
         phone.Focus();
         return;
     }
     else if (!chkAccepttheAgreement.Checked)
     {
         Response.Write("<script type='text/javascript'>alert('Please Select the Declaration Agreement!');</script>");
         chkAccepttheAgreement.Focus();
         return;
     }
     #endregion
     UserRegistration user = new UserRegistration();
     user.Name                    = txtApplicantName.Value;
     user.FatherName              = txtFathersName.Value;
     user.MothersName             = txtMothersName.Value;
     user.DOB                     = txtDOB.Value;
     user.UID_No                  = txtUIDNumber.Value;
     user.school_Name_HSS         = txt10Schoolname.Value;
     user.Board_Name_HSS          = txt10thBoard.Value;
     user.Roll_No_HSS             = txt10RollNo.Value;
     user.YOP_HSS                 = txt10YoP.Value;
     user.Total_Marks_HSS         = txt10TotalMarks.Value;
     user.Marks_Obtained_HSS      = txt10MarksObtained.Value;
     user.Marks_Perc_HSS          = txt10Percentage.Value;
     user.school_Name_SSC         = txt12Schoolname.Value;
     user.Board_Name_SSC          = txt12thBoard.Value;
     user.Roll_No_SSC             = txt12RollNo.Value;
     user.YOP_SSC                 = txt12YoP.Value;
     user.Total_Marks_SSC         = txt12TotalMarks.Value;
     user.Marks_Obtained_SSC      = txt12MarksObtained.Value;
     user.Marks_Per_SSC           = txt12Percentage.Value;
     user.AddressPermanent        = txtAddress_per.Text;
     user.PinCodePermanent        = txtPin_Per.Value;
     user.DistrictPermanent       = ddlDistrict.SelectedValue;
     user.StatePermanent          = ddlState.SelectedValue;
     user.AddressCorrespondence   = txtAddressCorr.Text;
     user.PinCodeCorrespondence   = txtPinCorr.Value;
     user.DistrictCorrespondence  = ddlDIsrictCorr.SelectedValue;
     user.StateCorrespondence     = ddlState.SelectedValue;
     user.PictureName             = Session["photoFileName"].ToString();
     user.Signature               = Session["SignFileName"].ToString();
     user.RegistrationMode        = "Education";
     user.Candidate_Category      = txtCategory.Text;
     user.isEconomicalDisabledGen = ChkEcDisabledGen.Checked == true ? true : false;
     int CandidateId = 0;
     if (new Utilities().submitUserData(user, ref CandidateId))
     {
         doPayment(user);
         string RegistrationNumber = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + CandidateId;
         // Response.Write("<script type='text/javascript'>alert('Candidate Registered With Registration Number " + RegistrationNumber + "');</script>");
     }
 }
Beispiel #19
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string filePath1 = "C:\\ASP2019\\0322ASP\\resimg\\" + FileUpload1.FileName;
        string filePath2 = "C:\\ASP2019\\0322ASP\\resimg\\" + FileUpload2.FileName;
        string filePath3 = "C:\\ASP2019\\0322ASP\\resimg\\" + FileUpload3.FileName;
        string filePath4 = "C:\\ASP2019\\0322ASP\\resimg\\" + FileUpload4.FileName;
        string filePath5 = "C:\\ASP2019\\0322ASP\\resimg\\" + FileUpload5.FileName;

        FileUpload1.SaveAs(filePath1);
        FileUpload2.SaveAs(filePath2);
        FileUpload3.SaveAs(filePath3);
        FileUpload4.SaveAs(filePath4);
        FileUpload5.SaveAs(filePath5);

        string imageUrl1 = "~/resimg/" + FileUpload1.FileName;
        string imageUrl2 = "~/resimg/" + FileUpload2.FileName;
        string imageUrl3 = "~/resimg/" + FileUpload3.FileName;
        string imageUrl4 = "~/resimg/" + FileUpload4.FileName;
        string imageUrl5 = "~/resimg/" + FileUpload5.FileName;

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyAspDB"].ConnectionString);
        SqlCommand    cmd = new SqlCommand("RoomInsert4", con);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@resimg1", imageUrl1);
        cmd.Parameters.AddWithValue("@resimg2", imageUrl2);
        cmd.Parameters.AddWithValue("@resimg3", imageUrl3);
        cmd.Parameters.AddWithValue("@resimg4", imageUrl4);
        cmd.Parameters.AddWithValue("@resimg5", imageUrl5);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();



        SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["MyAspDB"].ConnectionString);
        SqlCommand    cmd1 = new SqlCommand("RoomInsert6", con1);

        cmd1.CommandType = CommandType.StoredProcedure;

        cmd1.Parameters.AddWithValue("@KeyWord1", RoomsKeyWord.Text);
        cmd1.Parameters.AddWithValue("@KeyWord2", RoomsKeyWord1.Text);
        cmd1.Parameters.AddWithValue("@KeyWord3", RoomsKeyWord2.Text);
        cmd1.Parameters.AddWithValue("@KeyWord4", RoomsKeyWord3.Text);
        cmd1.Parameters.AddWithValue("@KeyWord5", RoomsKeyWord4.Text);

        con1.Open();
        cmd1.ExecuteNonQuery();
        con1.Close();

        SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["MyAspDB"].ConnectionString);


        SqlCommand cmd2 = new SqlCommand("RoomInsert5", con2);

        cmd2.CommandType = CommandType.StoredProcedure;

        cmd2.Parameters.AddWithValue("@resname", RoomsName.Text);
        cmd2.Parameters.AddWithValue("@resaddr", resaddr.Text);
        cmd2.Parameters.AddWithValue("@resevt", resevt.Text);
        cmd2.Parameters.AddWithValue("@resinfo", resinfo.Text);
        cmd2.Parameters.AddWithValue("@rescom", rescom.Text);
        cmd2.Parameters.AddWithValue("@lcode", DropDownList1.SelectedValue);
        con2.Open();
        cmd2.ExecuteNonQuery();
        con2.Close();

        SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["MyAspDB"].ConnectionString);

        SqlCommand cmd3 = new SqlCommand("RoomInsert7", con3);

        cmd3.CommandType = CommandType.StoredProcedure;

        cmd3.Parameters.AddWithValue("@wasmac", WASMAC);
        cmd3.Parameters.AddWithValue("@paklot", PAKLOT);
        cmd3.Parameters.AddWithValue("@bbq", BBQ);
        cmd3.Parameters.AddWithValue("@wifi", WIFI);
        cmd3.Parameters.AddWithValue("@resfri", RESFRI);
        cmd3.Parameters.AddWithValue("@resair", RESAIR);
        cmd3.Parameters.AddWithValue("@resbat", RESBAT);
        cmd3.Parameters.AddWithValue("@restv", RESTV);
        cmd3.Parameters.AddWithValue("@brkfat", BRKFAT);
        cmd3.Parameters.AddWithValue("@pet", PET);
        cmd3.Parameters.AddWithValue("@somke", SOMKE);
        cmd3.Parameters.AddWithValue("@event", EVENT);

        con3.Open();
        cmd3.ExecuteNonQuery();
        con3.Close();
    }
Beispiel #20
0
    protected void team_save_click(object sender, EventArgs e)
    {
        ////////////////////////////1
        if (FileUpload1.HasFile)
        {
            if (!Directory.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/", "1"))))
            {
                Directory.CreateDirectory(Server.MapPath(string.Format("~/Npanel/image/{0}/", "1")));
            }

            if (File.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "1", "1"))))
            {
                File.Delete(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "1", "1")));
            }

            FileUpload1.SaveAs(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "1", "1")));

            if (FileUpload1.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(FileUpload1.FileName);

                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg")
                {
                    Stream strm = FileUpload1.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Print Original Size of file (Height or Width)
                        int newWidth   = 400; // New Width of Image in Pixel
                        int newHeight  = 350; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string targetPath = Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "1", "1"));
                        thumbImg.Save(targetPath, image.RawFormat);
                        // Print new Size of file (height or Width)
                        //Show Image
                    }
                }
            }
        }
        ////////////////////////////2

        if (FileUpload2.HasFile)
        {
            if (!Directory.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/", "2"))))
            {
                Directory.CreateDirectory(Server.MapPath(string.Format("~/Npanel/image/{0}/", "2")));
            }

            if (File.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "2", "2"))))
            {
                File.Delete(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "2", "2")));
            }

            FileUpload2.SaveAs(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "2", "2")));

            if (FileUpload2.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(FileUpload2.FileName);

                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg")
                {
                    Stream strm = FileUpload2.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Print Original Size of file (Height or Width)
                        int newWidth   = 400; // New Width of Image in Pixel
                        int newHeight  = 350; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string targetPath = Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "2", "2"));
                        thumbImg.Save(targetPath, image.RawFormat);
                        // Print new Size of file (height or Width)
                        //Show Image
                    }
                }
            }
        }
        ////////////////////////////3

        if (FileUpload3.HasFile)
        {
            if (!Directory.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/", "3"))))
            {
                Directory.CreateDirectory(Server.MapPath(string.Format("~/Npanel/image/{0}/", "3")));
            }

            if (File.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "3", "3"))))
            {
                File.Delete(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "3", "3")));
            }

            FileUpload3.SaveAs(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "3", "3")));

            if (FileUpload3.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(FileUpload3.FileName);

                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg")
                {
                    Stream strm = FileUpload3.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Print Original Size of file (Height or Width)
                        int newWidth   = 400; // New Width of Image in Pixel
                        int newHeight  = 350; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string targetPath = Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "3", "3"));
                        thumbImg.Save(targetPath, image.RawFormat);
                        // Print new Size of file (height or Width)
                        //Show Image
                    }
                }
            }
        }
        ////////////////////////////4

        if (FileUpload4.HasFile)
        {
            if (!Directory.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/", "4"))))
            {
                Directory.CreateDirectory(Server.MapPath(string.Format("~/Npanel/image/{0}/", "4")));
            }

            if (File.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "4", "4"))))
            {
                File.Delete(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "4", "4")));
            }

            FileUpload4.SaveAs(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "4", "4")));

            if (FileUpload4.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(FileUpload4.FileName);

                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg")
                {
                    Stream strm = FileUpload4.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Print Original Size of file (Height or Width)
                        int newWidth   = 400; // New Width of Image in Pixel
                        int newHeight  = 350; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string targetPath = Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "4", "4"));
                        thumbImg.Save(targetPath, image.RawFormat);
                        // Print new Size of file (height or Width)
                        //Show Image
                    }
                }
            }
        }

        ////////////////////////////5

        if (FileUpload5.HasFile)
        {
            if (!Directory.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/", "5"))))
            {
                Directory.CreateDirectory(Server.MapPath(string.Format("~/Npanel/image/{0}/", "5")));
            }

            if (File.Exists(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "5", "5"))))
            {
                File.Delete(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "5", "5")));
            }

            FileUpload5.SaveAs(Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "5", "5")));

            if (FileUpload5.PostedFile != null)
            {
                // Check the extension of image
                string extension = Path.GetExtension(FileUpload5.FileName);

                if (extension.ToLower() == ".png" || extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg")
                {
                    Stream strm = FileUpload5.PostedFile.InputStream;
                    using (var image = System.Drawing.Image.FromStream(strm))
                    {
                        // Print Original Size of file (Height or Width)
                        int newWidth   = 400; // New Width of Image in Pixel
                        int newHeight  = 350; // New Height of Image in Pixel
                        var thumbImg   = new Bitmap(newWidth, newHeight);
                        var thumbGraph = Graphics.FromImage(thumbImg);
                        thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
                        thumbGraph.SmoothingMode      = SmoothingMode.HighQuality;
                        thumbGraph.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        var imgRectangle = new Rectangle(0, 0, newWidth, newHeight);
                        thumbGraph.DrawImage(image, imgRectangle);
                        // Save the file
                        string targetPath = Server.MapPath(string.Format("~/Npanel/image/{0}/_{1}.jpg", "5", "5"));
                        thumbImg.Save(targetPath, image.RawFormat);
                        // Print new Size of file (height or Width)
                        //Show Image
                    }
                }
            }
        }
    }
    protected void Add_Policy_Click(object sender, EventArgs e)
    {
        SqlCommand     cmd2 = new SqlCommand("select top 1 policy_id from new_policy order by policy_id desc", conn);
        SqlDataAdapter sda2 = new SqlDataAdapter(cmd2);
        DataTable      dt3  = new DataTable();

        sda2.Fill(dt3);
        if (dt3.Rows.Count > 0)
        {
            id = Convert.ToInt32(dt3.Rows[0]["policy_id"]);
        }
        h_id = id + 1;



        Random ran           = new Random();
        int    policy_number = ran.Next(1000);

        conn.Open();
        string filename = Path.GetFileName(FileUpload1.FileName);

        FileUpload1.SaveAs(Server.MapPath("/AddharCard/") + filename);
        string filepath = "/AddharCard/" + filename;

        string fileform = Path.GetFileName(FileUpload2.FileName);

        FileUpload2.SaveAs(Server.MapPath("/UserForm/") + fileform);
        string menu = "/UserForm/" + fileform;

        using (SqlCommand cmd = new SqlCommand("insert into new_policy(cust_id,policy_number,name,age,policy_type,policy,purchase_date,phno,premium_amount,start_date,end_date,aadhar,form,policy_id_hash) values(@cust_id,@policy_number,@name,@age,@policy_type,@policy,@purchase_date,@phno,@premium_amount,@start_date,@end_date,@aadhar,@form,@policy_id_hash)", conn))
        {
            string plainData  = Convert.ToString(h_id);
            string hashedData = ComputeSha256Hash(plainData);

            cmd.Parameters.AddWithValue("@cust_id", Session["cust_id"]);
            cmd.Parameters.AddWithValue("@policy_number", policy_number);
            cmd.Parameters.AddWithValue("@name", TextBox1.Text);
            cmd.Parameters.AddWithValue("@age", TextBox2.Text);
            cmd.Parameters.AddWithValue("@policy_type", DropDownList1.SelectedValue);
            cmd.Parameters.AddWithValue("@policy", DropDownList2.SelectedValue);
            cmd.Parameters.AddWithValue("@purchase_date", TextBox3.Text);
            //cmd.Parameters.AddWithValue("@address", TextBox4.Text);
            cmd.Parameters.AddWithValue("@phno", TextBox4.Text);
            cmd.Parameters.AddWithValue("@premium_amount", TextBox5.Text);
            cmd.Parameters.AddWithValue("@start_date", TextBox6.Text);
            cmd.Parameters.AddWithValue("@end_date", TextBox7.Text);
            cmd.Parameters.AddWithValue("@aadhar", filepath);
            cmd.Parameters.AddWithValue("@form", menu);
            cmd.Parameters.AddWithValue("@policy_id_hash", hashedData);

            cmd.ExecuteNonQuery();
            conn.Close();

            // SqlCommand cmd4 = new SqlCommand("select cust_id_hash from customer_master where cust_id=@cust", conn);
            // cmd4.Parameters.AddWithValue("@cust", Session["cust_id"]);
            //SqlDataAdapter sda3=new SqlDataAdapter(cmd4);
            // DataTable dt4=new DataTable();
            // sda3.Fill(dt4);
            // if (dt4.Rows.Count > 0)
            // {
            //     cust_id = Convert.ToInt32(dt4.Rows[0]["cust_id_hash"]);
            // }

            //SqlCommand cmd3 = new SqlCommand("Update  Log_Table set policy_i=@policy_id where cust_id=@cust_id", conn);
            //cmd.Parameters.AddWithValue("@cust_id", cust_id);
            //cmd3.Parameters.AddWithValue("@policy_id", hashedData);
            //conn.Open();
            //cmd3.ExecuteNonQuery();
            SqlCommand cmd3 = new SqlCommand("insert into Log_Table(cust,hash,Type,date_a_paid)values(@cust,@hash,@Type,@date_a_paid)", conn);
            cmd3.Parameters.AddWithValue("@cust", Session["cust_id"]);
            cmd3.Parameters.AddWithValue("@hash", hashedData);
            cmd3.Parameters.AddWithValue("@Type", "New Policy");
            cmd3.Parameters.AddWithValue("@date_a_paid", DateTime.Now.Date);
            conn.Open();
            cmd3.ExecuteNonQuery();
            MessageBox.Show("New Policy added Successfully");
            Response.Redirect("~/user/New_Policy.aspx");
            TextBox1.Text = "";
            TextBox4.Text = "";
            conn.Close();
        }
    }
        protected void REACTlaunchUpload(object sender, EventArgs e)
        {
            // For safety, do yet another verification that this user owns the
            // workspace.
            session.ObtainWorkspaceContext();

            if (!((session.idWorkspace >= 0) && session.isWorkspaceOwner))
            {
                throw new Exception("There is no active workspace, owned by you, for this subprocess.");
            }



            if (this.FileUpload2.HasFile)
            {
                string pathTempFolder = System.IO.Path.GetTempPath();
                string pathTempFile   = System.IO.Path.GetTempFileName();



                /*
                 * if (this.COMBOXchooseBrole.SelectedIndex < 0)
                 * {
                 * throw new Exception("Select a role from the dropdown list!");
                 * }
                 */



                /*
                 * TURNS OUT THAT idBusRole was never being used after being set.
                 *
                 * int idBusRole = -1;
                 * if (this.COMBOXchooseBrole.SelectedItem != null)
                 * {
                 * idBusRole = int.Parse(this.COMBOXchooseBrole.SelectedItem.Value);
                 * }
                 */


                FileUpload2.SaveAs(pathTempFile);
                DataTable dt = HELPERS.LoadCsv(pathTempFolder,
                                               System.IO.Path.GetFileName(pathTempFile));
                if (dt != null)
                {
                    if (dt.Columns.Count > 1)
                    {
                        System.Data.Odbc.OdbcConnection conn =

                            new System.Data.Odbc.OdbcConnection(
                                ConfigurationManager.AppSettings["DBconnstr"]);

                        conn.Open();

                        Queue RETmsgs = new Queue();


                        HELPERS.ImportBusRoleAssignmentsFromDataTable
                            (dt, session.idUser, session.idWorkspace,
                            this.COMBOXchooseUnregEntAction.SelectedValue,
                            this.COMBOXchooseBrole.SelectedValue, RETmsgs,
                            session.idSubprocess);


                        if (RETmsgs.Count > 0)
                        {
                            string strMsgs = "";
                            foreach (object objMsg in RETmsgs.ToArray())
                            {
                                strMsgs += "\n" + objMsg.ToString();
                            }
                            TXTimportEngineMessages.Text  = strMsgs;
                            DIVimportFeeback.Visible      = true;
                            PANELcond_AbortUpload.Visible = false;
                            PANELcond_AllowUpload.Visible = false;
                        }
                        else
                        {
                            Response.Redirect("ListBRoles.aspx");
                        }
                    }
                }
            }
        }
    protected void btnsend_Click(object sender, EventArgs e)
    {
        // txtimg.Text = txtimg.Text.Trim();
        try
        {
            string[]     validFileTypes = { "png", "jpg", "jpeg" };
            Stream       fs             = FileUpload2.PostedFile.InputStream;
            BinaryReader br             = new BinaryReader(fs);
            Byte[]       image          = br.ReadBytes((Int32)fs.Length);

            string exten = System.IO.Path.GetExtension(FileUpload2.FileName);
            string name  = System.IO.Path.GetFileName(FileUpload2.FileName);


            string ext = System.IO.Path.GetExtension(FileUpload2.FileName);

            string fileName    = "";
            bool   isValidFile = false;
            string imgname     = "";
            if (FileUpload2.HasFile)
            {
                for (int i = 0; i < validFileTypes.Length; i++)
                {
                    if (ext == "." + validFileTypes[i])
                    {
                        isValidFile = true;
                        break;
                    }
                }

                if (!isValidFile)
                {
                    ltrerr.Text = "Invalid File. Please upload valid Image file (.png, .jpg, .jpeg).";
                    return;
                }


                ext = ext.Replace(".", "image/");

                imgname = DateTime.Now.Ticks + exten;
                string path = Server.MapPath("~/content/images/thumbs") + "\\" + imgname;



                FileUpload2.SaveAs(path);
                if (Request.Url.ToString().Contains("localhost"))
                {
                    imgname = "http://" + Request.Url.Authority + "/content/images/thumbs/" + imgname;
                }
                else
                {
                    imgname = "http://admin.salebhai.in/content/images/thumbs/" + imgname;
                }
            }
            fileName = imgname;



            string uid              = Request.Cookies["TUser"]["Id"];
            string type             = "";
            string NotificationType = ddlcategory.SelectedValue;
            bool   isoffer          = false;

            //if (ddlcategory.SelectedValue == "0")
            //{
            //    if (chkoffer.Checked == false)
            //    {
            //        isoffer = false;

            //            type = "0";
            //            NotificationType = "0";

            //    }
            //    else
            //    {
            //        isoffer = true;

            //            type = "11";
            //            NotificationType = "11";

            //    }
            //}
            //else
            //{

            //        type = "14";
            //        NotificationType = "14";

            //}


            ltrerr.Text = "";
            int    sendtype       = 0;;
            string NotificationTo = "";
            string SendTo         = "";
            //if (txtpwd.Text != "" && txtpwd.Text.ToLower() == "secret")
            //{
            string mobile = "";

            //if (rdbhotel.Checked == true)
            //{
            //    NotificationTo = "1"; // Hotel
            //}
            //else if (rdbretail.Checked == true)
            //{
            //    NotificationTo = "0"; // Retail
            //}
            //else
            //{
            NotificationTo = "2"; // Both
            //}


            if (rdbsendall.Checked == true)
            {
                sendtype = 0;///// have to set 0 afterwards


                SendTo = "0"; // All
            }
            else
            {
                sendtype = 1;
                SendTo   = "1"; // Selected

                if (txtmsg.Text != "" && txtmob.Text != "")
                {
                    txtmob.Text = txtmob.Text.Replace("\r\n", ",");
                    txtmob.Text = txtmob.Text.Replace(",,,", ",");
                    txtmob.Text = txtmob.Text.Replace(",,", ",");
                    mobile      = txtmob.Text;
                    mobile      = "'" + mobile.Replace(",", "','") + "'";
                }
                else
                {
                    ltrerr.Text = "Enter all values";
                    return;
                }
            }

            //Notification nf = new Notification();
            string category = "";
            string product  = "";
            if (ddlcategory.SelectedValue == "0")
            {
                category = "";
            }
            else
            {
                category = ddlcategory.SelectedValue;
            }

            if (ddlProduct.SelectedValue == "0")
            {
                product = "";
            }
            else
            {
                product = ddlProduct.SelectedValue.ToString();
            }

            string ScheduleTime = txtSDate.Value + " " + txttime.Value;
            //   string exptime = txtexpdate.Value + " " + txtexptime.Value;

            int sent = StoreNotificationScheduler(NotificationTo, SendTo, category, product, txtmsg.Text.Trim(), mobile, NotificationType, ScheduleTime, ScheduleTime, fileName);// nf.SendNotification(type, uid, txtimg.Text, txtmsg.Text, isoffer, category, mobile, product, sendtype);
            if (sent > 0)
            {
                ltrerr.Text = "Notification Scheduler Set Successfully.";
                txtmob.Text = "";
                txtmsg.Text = "";
                // txtpwd.Text = "";
                // txtimg.Text = " ";

                //gvbind();
            }
            else
            {
                ltrerr.Text = "Notification Scheduler NOT Set.";
                //txtpwd.Text = "";
                // txtimg.Text = " ";
            }

            //}
            //else
            //{
            //    txtpwd.Text = "";
            //    txtimg.Text = " ";
            //    ltrerr.Text = "Invalid Password";
            //}
        }
        catch (Exception ex)
        {
            // txtimg.Text = " ";
            //txtpwd.Text = "";
            ltrerr.Text = ex.Message + "Stack: " + ex.StackTrace;
        }
    }
Beispiel #24
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile == false || FileUpload2.HasFile == false || FileUpload3.HasFile == false)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "fileup", "<script>warningDesPic();</script>");
            }
            else if (txtName.Text.Trim() == "" || txtSize.Text.Trim() == "" || txtSCPrice.Text.Trim() == "" || txtCXPrice.Text.Trim() == "")
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "fileup", "<script>warningEmpty();</script>");
            }
            else
            {
                string name = txtName.Text.Trim();
                //市场价格
                string scprice = txtSCPrice.Text.Trim();
                //促销价格
                string cxprice = txtCXPrice.Text.Trim();
                //可选尺码
                string selectSize = txtSize.Text.Trim();
                string File1      = FileUpload1.FileName;
                string File2      = FileUpload2.FileName;
                string File3      = FileUpload3.FileName;
                string DetailDes  = FCKeditor1.Value;
                //string type1, type2, type3;
                //type1 = File1.Substring(File1.LastIndexOf("."));
                //type2 = File2.Substring(File2.LastIndexOf("."));
                //type3 = File3.Substring(File3.LastIndexOf("."));
                ///这里还没有判断是否是图片
                //////
                //随机种子
                //Random rd = new Random();
                //int sj1= rd.Next(10000, 99999999);
                //int sj2 = rd.Next(10000, 99999999);
                //int sj3 = rd.Next(10000, 99999999);
                //File1 = File1 + sj1.ToString();
                //File2 = File2 + sj1.ToString();
                //File3 = File3 + sj1.ToString();
                string a1    = getFileName(File1);
                string a2    = getFileName(File2);
                string a3    = getFileName(File3);
                string path1 = Server.MapPath("~\\productImg\\" + a1);
                string path2 = Server.MapPath("~\\productImg\\" + a2);
                string path3 = Server.MapPath("~\\productImg\\" + a3);

                FileUpload1.SaveAs(path1);
                FileUpload2.SaveAs(path2);
                FileUpload1.SaveAs(path3);
                string goodtype = ddlType.SelectedValue;
                ///
                YC_Goods goods = new YC_Goods();
                goods.Gtid         = Convert.ToInt32(goodtype);
                goods.Name         = name;
                goods.SCPrice      = Convert.ToDouble(scprice);
                goods.Cxprice      = Convert.ToDouble(cxprice);
                goods.DesImg1Url   = a1;
                goods.DesImg2Url   = a2;
                goods.DesImg3Url   = a3;
                goods.DetailImages = DetailDes;
                goods.AllSize      = txtSize.Text;
                BLL.AdminGoodManager.add(goods);
                ClientScript.RegisterClientScriptBlock(this.GetType(), "xx", "<script>alert(\"上架成功\")</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            btnUpdate.ServerClick += BtnUpdate_ServerClick;
            btnClear.ServerClick  += BtnClear_ServerClick;
            BtnUpload.Text         = Resources.Index.Upload;
            btnClear.Value         = Resources.Index.Clean;

            if (Request.QueryString["Process"] != null)
            {
                string Processs = Request.QueryString["Process"];

                if (Processs == "EditPage")
                {
                    Prcs = AddNews.Process.EditPage;
                    id   = Request.QueryString["id"].Clean();
                    Dictionary <string, string> condition = new Dictionary <string, string>();
                    condition.Add("id", id);
                    pages           = jobs.Pages(condition);
                    btnUpdate.Value = Resources.Index.Update;
                    if (pages.Count > 0)
                    {
                        PageTitle = Resources.Index.EditPage;
                        {
                            if (!Page.IsPostBack)
                            {
                                lblturkish.Text        = Resources.Index.Turkish;
                                lblenglish.Text        = Resources.Index.English;
                                txtTurkishTitle.Value  = pages[0].PageTitleTR.ToString().Clean();
                                txtEnglishTitle.Value  = pages[0].PageTitleEN.ToString().Clean();
                                txtturkish.Value       = pages[0].PageContentTR.ToString().Clean();
                                txtenglish.Value       = pages[0].PageContentEN.ToString().Clean();
                                txtPageUrl.Value       = pages[0].PageUrl.ToString().Clean();
                                image1.ImageUrl        = pages[0].SmallPicture.ToString().Clean();
                                image2.ImageUrl        = pages[0].ContentPicture.ToString().Clean();
                                imageuploading.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        PageTitle = Resources.Index.DataNotFound;
                        Prcs      = AddNews.Process.DataNotFound;
                    }
                }
                else if (Processs == "DeletePage")
                {
                    PageTitle = Resources.Index.DeletePage;
                    Prcs      = AddNews.Process.DeletePage;
                    id        = Request.QueryString["id"].Clean();
                    int result = jobs.query("Delete pages where id='" + id + "'");
                    if (result > 0)
                    {
                        Response.Redirect("/PagesList.aspx");
                    }
                    else
                    {
                        Response.Write("Error1");
                    }
                }
                else
                {
                    Title = Resources.Index.WrongParameter;
                }
            }
            else
            {
                btnUpdate.Value         = Resources.Index.AddPage;
                PageTitle               = Resources.Index.AddPage;
                Prcs                    = Process.AddPage;
                Viewingimages.Visible   = false;
                uploadbuttondiv.Visible = false;
            }
            if (FileUpload1.HasFile)
            {
                if (Path.GetExtension(FileUpload1.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload1.PostedFile.FileName) == ".png")
                {
                    Random rndm            = new Random();
                    string PhotoExtensions = Path.GetExtension(FileUpload1.PostedFile.FileName);
                    string PhotoName       = FileUpload1.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/;
                    //Firstly we will save chosen images to \\images\\ folder as temporary
                    FileUpload1.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    //After we are converting as bitmap
                    Bitmap Photo  = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    int    Width  = 215;
                    int    Height = 215;
                    //Resizing the photo
                    Size Size = new Size(Width, Height);
                    //Resmi boyutlandırıyoruz.
                    Bitmap ResizedPhoto         = new Bitmap(Photo, Size);
                    string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName;
                    //We are saving resized photo to \\images\\userphotos\\ folder
                    ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg);
                    Photo.Dispose();
                    ResizedPhoto.Dispose();
                    //we delete the photo we saved as temporary
                    FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    Firstuploadedphoto.Delete();
                    image1.ImageUrl = Resizedandsavedphoto.Clean();
                }
            }
            if (FileUpload2.HasFile)
            {
                if (Path.GetExtension(FileUpload2.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload2.PostedFile.FileName) == ".png")
                {
                    Random rndm            = new Random();
                    string PhotoExtensions = Path.GetExtension(FileUpload2.PostedFile.FileName);
                    string PhotoName       = FileUpload1.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/;
                    //Firstly we will save chosen images to \\images\\ folder as temporary
                    FileUpload2.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    //After we are converting as bitmap
                    Bitmap Photo  = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    int    Width  = 215;
                    int    Height = 215;
                    //Resizing the photo
                    Size Size = new Size(Width, Height);
                    //Resmi boyutlandırıyoruz.
                    Bitmap ResizedPhoto         = new Bitmap(Photo, Size);
                    string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName;
                    //We are saving resized photo to \\images\\userphotos\\ folder
                    ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg);
                    Photo.Dispose();
                    ResizedPhoto.Dispose();
                    //we delete the photo we saved as temporary
                    FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    Firstuploadedphoto.Delete();
                    image2.ImageUrl = Resizedandsavedphoto.Clean();
                }
            }
        }
        protected void cmdAdd_Click(object sender, EventArgs e)
        {
            int i = 0, j = 0;

            int[] store = new int[20];
            int   maxid = colour.GetMaxId();
            //   int maxid = 11;
            bool          flag    = false;
            DirectoryInfo di      = new DirectoryInfo(Server.MapPath("~/Images/ColorImage"));
            int           greater = 0;

            foreach (var item in di.GetFiles())
            {
                if (item.Name.StartsWith(maxid.ToString()))
                {
                    string[] sp    = item.Name.Split('-');
                    string   value = sp[1];
                    string[] va    = value.Split('.');
                    int      rslt  = Convert.ToInt32(va[0]);
                    store[j] = rslt;
                    if (store[j] > greater)
                    {
                        greater = store[j];
                        j++;
                    }
                    flag = true;
                }

                var data = from c in colour.GetallData() select c.ColourId;
                foreach (var d in data)
                {
                    if ((item.Name.StartsWith(d.ToString()) == false) && (item.Name.StartsWith(maxid.ToString()) == false))
                    {
                        break;
                        //flag = false;
                    }
                }
            }
            if (flag == true)
            {
                string cmbine0 = string.Format("~/Images/ColorImage/{0}-{1}.jpg", maxid, greater + 1);
                FileUpload2.SaveAs(Server.MapPath(cmbine0));
            }
            else
            {
                i = Convert.ToInt32(Session["img"]) + 1;
                Session["img"] = i;
                string cmbine1 = string.Format("~/Images/ColorImage/{0}-{1}.jpg", maxid, i);
                FileUpload2.SaveAs(Server.MapPath(cmbine1));



                Session["img"] = 0;
            }

            DataList1.DataBind();
            ////=======================


            HiddenField2.Value = Server.MapPath("~/Images/ColorImage");
            DataList1.DataBind();
        }
Beispiel #27
0
        protected void REACTlaunchUpload(object sender, EventArgs e)
        {
            if (this.FileUpload2.HasFile)
            {
                string pathTempFolder = System.IO.Path.GetTempPath();
                string pathTempFile   = System.IO.Path.GetTempFileName();

                FileUpload2.SaveAs(pathTempFile);
                DataTable dt = HELPERS.LoadCsv(pathTempFolder,
                                               System.IO.Path.GetFileName(pathTempFile));
                if (dt != null)
                {
                    if (dt.Columns.Count > 1)
                    {
                        System.Data.Odbc.OdbcConnection conn =
                            new System.Data.Odbc.OdbcConnection(
                                ConfigurationManager.AppSettings["DBconnstr"]);

                        conn.Open();

                        Queue RETmsgs = new Queue();


                        if (this.COMBOXchooseApp.SelectedIndex < 0)
                        {
                            this.PANELchooseApp.Style[HtmlTextWriterStyle.BackgroundColor] = "yellow";
                            return;
                        }


                        string strNameApplication =
                            this.COMBOXchooseApp.SelectedItem.Text;


                        int numChanges =
                            HELPERS.ImportNewEntitlementsFromDataTable
                                (dt, session.idUser,
                                /* the application to attach these to */ strNameApplication,
                                this.COMBOXinitStatus.SelectedValue,
                                conn, RETmsgs);

                        if (RETmsgs.Count > 0)
                        {
                            string strMsgs = "";
                            foreach (object objMsg in RETmsgs.ToArray())
                            {
                                strMsgs += "\n" + objMsg.ToString();
                            }
                            TXTimportEngineMessages.Text = strMsgs;
                            DIVimportFeeback.Visible     = true;

                            PANELcond_AllowUpload.Visible = false;
                        }
                        else
                        {
                            throw new Exception("SUCCESS!!!!");
                        }
                    }
                }
            }
        }
Beispiel #28
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Class1 c = new Class1();
        Class2 b = new Class2();
        int    x = c.scalar("select count(*) from reg where name='" + TextBox1.Text + "' and votersid='" + TextBox2.Text + "'");

        if (x == 1)
        {
            Response.Write("User already exists");
        }
        if (DropDownList4.SelectedValue == "state level")
        {
            DataTable dd1 = b.select("select userlastdate from stateelectionn where statename='" + DropDownList1.SelectedValue + "'");
            DateTime  aa  = Convert.ToDateTime(dd1.Rows[0]["userlastdate"].ToString());
            if (DateTime.Now.Date > aa.Date)
            {
                Response.Write("<script>alert('Last date for User Registration has exceeded');</script>");
            }
        }
        else if (DropDownList4.SelectedValue == "district level")
        {
            DataTable dd2 = b.select("select userlastdate from districtelectionn");
            DateTime  bb  = Convert.ToDateTime(dd2.Rows[0]["userlastdate"].ToString());
            if (DateTime.Now.Date > bb.Date)
            {
                Response.Write("<script>alert('Last date for User Registration has exceeded');</script>");
            }
        }
        else if (DropDownList4.SelectedValue == "village level")
        {
            DataTable dd3 = b.select("select userlastdate from villageelectionn");
            DateTime  cc  = Convert.ToDateTime(dd3.Rows[0]["userlastdate"].ToString());
            if (DateTime.Now.Date > cc.Date)
            {
                Response.Write("<script>alert('Last date for User Registration has exceeded');</script>");
            }
        }

        string adhar = "", img = "";

        if (FileUpload1.HasFile)
        {
            img = "~/home/myimages/" + FileUpload1.FileName;
            FileUpload1.SaveAs(Server.MapPath("~/home/myimages/" + FileUpload1.FileName));
        }
        if (FileUpload2.HasFile)
        {
            adhar = "~/home/myimages/" + FileUpload2.FileName;
            FileUpload2.SaveAs(Server.MapPath("~/home/myimages/" + FileUpload2.FileName));
        }



        c.data("insert into login values('" + TextBox1.Text + "','" + TextBox7.Text + "','user')");
        string g = c.scalar1("select logid from login where name='" + TextBox1.Text + "'");

        //if (g != "")
        //{

        c.data("insert into reg values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox4.Text + "','" + TextBox8.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + DropDownList1.SelectedValue + "','" + DropDownList2.SelectedValue + "','" + DropDownList3.SelectedValue + "','" + DropDownList4.SelectedValue + "','" + img + "','" + adhar + "','pending','failure','" + g + "')");
        Response.Redirect("register.aspx");
        Response.Write("<script>alert('User registered successfully!!');</script>");
        //delete();

        //}
    }
    /// <summary>
    /// This method will be called when user clicks on send mms button
    /// </summary>
    /// <param name="sender">object, that caused this event</param>
    /// <param name="e">Event that invoked this function</param>
    protected void SendMMSMessageButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.ReadAndGetAccessToken() == true)
            {
                long fileSize = 0;
                if (!string.IsNullOrEmpty(FileUpload1.FileName))
                {
                    FileUpload1.SaveAs(Request.MapPath(FileUpload1.FileName.ToString()));
                    Session["mmsFilePath1"] = Request.MapPath(FileUpload1.FileName);
                    FileInfo fileInfoObj = new FileInfo(Session["mmsFilePath1"].ToString());
                    fileSize = fileSize + (fileInfoObj.Length / 1024);
                    if (fileSize > 600)
                    {
                        this.DrawPanelForFailure(sendMessagePanel, "Attachment file size exceeded 600kb");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(FileUpload2.FileName))
                {
                    FileUpload2.SaveAs(Request.MapPath(FileUpload2.FileName));
                    Session["mmsFilePath2"] = Request.MapPath(FileUpload2.FileName);
                    FileInfo fileInfoObj = new FileInfo(Session["mmsFilePath2"].ToString());
                    fileSize = fileSize + (fileInfoObj.Length / 1024);
                    if (fileSize > 600)
                    {
                        this.DrawPanelForFailure(sendMessagePanel, "Attachment file size exceeded 600kb");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(FileUpload3.FileName))
                {
                    FileUpload3.SaveAs(Request.MapPath(FileUpload3.FileName));
                    Session["mmsFilePath3"] = Request.MapPath(FileUpload3.FileName);
                    FileInfo fileInfoObj = new FileInfo(Session["mmsFilePath3"].ToString());
                    fileSize = fileSize + (fileInfoObj.Length / 1024);
                    if (fileSize > 600)
                    {
                        this.DrawPanelForFailure(sendMessagePanel, "Attachment file size exceeded 600kb");
                        return;
                    }
                }

                if (fileSize <= 600)
                {
                    this.SendMMS();
                }
                else
                {
                    this.DrawPanelForFailure(sendMessagePanel, "Attachment file size exceeded 600kb");
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            this.DrawPanelForFailure(sendMessagePanel, ex.ToString());
            return;
        }
    }
        protected void btnSave_Top_Click(object sender, EventArgs e)
        {
            Entity.TinTuc dt = new Entity.TinTuc();
            if (insert == true)
            {
                dt.TieuDe      = txttieude.Text;
                dt.Tomtat      = txttomtat.Text;
                dt.Noidung     = txtnoidung.Text;
                dt.Ngayviet    = txtngayviet.Text;
                dt.Id_nhanvien = txtIdNhanvien.Text;
                if (FileUpload2.HasFile)
                {
                    try
                    {
                        string Duoi_filename = Path.GetExtension(FileUpload2.FileName);
                        string filename      = FileUpload2.FileName.ToString();

                        if (Duoi_filename == ".jpeg" || Duoi_filename == ".jpg" || Duoi_filename == ".png" || Duoi_filename == ".PNG" || Duoi_filename == ".JPG" || Duoi_filename == ".JPEG")
                        {
                            FileUpload2.SaveAs(Server.MapPath("~/images/") + filename);
                            dt.UrlHinhAnh = "images/" + filename;
                        }
                        else
                        {
                            Response.Write("<script>alert('Bạn chỉ được upload jpg,png,jpeg')</script>");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                }


                dt.Active = ckbActive.Checked == true ? "True" : "False";
                TinTucService.TinTuc_Insert(dt);
                Response.Write("<script>alert('Insert thành công!!!')</script>");
                getData();
            }
            else
            {
                dt.Id          = txtID.Text;
                dt.TieuDe      = txttieude.Text;
                dt.Tomtat      = txttomtat.Text;
                dt.Noidung     = txtnoidung.Text;
                dt.Ngayviet    = txtngayviet.Text;
                dt.Id_nhanvien = txtIdNhanvien.Text;
                if (FileUpload2.HasFile)
                {
                    try
                    {
                        string Duoi_filename = Path.GetExtension(FileUpload2.FileName);
                        string filename      = FileUpload2.FileName.ToString();

                        if (Duoi_filename == ".jpeg" || Duoi_filename == ".jpg" || Duoi_filename == ".png" || Duoi_filename == ".PNG" || Duoi_filename == ".JPG" || Duoi_filename == ".JPEG")
                        {
                            FileUpload2.SaveAs(Server.MapPath("~/images/") + filename);
                            dt.UrlHinhAnh = "images/" + filename;
                        }
                        else
                        {
                            Response.Write("<script>alert('Bạn chỉ được upload jpg,png,jpeg')</script>");
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    dt.UrlHinhAnh = fileUpLoad;
                }

                dt.Active = ckbActive.Checked == true ? "True" : "False";
                TinTucService.TinTuc_Update(dt);
                Response.Write("<script>alert('Update thành công!!!')</script>");
                getData();
            }
            insert         = true;
            pnData.Visible = true;
            pnInfo.Visible = false;
            ClearText();
        }