public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddString("SerialNumber", serialNumber); cmd.AddString("IssueDepartment", issueDepartment); cmd.AddDateTime("IssueDate", issueDate); cmd.AddString("DepartmentCode", departmentCode); cmd.AddString("Surname", surname); cmd.AddString("Name", name); cmd.AddString("MiddleName", middleName); cmd.AddInt("Gender", (int)gender); cmd.AddDateTime("Birthday", birthday); cmd.AddString("BirthPlace", birthPlace); cmd.AddString("Registration", registration); if (id == 0) { cmd.CommandText = "insert into Passports values (@SerialNumber,@IssueDepartment,@IssueDate,@DepartmentCode,@Surname,@Name,@MiddleName,@Gender,@Birthday,@BirthPlace,@Registration) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Passports set SerialNumber=@SerialNumber,IssueDepartment=@IssueDepartment,IssueDate=@IssueDate,DepartmentCode=@DepartmentCode,Surname=@Surname,Name=@Name,MiddleName=@MiddleName,Gender=@Gender,Birthday=@Birthday,BirthPlace=@BirthPlace,Registration=@Registration where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Write(LogType logType, string msg) { try { using (GmConnection conn = Global.CreateConnection()) { GmCommand cmd = conn.CreateCommand("insert into Log values (@Time,@SessionId,@LogTypeId,@Page,@Message)"); cmd.AddDateTime("Time", DateTime.Now); cmd.AddInt("SessionId", (int)sessionId); cmd.AddInt("LogTypeId", (int)logType); cmd.AddString("Page", page); cmd.AddString("Message", msg, MaxLength.Log.Message); cmd.ExecuteNonQuery(); } } catch { } switch (logType) { case LogType.Error: case LogType.Exception: if (ctl != null) { ctl.Page.Response.Write(string.Format("<p>{0}</p>", msg)); } break; } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("PassportId", passportId); cmd.AddInt("InsuranceId", insuranceId); cmd.AddInt("PatientIdentificationId", patientIdentificationId); cmd.AddInt("DoctorId", doctorId); cmd.AddInt("DiagnosisId", diagnosisId); cmd.AddString("PatientData", patientData.GetXmlString()); cmd.AddString("PatientDescription", patientDescription.GetXmlString()); cmd.AddDateTime("AdmissionDate", admissionDate); cmd.AddInt("WardId", wardId); cmd.AddInt("PatientTypeId", (int)patientTypeId); cmd.AddString("PatientDiagnoses", patientDiagnoses.GetXmlString()); cmd.AddString("DietNumber", dietNumber); cmd.AddInt("Status", (int)status); if (id == 0) { cmd.CommandText = "insert into Patients values (@PassportId,@InsuranceId,@PatientIdentificationId,@DoctorId,@DiagnosisId,@PatientData,@PatientDescription,@AdmissionDate,@WardId,@PatientTypeId,0,null,null,@PatientDiagnoses,@DietNumber, @Status) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = @"update Patients set PassportId=@PassportId,InsuranceId=@InsuranceId,PatientIdentificationId=@PatientIdentificationId,DoctorId=@DoctorId,DiagnosisId=@DiagnosisId,PatientData=@PatientData,PatientDescription=@PatientDescription,AdmissionDate=@AdmissionDate,WardId=@WardId,PatientTypeId=@PatientTypeId,PatientDiagnoses=@PatientDiagnoses,DietNumber=@DietNumber, Status=@Status where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Update(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); // cmd.AddInt("RecordId", recordId); cmd.AddDateTime("Date", date); cmd.AddString("Name", name, MaxLength.UserInfo.Name); cmd.AddString("Email", email, MaxLength.UserInfo.Email); cmd.CommandText = "update UserInfo set Date=@Date,Name=@Name,Email=@Email"; if (psw.Length > 0) { cmd.CommandText += ",Psw=@Psw"; cmd.AddString("Psw", psw, MaxLength.UserInfo.Psw); } if (picture.Length > 0) { cmd.CommandText += ",Picture=@Picture"; cmd.AddString("Picture", picture, MaxLength.UserInfo.Picture); } // cmd.AddInt("UserRole", (int)userRole); // cmd.AddInt("Status", (int)status); cmd.CommandText += " where Id=@Id"; cmd.ExecuteNonQuery(); }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("PositionId", positionId); cmd.AddDateTime("Date", date); cmd.AddString("Name", name); cmd.AddString("Surname", surname); cmd.AddString("Address", address); cmd.AddString("Phone", phone); cmd.AddString("Link", link); cmd.AddString("Email", email); cmd.AddString("Resume", resume); cmd.AddString("Comments", comments); cmd.AddInt("Status", (int)status); if (id == 0) { cmd.CommandText = "insert into Candidates values (@PositionId,@Date,@Name,@Surname,@Address,@Phone,@Link,@Email,@Resume,@Comments,@Status) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { // cmd.CommandText = "update Competitors set PositionId=@PositionId,Date=@Date,Name=@Name,Surname=@Surname,Address=@Address,Phone=@Phone,Link=@Link,Email=@Email, Resume=@Resume, Comments=@Comments,Status=@Status where Id=@Id"; // cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("ParentId", (int)parentId); cmd.AddDateTime("Date", date); cmd.AddString("Person", person); cmd.AddString("Title", title); cmd.AddString("Preview", preview); cmd.AddString("Header", header); cmd.AddString("Text", text); cmd.AddString("Company", company); cmd.AddInt("CityId", cityId); cmd.AddString("Address", address); cmd.AddString("Phone", phone); cmd.AddString("Link", link); cmd.AddString("Email", email); cmd.AddInt("Status", (int)status); cmd.AddString("Tag", tag); cmd.AddBoolean("IsGroup", isGroup); if (id == 0) { cmd.CommandText = "insert into Articles values (@ParentId,@Date,@Person,@Title,@Preview,@Header,@Text,@Company,@CityId,@Address,@Phone,@Link,@Email, @Status,@Tag,@IsGroup) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Articles set ParentId=@ParentId,Date=@Date,Person=@Person,Title=@Title,Preview=@Preview,Header=@Header,Text=@Text,Company=@Company,CityId=@CityId,Address=@Address,Phone=@Phone,Link=@Link,Email=@Email,Status=@Status, Tag=@Tag, IsGroup=@IsGroup where Id=@Id"; cmd.ExecuteNonQuery(); } }
int LoadData() { reportsDataSet.PatientsPrescriptions.Clear(); doc.documentData.prescriptionTypes.Clear(); foreach (PrescriptionType prescriptionType in lbPrescriptionTypes.CheckedItems) { doc.documentData.prescriptionTypes.Add(prescriptionType.Id); } doc.date = dpDate.Value.Date; if (doc.documentData.prescriptionTypes.Count == 0) { return(0); } string cmdText = @" SELECT Wards.Number AS WardNumber, Prescriptions.PatientId, Passports.Surname + ' ' + Passports.Name AS PatientName, PrescriptionTypes.Name AS PrescriptionTypeName, Products.Name AS ProductName, Prescriptions.Dose, BaseUnits.Name AS BaseUnitName, Prescriptions.Multiplicity FROM Prescriptions LEFT OUTER JOIN StoreProducts ON StoreProducts.Id = Prescriptions.StoreProductId LEFT OUTER JOIN Products ON Products.Id = StoreProducts.ProductId LEFT OUTER JOIN BaseUnits ON BaseUnits.Id = Products.BaseUnitId LEFT OUTER JOIN PrescriptionTypes ON PrescriptionTypes.Id = Prescriptions.PrescriptionTypeId LEFT OUTER JOIN Patients ON Patients.Id = Prescriptions.PatientId LEFT OUTER JOIN Wards ON Wards.Id = Patients.WardId LEFT OUTER JOIN Passports ON Passports.Id = Patients.PassportId WHERE (Prescriptions.StartDate <= @EndDate) AND (@StartDate <= Prescriptions.EndDate)"; cmdText += string.Format(" and PrescriptionTypeId in ({0})", CollectionUtils.GetCommaSeparatedList(doc.documentData.prescriptionTypes)); if (hasWatching) { cmdText += string.Format(" and PatientId in ({0})", CollectionUtils.GetCommaSeparatedList(doc.documentData.patients)); } else { cmdText += " and (DischargeDate is null)"; } cmdText += " ORDER BY WardNumber, Prescriptions.PatientId"; using (GmConnection conn = App.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddDateTime("StartDate", doc.date); cmd.AddDateTime("EndDate", doc.date + TimeSpan.FromDays(1)); cmd.Fill(reportsDataSet.PatientsPrescriptions); } return(reportsDataSet.PatientsPrescriptions.Rows.Count); }
public int SaveWardHistory(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("PatientId", id); cmd.AddDateTime("Date", DateTime.Now); cmd.AddInt("WardId", wardId); cmd.AddInt("PatientTypeId", (int)patientTypeId); cmd.CommandText = "insert into PatientWardHistory values (@PatientId,@Date,@WardId,@PatientTypeId) select @@Identity"; return((int)(decimal)cmd.ExecuteScalar()); }
public ReportsDataSet.ReacardPrescriptionsDataTable GetReacardPrescriptionsTable(ConnectionFactory factory) { DataTable dataTable = new DataTable(); string cmdText = @"select Prescriptions.*, Products.Name as ProductName, BaseUnits.Name as BaseUnitName, UnitCount, PrescriptionTypes.ShortName from Prescriptions left join StoreProducts on StoreProducts.Id=StoreProductId left join Products on Products.Id=ProductId left join BaseUnits on BaseUnits.Id=BaseUnitId left join PrescriptionTypes on PrescriptionTypes.Id=PrescriptionTypeId where PatientId=@PatientId and StartDate<@EndTime and EndDate>@StartTime and ReanimationFlag=1 order by PrescriptionTypeId, StartDate"; //and PrescriptionTypeId=@PrescriptionTypeId DateTime startTime = reacard.date.Date + TimeSpan.FromHours(9); DateTime endTime = startTime + TimeSpan.FromHours(24); using (GmConnection conn = factory.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("PatientId", patient.Id); cmd.AddDateTime("StartTime", startTime); cmd.AddDateTime("EndTime", endTime); // cmd.AddInt("PrescriptionTypeId", PrescriptionTypeId.IntravenousInjection); conn.Fill(dataTable, cmd); } ReportsDataSet.ReacardPrescriptionsDataTable dtReacardPrescriptions = new ReportsDataSet.ReacardPrescriptionsDataTable(); foreach (DataRow dr in dataTable.Rows) { string productName = string.Format("{0} {1}{2} {3}", dr["ProductName"], dr["UnitCount"], dr["BaseUnitName"], dr["ShortName"]); DateTime startDate = (DateTime)dr["StartDate"]; DateTime endDate = (DateTime)dr["EndDate"]; CreateRow(dtReacardPrescriptions, productName, startDate, endDate, reacard.date); } return(dtReacardPrescriptions); }
public static void GetPrescriptions(GmConnection conn, List <Prescription> prescriptions, IEnumerable <int> patients, IEnumerable <int> prescriptionTypes, DateTime startDate, DateTime endDate, bool reanimationFlag) { string cmdText = @"select * from Prescriptions where PatientId in ({0}) and PrescriptionTypeId in ({1}) and StartDate<@EndDate and EndDate>@StartDate and ReanimationFlag=@ReanimationFlag "; cmdText = string.Format(cmdText, CollectionUtils.GetCommaSeparatedList(patients), CollectionUtils.GetCommaSeparatedList(prescriptionTypes)); GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddDateTime("StartDate", startDate); cmd.AddDateTime("EndDate", endDate); cmd.AddBoolean("ReanimationFlag", reanimationFlag); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { prescriptions.Add(new Prescription(dr)); } } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddDateTime("Date", date); cmd.AddString("Text", text, MaxLength.LinkExchangePages.Text); if (id == 0) { cmd.CommandText = "insert into LinkExchange values (@Id,@Date,@Text)"; // id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update LinkExchange set Date=@Date,Text=@Text where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddDateTime("Date", date); cmd.AddString("Question", question); cmd.AddInt("Status", (int)status); if (id == 0) { cmd.CommandText = "insert into Polls values (@Date,@Question,@Status) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Polls set Date=@Date,Question=@Question,Status=@Status where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("PatientId", patientId); cmd.AddDateTime("RequestDate", requestDate); cmd.AddNullableDateTime("ExecutionDate", executionDate); cmd.AddString("ConsultationData", consultationData.GetXmlString()); if (id == 0) { cmd.CommandText = "insert into PatientConsultations values (@PatientId,@RequestDate,@ExecutionDate,@ConsultationData) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update PatientConsultations set PatientId=@PatientId,RequestDate=@RequestDate,ExecutionDate=@ExecutionDate,ConsultationData=@ConsultationData where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("PatientId", patientId); cmd.AddDateTime("Date", date); cmd.AddString("ReacardData", reacardData.GetXmlString()); if (id == 0) { cmd.CommandText = "insert into Reacards values (@PatientId,@Date,@ReacardData) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Reacards set PatientId=@PatientId,Date=@Date,ReacardData=@ReacardData where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("ForumId", forumId); cmd.AddDateTime("Date", date); cmd.AddString("Name", name, MaxLength.ForumTopics.Name); cmd.AddString("Description", description, MaxLength.ForumTopics.Description); cmd.AddInt("Status", (int)status); if (id == 0) { cmd.CommandText = "insert into ForumTopics values (@ForumId,@Date,@Name,@Description,@Status) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update ForumTopics set ForumId=@ForumId,Name=@Name,Description=@Description,Status=@Status where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("UserId", userId); cmd.AddDateTime("StartTime", startTime); cmd.AddNullableDateTime("EndTime", endTime); cmd.AddString("Data", data.GetXmlString()); if (id == 0) { cmd.CommandText = "insert into Watching values (@UserId,@StartTime,@EndTime,@Data) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Watching set UserId=@UserId,StartTime=@StartTime,EndTime=@EndTime,Data=@Data where Id=@Id"; cmd.ExecuteNonQuery(); } }
public int Save(GmConnection conn, bool newRecord) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("RestoredId", restoredId); cmd.AddInt("UserId", userId); cmd.AddInt("Version", version); cmd.AddDateTime("Time", time); cmd.AddString("Config", config.Serialize()); cmd.AddString("Comment", comment); if (newRecord) { cmd.CommandText = "insert into ConfigRecords values (@Id,@RestoredId,@UserId,@Version,@Time,@Config,@Comment)"; } else { cmd.CommandText = "update ConfigRecords set RestoredId=@RestoredId,UserId=@UserId,Version=@Version,Time=@Time,Config=@Config,Comment=@Comment where Id=@Id"; } return(cmd.ExecuteNonQuery()); }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("PatientId", patientId); cmd.AddInt("DoctorId", doctorId); cmd.AddDateTime("Time", time); cmd.AddString("Description", description.GetXmlString()); cmd.AddInt("ObservationTypeId", (int)observationTypeId); if (id == 0) { cmd.CommandText = "insert into Observations values (@PatientId,@DoctorId,@Time,@Description,@ObservationTypeId) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Observations set PatientId=@PatientId,DoctorId=@DoctorId,Time=@Time,Description=@Description,ObservationTypeId=@ObservationTypeId where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn, DbTransaction trans) { GmCommand cmd = conn.CreateCommand(trans); cmd.AddInt("Id", id); cmd.AddDateTime("Date", date); cmd.AddInt("UserId", userId); cmd.AddInt("DocumentTypeId", (int)documentTypeId); cmd.AddBoolean("Completed", completed); cmd.AddInt("StorekeeperId", storekeeperId); cmd.AddInt("NDays", nDays); cmd.AddString("DocumentData", documentData.GetXmlString()); if (id == 0) { cmd.CommandText = "insert into Documents values (@Date,@UserId,@DocumentTypeId,@Completed,@StorekeeperId,@NDays,@DocumentData) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update Documents set Date=@Date,UserId=@UserId,DocumentTypeId=@DocumentTypeId,Completed=@Completed,StorekeeperId=@StorekeeperId,NDays=@NDays,DocumentData=@DocumentData where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("RecordId", recordId); cmd.AddDateTime("Date", date); cmd.AddString("Name", name, MaxLength.UserInfo.Name); cmd.AddString("Email", email, MaxLength.UserInfo.Email); cmd.AddString("Psw", psw, MaxLength.UserInfo.Psw); cmd.AddInt("UserRole", (int)userRole); cmd.AddInt("Status", (int)status); cmd.AddString("Picture", picture, MaxLength.UserInfo.Picture); if (id == 0) { cmd.CommandText = "insert into UserInfo values (@RecordId,@Date,@Name,@Email,@Psw,@UserRole,@Status,@Picture) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { cmd.CommandText = "update UserInfo set RecordId=@RecordId,Date=@Date,Name=@Name,Email=@Email,Psw=@Psw,UserRole=@UserRole,Status=@Status,Picture=@Picture where Id=@Id"; cmd.ExecuteNonQuery(); } }
public void Save(GmConnection conn) { GmCommand cmd = conn.CreateCommand(); cmd.AddInt("Id", id); cmd.AddInt("MessageId", messageId); cmd.AddInt("ForumTopicId", forumTopicId); cmd.AddDateTime("Date", date); cmd.AddInt("UserId", userId); cmd.AddString("UserName", userName, MaxLength.ForumMessages.UserName); cmd.AddString("Text", text, MaxLength.ForumMessages.Text); cmd.AddInt("Status", (int)status); if (id == 0) { cmd.CommandText = "insert into ForumMessages values (@MessageId,@ForumTopicId,@Date,@UserId,@UserName,@Text,@Status) select @@Identity"; id = (int)(decimal)cmd.ExecuteScalar(); } else { // cmd.CommandText = "update ForumMessage set MessageId=@MessageId,ForumTopicId=@ForumTopicId,Date=@Date,UserId=@UserId,UserName=@UserName,Text=@Text,Status=@Status where Id=@Id"; cmd.CommandText = "update ForumMessages set UserName=@UserName,Text=@Text,Status=@Status where Id=@Id"; cmd.ExecuteNonQuery(); } }
void LoadData() { using (WaitCursor wc = new WaitCursor()) { colUserName.Visible = (int)cbUser.SelectedValue == 0; colLogType.Visible = (int)cbLogType.SelectedValue == 0; StringBuilder query = new StringBuilder(); StringBuilder join = new StringBuilder(); StringBuilder cond = new StringBuilder(); query.Append("select Log.Id, Log.Time,"); if (colUserName.Visible) { query.Append(" Users.Name as UserName,"); join.Append(" left join Users on Users.Id=UserId"); } if (colUserName.Visible) { query.Append(" LogTypes.Name as LogTypeName,"); join.Append(" left join LogTypes on LogTypes.Id=LogType"); } query.Append(" Header, Message from Log"); using (GmConnection conn = App.CreateConnection()) { GmCommand cmd = conn.CreateCommand(); if (ucTimeRange.FromTimeChecked) { if (cond.Length > 0) { cond.Append(" and"); } cond.Append(" Time>@FromTime"); cmd.AddDateTime("FromTime", ucTimeRange.FromTime); } if (ucTimeRange.ToTimeChecked) { if (cond.Length > 0) { cond.Append(" and"); } cond.Append(" Time<@ToTime"); cmd.AddDateTime("ToTime", ucTimeRange.ToTime); } if ((int)cbUser.SelectedValue != 0) { if (cond.Length > 0) { cond.Append(" and"); } cond.Append(" UserId=@UserId"); cmd.AddInt("UserId", (int)cbUser.SelectedValue); } if ((int)cbLogType.SelectedValue != 0) { if (cond.Length > 0) { cond.Append(" and"); } cond.Append(" LogType=@LogType"); cmd.AddInt("LogType", (int)cbLogType.SelectedValue); } if (cond.Length > 0) { cond.Insert(0, " where"); } cmd.CommandText = query.ToString() + join.ToString() + cond.ToString(); dataTable.Rows.Clear(); dataTable.Columns.Clear(); dataTable.Clear(); conn.Fill(dataTable, cmd); } gridView.DataSource = dataTable; } }