public List <cMeaurements> getMeasurements(int customerID)
        {
            List <cMeaurements> customers = new List <cMeaurements>();
            SqlConnection       con       = new SqlConnection(Helper.conStr);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();

            string        query  = "select * from Measurement where cId='" + customerID + "' ";
            SqlCommand    cmd    = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cMeaurements u1 = new cMeaurements();
                u1.cId   = Convert.ToInt32(reader["cId"]);
                u1.mType = reader["mType"].ToString();
                customers.Add(u1);
            }
            reader.Close();
            con.Close();

            con.Dispose();
            cmd.Dispose();
            return(customers);
        }
Exemple #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            cMeaurements m = new cMeaurements();

            m.cId   = Convert.ToInt32(GridView1.SelectedValue.ToString());
            m.mType = d.tempType;
            m.mType = type.Text;
            new cMeaurementsDAL().InsertMeaurements(m);
            //added meausurement
            d.mId = new cMeaurementsDAL().getId(m);
            foreach (GridViewRow r in GridView2.Rows)
            {
                var ts = (r.FindControl("valuetxt") as TextBox).Text;
                d.field_name  = (r.FindControl("namelbl") as Label).Text;
                d.field_value = Convert.ToInt32((r.FindControl("valuetxt") as TextBox).Text);
                d.tempType    = type.Text;
                //detailsList.Add(d);
                new cMeaurementsDAL().InsertDetails(d);
            }
        }
        public int getId(cMeaurements m)
        {
            SqlConnection con = new SqlConnection(Helper.conStr);

            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            string query = "SELECT mId FROM Measurement WHERE cId = '" + m.cId + "' and mType= '" + m.mType + "'";

            SqlCommand cmd   = new SqlCommand(query, con);
            Int32      count = (Int32)cmd.ExecuteScalar();

            /*
             * SqlCommand cmd = new SqlCommand(query, con);
             * var result = cmd.ExecuteNonQuery();*/
            con.Close();
            cmd.Dispose();
            con.Dispose();
            return(count);
        }
        public int InsertMeaurements(cMeaurements m)
        {
            SqlConnection con = new SqlConnection(Helper.conStr);

            if (con.State.ToString() == "open")
            {
                con.Close();
            }

            con.Open();

            string query = "INSERT INTO Measurement(cId,mType) values('" + m.cId + "','" + m.mType + "')";

            SqlCommand cmd = new SqlCommand(query, con);


            var result = cmd.ExecuteNonQuery();

            con.Close();
            cmd.Dispose();
            con.Dispose();

            return(result);
        }
Exemple #5
0
 public int getId(cMeaurements m)
 {
     return(new TMS.DAL.cMeaurementsDAL().getId(m));
 }
Exemple #6
0
 public int InsertMeaurements(cMeaurements m)
 {
     return(new TMS.DAL.cMeaurementsDAL().InsertMeaurements(m));
 }
        private void button1_Click(object sender, EventArgs e)
        {
            cCustomer customer = new cCustomer();

            customer.cFullName = txtFullname.Text.Trim();
            customer.cCNIC     = txtCNIC.Text.Trim();
            customer.cAddress  = txtAddress.Text.Trim();
            customer.cMobileNo = txtMobile.Text.Trim();
            customer.cRemarks  = txtRemarks.Text.Trim();

            if (customer.cFullName != "")
            {
                if (customer.cCNIC != "")
                {
                    if (customer.cAddress != "")
                    {
                        if (customer.cMobileNo != "")
                        {
                            if (customer.cRemarks != "")
                            {
                                if (new cCustomerBLL().InsertCustomer(customer) > 0)
                                {
                                    //valid record or user
                                    /**/

                                    var          cid = new cCustomerBLL().getId(customer);//recently added customer
                                    cMeaurements m   = new cMeaurements();
                                    cDetails     d   = new cDetails();
                                    foreach (var mes in mList)
                                    {
                                        m.cId   = cid;
                                        m.mType = mes[0].tempType;
                                        new cMeaurementsBLL().InsertMeaurements(m);
                                        var mid = new cMeaurementsBLL().getId(m);
                                        foreach (var details in mes)
                                        {
                                            d.mId         = mid;
                                            d.field_name  = details.field_name;
                                            d.field_value = details.field_value;
                                            new cMeaurementsBLL().InsertDetails(d);
                                        }
                                    }
                                    MessageBox.Show("Data stored...!!!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    txtFullname.Text = "";
                                    txtCNIC.Text     = "";
                                    txtAddress.Text  = "";
                                    txtMobile.Text   = "";
                                    txtRemarks.Text  = "";
                                }
                                else
                                {
                                    MessageBox.Show("Data cannot be stored...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Remarks Must be entered...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Mobile No should be selected...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Address should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("CNIC should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Full Name should be filled...!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }