public void SetInputForms(int clientid, int organid, JournalItem item) { if (item!=null) { journalItem = item; textEditJournalNumber.Text=item.ID_Real_Journal.ToString(); dateEdit.Text = item.DateJournal.ToShortDateString(); } if ((organization != null) && (clients != null)) { Organization org = organization.Find(u => u.ID.Equals(organid)); Client client = clients.Find(x => x.ID.Equals(clientid)); if (client != null) { txtName.Text = client.Name; txtSurname.Text = client.SurName; txtSecondName.Text = client.SecondName; txtPhone.Text = client.Phone; IdClient = clientid; } if (org != null) { if (mruEditOrganization.Properties.Items.Contains(org)) { IdOrganization = org.ID; mruEditOrganization.Text = org.OrganizationName; } } } }
public void SetInputForms(JournalItem item, List<UslugiCategory> listUslugi) { uslugiCategoryBindingSource.DataSource = listUslugi; if (item != null) { journalItem = item; } }
public static List<JournalItem> GetJournalItems(DateTime dateFrom, DateTime dateTo) { List<JournalItem> journalList = new List<JournalItem>(); try { SqlConnection connection = OpenConnection(); if ((connection == null) || (connection.State == ConnectionState.Closed)) return null; SqlCommand ngCommand = connection.CreateCommand(); ngCommand.CommandType = CommandType.StoredProcedure; ngCommand.Parameters.AddWithValue("@dateFrom", dateFrom); ngCommand.Parameters.AddWithValue("@dateTo", dateTo); ngCommand.CommandText = GET_JOURNALITEMS_REGISRTY; // ngCommand.CommandTimeout = CommandTimeOut > 2 * connection.ConnectionTimeout ? CommandTimeOut : 2 * connection.ConnectionTimeout; ngCommand.ExecuteNonQuery(); SqlDataReader reader = null; if (connection != null) { reader = ngCommand.ExecuteReader(); while (reader.Read()) { JournalItem newItem = new JournalItem(); if (!DBNull.Value.Equals(reader["ID"])) newItem.ID = (int)reader["ID"]; if (!DBNull.Value.Equals(reader["Date"])) newItem.DateJournal = (DateTime)reader["Date"]; if (!DBNull.Value.Equals(reader["ID_Organization"])) newItem.ID_Org = (int)reader["ID_Organization"]; if (!DBNull.Value.Equals(reader["ID_Client"])) newItem.ID_Client = (int)reader["ID_Client"]; if (!DBNull.Value.Equals(reader["CommonPrice"])) newItem.CommonPrice = (double)reader["CommonPrice"]; if (!DBNull.Value.Equals(reader["Description"])) newItem.Description = (string)reader["Description"]; if (!DBNull.Value.Equals(reader["ID_Real_Journal"])) newItem.ID_Real_Journal = (int)reader["ID_Real_Journal"]; if (!DBNull.Value.Equals(reader["OrganizationName"])) newItem.OrganizationName = (string)reader["OrganizationName"]; if (!DBNull.Value.Equals(reader["ClientName"])) newItem.ClientName = (string)reader["ClientName"]; if (!DBNull.Value.Equals(reader["IsPaid"])) newItem.IsPaid = (bool)reader["IsPaid"]; if (!DBNull.Value.Equals(reader["OstatokSumma"])) newItem.OstatokSumma = (double)reader["OstatokSumma"]; if (!DBNull.Value.Equals(reader["PaidSumma"])) newItem.PaidSumma = (double)reader["PaidSumma"]; journalList.Add(newItem); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseConnection(); return null; } CloseConnection(); return journalList; }
public static void EditJournalItem(JournalItem journal) { try { SqlConnection connection = OpenConnection(); if ((connection == null) || (connection.State == ConnectionState.Closed)) return; SqlCommand ngCommand = connection.CreateCommand(); ngCommand.CommandType = CommandType.StoredProcedure; ngCommand.CommandText = EDIT_JOURNAL_REGISRTY; ngCommand.Parameters.AddWithValue("@Id", journal.ID); ngCommand.Parameters.AddWithValue("@IdClient", journal.ID_Client); ngCommand.Parameters.AddWithValue("@IdOrg", journal.ID_Org); ngCommand.Parameters.AddWithValue("@DateJournal", journal.DateJournal); ngCommand.Parameters.AddWithValue("@Description", journal.Description); ngCommand.Parameters.AddWithValue("@IDInRealJournal", journal.ID_Real_Journal); ngCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseConnection(); return; } CloseConnection(); return; }
public static void UpdateUslugiJournaliItem(List<UslugiCategory> listUslugi, JournalItem journal, double commonPrice, bool isPaided, double paidsumma, double ostatoksumma) { try { SqlConnection connection = OpenConnection(); if ((connection == null) || (connection.State == ConnectionState.Closed)) return; if (listUslugi.Count > 0) { DataTable dataTable = new DataTable("AssignedProcedureTableType"); dataTable.Columns.Add("ID_Uslugi", typeof(Int32)); dataTable.Columns.Add("Price", typeof(double)); dataTable.Columns.Add("IsPaid", typeof(bool)); foreach (UslugiCategory usluga in listUslugi) { dataTable.Rows.Add(usluga.ID, usluga.Price, usluga.IsPaid); } SqlCommand ngCommand = connection.CreateCommand(); ngCommand.CommandType = CommandType.StoredProcedure; ngCommand.CommandText = UPDATE_JOURNALITEM_USIGNED_PROCEDURE_REGISRTY; SqlParameter parameter = new SqlParameter(); //The parameter for the SP must be of SqlDbType.Structured parameter.ParameterName = "@TableProced"; parameter.SqlDbType = System.Data.SqlDbType.Structured; parameter.Value = dataTable; ngCommand.Parameters.Add(parameter); ngCommand.Parameters.AddWithValue("@Id", journal.ID); ngCommand.Parameters.AddWithValue("@CommonPrice", commonPrice); ngCommand.Parameters.AddWithValue("@IsPaided", isPaided); ngCommand.Parameters.AddWithValue("@PaidSumma", paidsumma); ngCommand.Parameters.AddWithValue("@OstatokSumma", ostatoksumma); ngCommand.Parameters.AddWithValue("@IdClient", journal.ID_Client); ngCommand.Parameters.AddWithValue("@DateJournal", journal.DateJournal); ngCommand.ExecuteNonQuery(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseConnection(); return; } CloseConnection(); return; }