Esempio n. 1
0
        public static int RemoveDocumentProducts(GmConnection conn, int documentId)
        {
            GmCommand cmd = conn.CreateCommand("delete from DocumentProducts where DocumentId=@DocumentId");

            cmd.AddInt("DocumentId", documentId);
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 2
0
 internal void Remove(Context context, bool updateParentType)
 {
     if (types != null)
     {
         foreach (GType type in types)
         {
             type.Remove(context, false);
         }
         types.Clear();
         types = null;
     }
     if (ranges != null)
     {
         foreach (GRange range in ranges)
         {
             range.Remove(context, false);
         }
         ranges.Clear();
         ranges = null;
     }
     if (context != null && id != 0)
     {
         GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisTypesWhereId");
         cmd.AddInt("Id", id);
         cmd.ExecuteNonQuery();
     }
     if (updateParentType)
     {
         ParentComposite.Remove(this);
     }
     else
     {
         lib.Unregister(this);
     }
 }
Esempio n. 3
0
 private void Remove()
 {
     try
     {
         DataRow selRow = SelectedRow;
         if (selRow != null)
         {
             object obj = selRow[0];
             if (obj is int)
             {
                 int id = (int)obj;
                 using (GmConnection conn = App.CreateConnection())
                 {
                     GmCommand cmd = conn.CreateCommand("delete from Prescriptions where Id=@Id");
                     cmd.AddInt("Id", id);
                     cmd.ExecuteNonQuery();
                 }
             }
             dataTable.Rows.Remove(selRow);
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Esempio n. 4
0
 public void Save(Context context)
 {
     if (context.ExportMode || updateAttr[Constants.updateAttrCreated])
     {
         GmCommand cmd = context.TargetConn.CreateCommandById("insertIntoGisRanges");
         cmd.AddInt("Id", id);
         cmd.AddInt("TypeId", type.Id);
         context.Buf.SetRect(cmd.AddBinary("Code"), bounds);
         cmd.ExecuteNonQuery();
         if (!context.ExportMode)
         {
             updateAttr = 0;
         }
     }
     if (context.Filter == null)
     {
         return;
     }
     if (!context.Filter.Includes(BatchLevel.Object))
     {
         return;
     }
     if (objects != null)
     {
         foreach (GObject obj in objects)
         {
             obj.Save(context);
         }
     }
 }
Esempio n. 5
0
 internal void Remove(Context context, bool updateType)
 {
     if (context != null && objects == null)
     {
         Load(context);
     }
     foreach (GObject obj in objects)
     {
         obj.Remove(context, false);
     }
     if (context != null && id != 0)
     {
         GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisRangesWhereId");
         cmd.AddInt("Id", id);
         cmd.ExecuteNonQuery();
     }
     if (updateType)
     {
         type.Remove(this);
     }
     else
     {
         Lib.Unregister(this);
     }
     Unload();
 }
 internal void Save(GmConnection conn, int id)
 {
     this.id = id;
     if (id != 0)
     {
         foreach (DataRow dr in dt.Rows)
         {
             if (dr.RowState == DataRowState.Modified)
             {
                 int       groupId   = (int)dr[dcId];
                 bool      isChecked = (bool)dr[dcChecked];
                 GmCommand cmd       = conn.CreateCommand();
                 if (isChecked)
                 {
                     cmd.CommandText = string.Format("insert into {0} values(@{1},@MedicamentGroupId)", tableName, fieldName);
                 }
                 else
                 {
                     cmd.CommandText = string.Format("delete from {0} where {1}=@{1} and MedicamentGroupId=@MedicamentGroupId", tableName, fieldName);
                 }
                 cmd.AddInt(fieldName, id);
                 cmd.AddInt("MedicamentGroupId", groupId);
                 cmd.ExecuteNonQuery();
             }
         }
         dt.AcceptChanges();
     }
 }
Esempio n. 7
0
 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 static int Remove(GmConnection conn, int id)
        {
            GmCommand cmd = conn.CreateCommand("delete from PatientIdentifications where Id=@Id");

            cmd.AddInt("Id", id);
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 9
0
    public static int Remove(GmConnection conn, int id)
    {
        GmCommand cmd = conn.CreateCommand("delete from LinkExchange where Id=@Id");        //!!!

        cmd.AddInt("Id", id);
        return(cmd.ExecuteNonQuery());
    }
Esempio n. 10
0
        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 static StoreProduct GetStoreProduct(GmConnection conn, int id)
 *              {
 *                      if (id == 0) return null;
 *                      GmCommand cmd = conn.CreateCommand("select * from StoreProducts where Id=@Id");
 *                      cmd.AddInt("Id", id);
 *                      using (DbDataReader dr = cmd.ExecuteReader())
 *                      {
 *                              if (dr.Read()) return new StoreProduct(dr);
 *                      }
 *                      return null;
 *              }*/
        public static int Remove(GmConnection conn, int id, DbTransaction trans)
        {
            GmCommand cmd = conn.CreateCommand("delete from StoreProducts where Id=@Id", trans);

            cmd.AddInt("Id", id);
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 12
0
    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.AddString("Name", name, MaxLength.BannerTopics.Name);
        cmd.AddInt("B1", b1);
        cmd.AddInt("B2", b2);
        cmd.AddInt("B3", b3);
        cmd.AddInt("B4", b4);
        cmd.AddInt("B5", b5);
        cmd.AddInt("B6", b6);
        cmd.AddInt("B7", b7);
        cmd.AddInt("B8", b8);
        cmd.AddInt("B9", b9);
        if (id == 0)
        {
            cmd.CommandText = "insert into BannerTopics values (@Name,@B1,@B2,@B3,@B4,@B5,@B6,@B7,@B8,@B9) select @@Identity";
            id = (int)(decimal)cmd.ExecuteScalar();
        }
        else
        {
            cmd.CommandText = "update BannerTopics set Name=@Name,B1=@B1,B2=@B2,B3=@B3,B4=@B4,B5=@B5,B6=@B6,B7=@B7,B8=@B8,B9=@B9 where Id=@Id";
            cmd.ExecuteNonQuery();
        }
    }
Esempio n. 14
0
        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();
            }
        }
Esempio n. 15
0
        public void Remove(Context context)
        {
            GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisLayersWhereId");

            cmd.AddInt("Id", id);
            cmd.ExecuteNonQuery();
        }
Esempio n. 16
0
    public static void Vote(GmConnection conn, int pollAnswerId)
    {
        GmCommand cmd = conn.CreateCommand("update PollAnswers set Count=Count+1 where Id=@Id");

        cmd.AddInt("Id", pollAnswerId);
        cmd.ExecuteNonQuery();
    }
Esempio n. 17
0
    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();
        }
    }
Esempio n. 18
0
        public static int SetStatus(GmConnection conn, int id, Status status)
        {
            GmCommand cmd = conn.CreateCommand("update Patients set Status=@Status where Id=@Id");

            cmd.AddInt("Id", id);
            cmd.AddInt("Status", (int)status);
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 19
0
        public void UpdateState(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand("update Document set DocumentStateId=@DocumentStateId where DocumentId=@DocumentId");

            cmd.AddInt("DocumentId", DocumentId);
            cmd.AddInt("DocumentStateId", DocumentStateId);
            cmd.ExecuteNonQuery();
        }
Esempio n. 20
0
        public void Remove(Context context)
        {
            if (id < 0)
            {
                return;
            }
            GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisBgWhereId");

            cmd.AddInt("Id", id);
            cmd.ExecuteNonQuery();
        }
Esempio n. 21
0
        public void UpdateTerminalId()
        {
            using (GmConnection conn = App.ConnectionFactory.CreateConnection())
            {
                GmCommand cmd = conn.CreateCommand("update [User] set TerminalId=@TerminalId where UserCode=@UserId");

                cmd.AddInt("TerminalId", TerminalId);
                cmd.AddInt("UserId", UserId);
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 22
0
        public void Remove(Context context)
        {
            if (this.IsOverall)
            {
                return;
            }
            GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisViewsWhereId");

            cmd.AddInt("Id", id);
            cmd.ExecuteNonQuery();
        }
Esempio n. 23
0
    public void UpdateResume(GmConnection conn)
    {
        GmCommand cmd = conn.CreateCommand();

        cmd.AddInt("Id", id);
        cmd.AddString("Resume", resume);
        if (id != 0)
        {
            cmd.CommandText = "update Candidates set Resume=@Resume where Id=@Id";
            cmd.ExecuteNonQuery();
        }
    }
Esempio n. 24
0
        public void SaveEndTime(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand();

            cmd.AddInt("Id", id);
            cmd.AddNullableDateTime("EndTime", endTime);

            if (id != 0)
            {
                cmd.CommandText = "update Watching set EndTime=@EndTime where Id=@Id";
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 25
0
 internal void Remove(Context context, bool updateRange)
 {
     if (context != null)
     {
         GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisObjectsWhereId");
         cmd.AddInt("Id", id);
         cmd.ExecuteNonQuery();
     }
     if (updateRange)
     {
         range.Remove(this);
         Lib.SetChanged();
     }
 }
Esempio n. 26
0
        private void BackupDb(string filePath)
        {
            string dbName = App.AppConfig.GetDbName();

            if (dbName.Length == 0)
            {
                throw new HospitalDepartmentException("Не найдено имя базы данных.");
            }
            using (GmConnection conn = App.CreateConnection())
            {
                string    cmdText = string.Format("BACKUP DATABASE {0} TO DISK='{1}'", dbName, filePath);
                GmCommand cmd     = conn.CreateCommand(cmdText);
                cmd.ExecuteNonQuery();
                //                            SqlServerBackup bk=new SqlServerBackup(conn.DbConnection as SqlConnection);
                //							bk.BackupDatabase(dbName, dlgBackup.FileName);
            }
        }
        public void Save(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand();

            cmd.AddInt("Id", id);
            cmd.AddString("Name", name);
            cmd.AddInt("Status", (int)status);
            if (id == 0)
            {
                cmd.CommandText = "insert into Medicaments values (@Name,@Status) select @@Identity";
                id = (int)(decimal)cmd.ExecuteScalar();
            }
            else
            {
                cmd.CommandText = "update Medicaments set Name=@Name,Status=@Status where Id=@Id";
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 28
0
        public void Save(GmConnection conn)
        {
            GmCommand cmd = conn.CreateCommand();

            cmd.AddInt("Id", id);
            cmd.AddString("Name", name);
            cmd.AddString("ShortName", shortName);
            if (id == 0)
            {
                cmd.CommandText = "insert into PrescriptionTypes values (@Name,@ShortName) select @@Identity";
                id = (int)(decimal)cmd.ExecuteScalar();
            }
            else
            {
                cmd.CommandText = "update PrescriptionTypes set Name=@Name,ShortName=@ShortName where Id=@Id";
                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 29
0
    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();
        }
    }
Esempio n. 30
0
 public void Save(Context context)
 {
     if (this.IsOverall)
     {
         return;
     }
     if (context.ExportMode || updateAttr[Constants.updateAttrCreated])
     {
         GmCommand cmd = context.TargetConn.CreateCommandById("insertIntoGisViews");
         cmd.AddInt("Id", id);
         cmd.AddInt("Attr", attr);
         cmd.AddString("Name", name, MaxLength.Name);
         context.Buf.SetIntArray(cmd.AddBinary("Code"), GetIntArray());
         cmd.ExecuteNonQuery();
     }
     else if (updateAttr.NonEmpty)
     {
         GmCommand cmd     = context.Conn.CreateCommand();
         string    cmdText = "";
         if (updateAttr[(int)ViewField.Attr])
         {
             cmdText += "Attr= @Attr,";
             cmd.AddInt("Attr", attr);
         }
         if (updateAttr[(int)ViewField.Name])
         {
             cmdText += "Name= @Name,";
             cmd.AddString("Name", name, MaxLength.Name);
         }
         if (updateAttr[(int)ViewField.Code])
         {
             cmdText += "Code= @Code,";
             context.Buf.SetIntArray(cmd.AddBinary("Code"), this.GetIntArray());
         }
         Geomethod.StringUtils.RemoveLastChar(ref cmdText);
         cmd.CommandText = "update gisViews set " + cmdText + " where Id= @Id";
         cmd.AddInt("Id", id);
         cmd.ExecuteNonQuery();
     }
     if (!context.ExportMode)
     {
         updateAttr = 0;
     }
 }