示例#1
0
        private void Createbtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(IDtxt.Text) || string.IsNullOrEmpty(Nametxt.Text) || string.IsNullOrEmpty(Emailtxt.Text) || string.IsNullOrEmpty(Phonenumbertxt.Text) || string.IsNullOrEmpty(Addresstxt.Text) || string.IsNullOrEmpty(Companytxt.Text) || string.IsNullOrEmpty(VatNotxt.Text))
            {
                return;
            }
            ListViewItem item = new ListViewItem(IDtxt.Text);

            item.SubItems.Add(Nametxt.Text);
            item.SubItems.Add(Emailtxt.Text);
            item.SubItems.Add(Phonenumbertxt.Text);
            item.SubItems.Add(Addresstxt.Text);
            item.SubItems.Add(Companytxt.Text);
            item.SubItems.Add(VatNotxt.Text);
            item.SubItems.Add(Statustxt.Text);
            listView1.Items.Add(item);
            IDtxt.Clear();
            Nametxt.Clear();
            Emailtxt.Clear();
            Phonenumbertxt.Clear();
            Addresstxt.Clear();
            Companytxt.Clear();
            VatNotxt.Clear();
            IDtxt.Focus();
        }
示例#2
0
 private void resetTextboxes()
 {
     fnametxt.Clear();
     Surnametxt.Clear();
     TeleNotxt.Clear();
     Postcodetxt.Clear();
     Addresstxt.Clear();
 }
示例#3
0
        private void Insertbtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameTxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                nameTxt.Focus();
                return;
            }
            if (dtmtxt.Text == "")
            {
                dtmtxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dtmtxt.Focus();
                return;
            }
            if (ConNumtxt.Text == "")
            {
                ConNumtxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ConNumtxt.Focus();
                return;
            }

            if (Addresstxt.Text == "")
            {
                Addresstxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Addresstxt.Focus();
                return;
            }
            if (Agetxt.Text == "")
            {
                Agetxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Agetxt.Focus();
                return;
            }
            if (HosChartxt.Text == "")
            {
                HosChartxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HosChartxt.Focus();
                return;
            }
            if (ProfChartxt.Text == "")
            {
                ProfChartxt.BackColor = Color.LightPink;
                MessageBox.Show("Name is required", "validation error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ProfChartxt.Focus();
                return;
            }
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                if (Insertbtn.Text == "Insert")
                {
                    SqlCommand sqlCmd = new SqlCommand("OutPBill", con);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.Parameters.AddWithValue("@mode", "Add");
                    sqlCmd.Parameters.AddWithValue("@PatientId", 0);
                    sqlCmd.Parameters.AddWithValue("@Name", nameTxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Date", dtmtxt.Value.Date);
                    sqlCmd.Parameters.AddWithValue("@Contact_Number", ConNumtxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Address", Addresstxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Age", Agetxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Hospital_Charge", HosChartxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@profs_Charge", ProfChartxt.Text.Trim());
                    sqlCmd.ExecuteNonQuery();
                    MessageBox.Show("Data inserted successfully");
                }
                Reset();
                FillDataGridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Message");
            }
            finally
            {
                con.Close();
            }
            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                if (Insertbtn.Text == "Insert")
                {
                    SqlCommand sqlCmd = new SqlCommand("OutPDProc", con);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.Parameters.AddWithValue("@mode", "Add");
                    sqlCmd.Parameters.AddWithValue("@PatientId", 0);
                    sqlCmd.Parameters.AddWithValue("@Name", nameTxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Contact_Number", ConNumtxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Address", Addresstxt.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Age", Agetxt.Text.Trim());
                }
                Reset1();
                FillDataGridView1();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Message");
            }
            finally
            {
                con.Close();
            }
        }