public int InsertDetails(cDetails d)
        {
            SqlConnection con = new SqlConnection(Helper.conStr);

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

            con.Open();

            string query = "INSERT INTO mDetails(mId,dFieldName,dFieldvalue) values('" + d.mId + "','" + d.field_name + "','" + d.field_value + "')";

            SqlCommand cmd = new SqlCommand(query, con);


            var result = cmd.ExecuteNonQuery();

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

            return(result);
        }
Exemplo n.º 2
0
 public int InsertDetails(cDetails d)
 {
     return(new TMS.DAL.cMeaurementsDAL().InsertDetails(d));
 }
        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);
            }
        }