示例#1
0
 public static void WriteOff(PaymentNote target)
 {
     using (var cmd = new System.Data.SQLite.SQLiteCommand(DataBase.Instance.sqlConnection))
     {
         cmd.Parameters.Add(cmd.CreateParameter());
         cmd.CommandText = "update DebitNotes set WroteOff = DateTime('now','localtime') where Id = " + target.Id;
         cmd.ExecuteNonQuery();
     }
 }
示例#2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtCompanyName.Text == string.Empty)
            {
                txtCompanyName.Focus();
                return;
            }

            //Submit all changes
            if (currentState == AddressBookState.Add)
            {
                using (var cmd = new System.Data.SQLite.SQLiteCommand(DataBase.Instance.sqlConnection))
                {
                    cmd.CommandText = "insert into AddressBook(CompanyName,President,Contact,Tel,Fax,Cellphone,Address1,Address2,SerialNumber,State,PhoneFormatId) values(@CompanyName,@President,@Contact,@Tel,@Fax,@Cellphone,@Address1,@Address2,@SerialNumber,@State,@PhoneFormatId); Select last_insert_rowid()";
                    System.Data.SQLite.SQLiteParameter[] parameters = new System.Data.SQLite.SQLiteParameter[11];
                    parameters[0] = new System.Data.SQLite.SQLiteParameter("CompanyName", txtCompanyName.Text);
                    parameters[1] = new System.Data.SQLite.SQLiteParameter("President", txtPresident.Text);
                    parameters[2] = new System.Data.SQLite.SQLiteParameter("Contact", txtContact.Text);
                    parameters[3] = new System.Data.SQLite.SQLiteParameter("Tel", mtxtTel.Text);
                    parameters[4] = new System.Data.SQLite.SQLiteParameter("Fax", mtxtFax.Text);
                    parameters[5] = new System.Data.SQLite.SQLiteParameter("Cellphone", mtxtCellphone.Text);
                    parameters[6] = new System.Data.SQLite.SQLiteParameter("Address1", txtAddress1.Text);
                    parameters[7] = new System.Data.SQLite.SQLiteParameter("Address2", txtAddress2.Text);
                    parameters[8] = new System.Data.SQLite.SQLiteParameter("SerialNumber", mtxtSerialNumber.Text);
                    parameters[9] = new System.Data.SQLite.SQLiteParameter("State", cbbState.SelectedText);
                    parameters[10] = new System.Data.SQLite.SQLiteParameter("PhoneFormatId", cbbPhoneFormat.SelectedIndex);
                    cmd.Parameters.AddRange(parameters);
                    long insertedId = (long)cmd.ExecuteScalar();
                    CurrentCompany.Id = (int)insertedId;
                }
            }
            else if (currentState == AddressBookState.Modify)
            {
                using (var cmd = new System.Data.SQLite.SQLiteCommand(DataBase.Instance.sqlConnection))
                {
                    cmd.Parameters.Add(cmd.CreateParameter());
                    cmd.CommandText = "update AddressBook set CompanyName = @CompanyName,President = @President,Contact = @Contact,Tel = @Tel,Fax = @Fax,Cellphone = @Cellphone,Address1 = @Address1,Address2 = @Address2, SerialNumber = @SerialNumber, State = @State, PhoneFormatId = @PhoneFormatId where Id = @Id";
                    System.Data.SQLite.SQLiteParameter[] parameters = new System.Data.SQLite.SQLiteParameter[12];
                    parameters[0] = new System.Data.SQLite.SQLiteParameter("CompanyName", txtCompanyName.Text);
                    parameters[1] = new System.Data.SQLite.SQLiteParameter("President", txtPresident.Text);
                    parameters[2] = new System.Data.SQLite.SQLiteParameter("Contact", txtContact.Text);
                    parameters[3] = new System.Data.SQLite.SQLiteParameter("Tel", mtxtTel.Text);
                    parameters[4] = new System.Data.SQLite.SQLiteParameter("Fax", mtxtFax.Text);
                    parameters[5] = new System.Data.SQLite.SQLiteParameter("Cellphone", mtxtCellphone.Text);
                    parameters[6] = new System.Data.SQLite.SQLiteParameter("Address1", txtAddress1.Text);
                    parameters[7] = new System.Data.SQLite.SQLiteParameter("Address2", txtAddress2.Text);
                    parameters[8] = new System.Data.SQLite.SQLiteParameter("Id", CurrentCompany.Id);
                    parameters[9] = new System.Data.SQLite.SQLiteParameter("SerialNumber", mtxtSerialNumber.Text);
                    parameters[10] = new System.Data.SQLite.SQLiteParameter("State", cbbState.Text);
                    parameters[11] = new System.Data.SQLite.SQLiteParameter("PhoneFormatId", cbbPhoneFormat.SelectedIndex);
                    cmd.Parameters.AddRange(parameters);
                    cmd.ExecuteNonQuery();
                }
            }
            currentState = AddressBookState.View;

            companies.ResetItem(customControl1.SelectedIndex);

            UpdateControls();
        }
示例#3
0
 public static void Delete(PaymentNote target)
 {
     using (var cmd = new System.Data.SQLite.SQLiteCommand(DataBase.Instance.sqlConnection))
     {
         cmd.Parameters.Add(cmd.CreateParameter());
         cmd.CommandText = "delete from DebitNotes where Id = " + target.Id;
         cmd.ExecuteNonQuery();
     }
 }