Friday 4 June 2021

Paul_testing.aspx

 [Paul_testing.aspx] page: This is page for testing the code before implement in the main page:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class paul_testing : System.Web.UI.Page
{
    public static byte[] bytes;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        try
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM id_pwd", con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                GridView1.DataSource = dr;
                GridView1.DataBind();

                txt_test.Text = dr[1].ToString();
                
            }
            else
            {
                GridView1.DataSource = null;
                GridView1.DataBind();
                txt_test.Text = dr[1].ToString();
            }
        }
        catch (Exception ex)
        {
            Response.Write("Error Occured: " + ex.ToString());
        }
        finally
        {
            con.Close();
        }

        //Testing Application State
        //if two clients requested the page at the same time. Then deadlock will occur.
        //We can avoid deadlock occurrence while we updating application variable
        //by multiple users with help of Lock() and UnLock().

        Application.Lock();
        int count = 0;
        if (Application["app_state"] != "")
        {
            count = Convert.ToInt32(Application["app_state"]);
        }
        count = count + 1;
        Application["app_state"] = count;

        Application.UnLock();
        lbl_app_state.Text = "Total Visited People Are:" + "  " + Convert.ToString(count);

        //Testing Application State



        //string dt = "6/28/2019 12:00:00    AM";

        //string[] st1 = dt.Split(' ');
        //dt = st1[0];
        //string dt2 = dt;
        //string[] st2 = dt2.Split('/');

        //string d = st2[1];
        //string m = st2[0];
        //string y = st2[2];
        //string add = d+ "/" + m+ "/" + y;




        ////SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        ////con.Open();
        ////SqlDataAdapter da = new SqlDataAdapter("select * from frs_status_regulatory_rl where frs_no='A-216/18-19' and order_no='D-182/18-19a' and pro_code='24000' ", con);
        //SqlDataAdapter da = new SqlDataAdapter("select * from [reactor_process] where reactor_no='R-09' and r_status='Waiting' and plant='RL-HP' and  block='Block-1' and start_dt='12/30/2018 6:00:00 AM' and stop_dt='12/31/2018 6:00:00 AM' ", con);




        ////SqlDataAdapter da = new SqlDataAdapter("SELECT DISTINCT cust.frs_no AS FRS_NO, cust.order_no AS Order_No, cust.pro_code AS Product_Code, cust.date AS Date, contact.qty AS Quantity,contact.packaging as Packaging, contact.spec AS Specification, contact.o_spec AS Other_Specification, contact.mkt_remarks AS Mkt_Remarks, cust.pro_remarks AS Prod_Remarks, cust.pro_approve AS Prod_Approve, cust.qc_remarks AS QC_Remarks, cust.qc_approve AS QC_Approve, contact.party_code,contact.additional_info,contact.type_of_drum FROM frs_status_regulatory_rc AS cust INNER JOIN frs_regulatory_rc AS contact ON cust.order_no = contact.order_no AND cust.frs_no = contact.frs_no WHERE (cust.date <> '') AND (cust.qc_date IS NULL) AND (cust.back IS NULL) ORDER BY FRS_NO, Order_No ", con);




        


        ////string sys1 = "ujjwal";
        ////Session["ujjwal"] = sys1;
        ////lbl_sys1.Text = Session["ujjwal"].ToString();


    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            ////SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            ////con.Open();
            ////SqlCommand cmd11 = new SqlCommand("delete from [reactor_process] where reactor_no='R-09' and r_status='Waiting' and plant='RL-HP' and  block='Block-1' and start_dt='12/30/2018 6:00:00 AM' and stop_dt='12/31/2018 6:00:00 AM'", con);
            ////cmd11.ExecuteNonQuery();


            ////SqlCommand cmd31 = new SqlCommand("insert into [i_mark_rc] ([order_no],[o_rcv_date],[buyer_name],[agent_name],[o_placing_date],[c_order_no],[destination],[region],[pro_name],[pro_code],[specification],[other_specification],[qty],[price],[packaging],[delivery_date],[commission],[date_m],[o_no],[con_name],[order_type],[party_code],[adc_sample]) values ('" + Label34.Text + "','" + Label33.Text + "','" + DropDownList5.Text + "','" + DropDownList6.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + DropDownList33.Text + "','" + DropDownList7.Text + "','" + DropDownList12.Text + "','" + DropDownList17.Text + "','" + TextBox5.Text + "','" + TextBox10.Text + "','" + TextBox15.Text + "','" + TextBox20.Text + "','" + TextBox25.Text + "','" + TextBox30.Text + "','" + TextBox50.Text + "','" + Label47.Text + "','" + DropDownList22.Text + "','" + DropDownList23.Text + "','" + DropDownList28.Text + "','" + DropDownList34.Text + "')", con);
            //cmd31.ExecuteNonQuery();
            // con.Close();
        }
        catch (Exception ex)
        {
            string str = ex.Message;
        }



    }

    protected void btn_demo_Click(object sender, EventArgs e)
    {
        //try
        //{
        //    string startdate = "10/26/2017 12:00:00 AM";
        //    string enddate = "10/31/2017 12:00:00 AM";
        //    string s3 = "";
        //    string s4 = "";
        //    //SELECT distinct convert(varchar(11), date1, 106) ColName FROM [reactor_process] where start_dt > startdate and start_dt <= enddate and block = 'P1'

        //    SqlDataAdapter da = new SqlDataAdapter("select reactor_no, pro_name, pro_stage, batch_no, r_status, plant, block, start_dt, stop_dt, ROUND(CAST(DATEDIFF(minute, start_dt, stop_dt) / 60.00 AS float), 2) AS Occupancy, remarks from [reactor_process] where (start_dt BETWEEN '" + a + "' AND '" + b + "') AND (stop_dt BETWEEN '" + a + "' AND '" + b + "') AND plant = '" + DropDownList1.SelectedItem + "'AND block = '" + DropDownList3.SelectedItem + "' order by CAST(SUBSTRING(reactor_no, CHARINDEX('R', reactor_no)+1,99) AS SMALLINT)", con111);
        //    DataTable dt = new DataTable();
        //    da.Fill(dt);
        //    txt_test.Text = dt.Rows[0][""].ToString();
        //}
        //catch(Exception ex)
        //{
        //    string str = ex.Message;
        //}
    }

    protected void btn_submitt_ipc_Click(object sender, EventArgs e)
    {
        //try
        //{

        //        string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
        //        string contentType = FileUpload1.PostedFile.ContentType;
        //        string lock1 = "lock";

        //        using (Stream fs = FileUpload1.PostedFile.InputStream)
        //        {
        //            using (BinaryReader br = new BinaryReader(fs))
        //            {
        //                bytes = br.ReadBytes((Int32)fs.Length);
        //                drp_invoice_no_ipc.Text = "2";
        //                SqlConnection cn1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        //                cn1.Open();
        //                SqlCommand cmd1 = new SqlCommand("insert into [post_logistic_export_rl] (invoice_no, appname_ipc, Attachment_ipc, ContentType_ipc, ipc_lock) values (@invoice_no, @appname_ipc, @Attachment_ipc, @ContentType_ipc, @ipc_lock)", cn1);
        //                cmd1.Parameters.AddWithValue("@invoice_no", drp_invoice_no_ipc.Text);
        //                cmd1.Parameters.AddWithValue("@appname_ipc", filename);
        //                cmd1.Parameters.AddWithValue("@Attachment_ipc", contentType);
        //                cmd1.Parameters.AddWithValue("@ContentType_ipc", bytes);
        //                cmd1.Parameters.AddWithValue("@ipc_lock", lock1);
        //                cmd1.ExecuteNonQuery();


        //                cn1.Close();
        //            }
        //        }               
        //        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(' Successfully Inserted ');window.location.replace('log_post_ipc_ab_export_rl.aspx');", true);
        //    }

        //catch (Exception ex)
        //{
        //    string str = ex.Message;
        //}
    }

    protected void btn_update_Click(object sender, EventArgs e)

    {
        try
        {
            string extension1 = Path.GetExtension(FileUpload1.FileName);
            string p1 = Path.GetFileName(FileUpload1.PostedFile.FileName);// p1_name(pdf file name fetch)
            string filename1 = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string contentType1 = FileUpload1.PostedFile.ContentType;
            string[] s1 = p1.Split('.');
            p1 = s1[0];
            SqlConnection cn1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            cn1.Open();
            using (Stream fs = FileUpload1.PostedFile.InputStream)
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] bytes = br.ReadBytes((Int32)fs.Length);
                    string strQuery = "Update d_pending_rl Set ContentType = @profilepic,appname=@appname Where order_no = 'D-1022/19-20a'";
                    SqlCommand cmd = new SqlCommand(strQuery, cn1);
                    cmd.Parameters.AddWithValue("@profilepic", bytes);
                    cmd.Parameters.AddWithValue("@appname", filename1);
                    //cmd.Parameters.AddWithValue("@p1_name", p1);
                    //  InsertUpdateData(cmd);
                    cmd.ExecuteNonQuery();
                }

            }
            cn1.Close();
        }
        catch (Exception ex)
        {
            string str = ex.Message;
        }
    }
}

No comments:

Post a Comment

FAQ--(3- Tier Project)

BACK   https://meeraacademy.com/3-tier-architecture-example-in-asp-net-c/ 1. Presentation Layer (UI – User Interface Layer) 2. Busine...