Ejemplo n.º 1
0
        private void saveContrButton_Click(object sender, EventArgs e)
        {
            connectionString = @"Data Source=.\SQLEXPRESS; Initial Catalog = D:\НАСТЯ\ДИПЛОМ\ACCOUNT_GRAIN.MDF; Integrated Security = True";
            if (contr == null)
            {
                contr = new Contractor(nameContrTextBox.Text, subTextBox.Text, yurAdressTextBox.Text, factAdressTextBox.Text, Convert.ToInt32(indexTextBox.Text), phoneTextBox.Text, innTextBox.Text);
                string sql = "Insert into Сontractor (name_contractor,subdivision,jur_address,fact_address,mail_index,phone,inn) values (@name_contractor, @subdivision, @jur_address, @fact_address, @mail_index, @phone, @inn)";
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand(sql, connection);
                    connection.Open();
                    cmd.Parameters.AddWithValue("@name_contractor", contr.Name);
                    cmd.Parameters.AddWithValue("@subdivision", contr.Sub);
                    cmd.Parameters.AddWithValue("@jur_address", contr.YurAdress);
                    cmd.Parameters.AddWithValue("@fact_address", contr.FactAdress);
                    cmd.Parameters.AddWithValue("@mail_index", contr.Index);
                    cmd.Parameters.AddWithValue("@phone", contr.Phone);
                    cmd.Parameters.AddWithValue("@inn", contr.Inn);
                    cmd.ExecuteNonQuery();
                    connection.Close();
                }
            }
            else
            {
                contr.Name       = nameContrTextBox.Text;
                contr.Sub        = subTextBox.Text;
                contr.YurAdress  = yurAdressTextBox.Text;
                contr.FactAdress = factAdressTextBox.Text;
                contr.Index      = Convert.ToInt32(indexTextBox.Text);
                contr.Phone      = phoneTextBox.Text;
                contr.Inn        = innTextBox.Text;
                string sql = string.Format("Update Сontractor Set name_contractor='{0}',subdivision='{1}', jur_address='{2}', fact_address='{3}', mail_index='{4}', phone='{5}', inn='{6}' where id_contractor='{7}'",
                                           contr.Name, contr.Sub, contr.YurAdress, contr.FactAdress, contr.Index, contr.Phone, contr.Inn, contr.Id);
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand(sql, connection);
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    connection.Close();
                }
            }

            this.Close();
        }
Ejemplo n.º 2
0
 private void removeContagentButton_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow row = dataGridView1.SelectedRows[0];
         DialogResult    dr  = MessageBox.Show("Вы действительно хотите удалить запись?",
                                               "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
         if (dr == DialogResult.OK)
         {
             Contractor contr = new Contractor(Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value));
             string     sql   = string.Format("Delete from Сontractor where id_contractor='{0}'", contr.Id);
             using (SqlConnection connection = new SqlConnection(connectionString))
             {
                 SqlCommand cmd = new SqlCommand(sql, connection);
                 connection.Open();
                 cmd.ExecuteNonQuery();
                 connection.Close();
             }
             this.сontractorTableAdapter.Fill(this.account_grainDataSet.Сontractor);
         }
     }
     catch (System.ArgumentOutOfRangeException) { MessageBox.Show("Выберите контрагента!", "Удаление", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Ejemplo n.º 3
0
        public void AddContractor(String name, String address, String landLine, String mobile, String employeeID, String email)
        {
            // Open database (or create if not exits)
            using (var db = new LiteDatabase(@"IQIncorporated.db"))
            {
                // Get contractors collection
                var contractors = db.GetCollection <Contractor>("contractors");

                // Create your new contractor instance
                var contractor = new Contractor
                {
                    Name       = name,
                    Address    = address,
                    LandLine   = landLine,
                    Mobile     = mobile,
                    EmployeeID = employeeID,
                    Email      = email
                };

                // Insert new customer document (Id will be auto-incremented)
                contractors.Insert(contractor);
            }
        }
Ejemplo n.º 4
0
        private void CompleteSave_Click(object sender, EventArgs e)
        {
            //checks if the cost and description are empty
            if (CompleteCost.Text != "" && CompleteDescription.Text != "")
            {
                Job        jobTable        = new Job();
                Contractor contractorTable = new Contractor();
                Client     clientTable     = new Client();

                //Updates job with new information
                if (JobListView.SelectedIndices.Count > 0)
                {
                    jobTable.UpdateJob(Int32.Parse(JobListView.Items[JobListView.SelectedIndices[0]].SubItems[4].Text.Trim()), CompleteCost.Text, CompleteDescription.Text, FinishedCheck.Checked);
                }
                else
                {
                    MessageBox.Show("Please reselect the current job");
                }
            }
            else
            {
                MessageBox.Show("Please add the price and/or the description and/or select a valid job");
            }
        }