public void Remove(Context context) { GmCommand cmd = context.Conn.CreateCommandById("deleteFromGisLayersWhereId"); cmd.AddInt("Id", id); cmd.ExecuteNonQuery(); }
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(); } }
void LoadData() { string cmdText = ""; if (doc.IsNew) { cmdText = "select top 0 * from DocumentProducts"; } else { cmdText = @" select DocumentProducts.*, StoreProducts.*, Products.Code, Products.Name from DocumentProducts left join StoreProducts on StoreProducts.Id=StoreProductId left join Products on Products.Id=ProductId where DocumentId=@DocumentId"; } using (GmConnection conn = App.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("DocumentId", doc.Id); cmd.Fill(dataTable); } if (gridView.Visible) { gridView.DataSource = dataTable; } }
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(); }
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(); } }
void LoadData() { string cmdText = @" select DocumentProducts.*, StoreProducts.*, Products.Code, Products.Name from DocumentProducts left join StoreProducts on StoreProducts.Id=StoreProductId left join Products on Products.Id=ProductId where DocumentId=@DocumentId"; using (GmConnection conn = App.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("DocumentId", doc.Id); cmd.Fill(dataTable); } gridView.DataSource = dataTable; chkCompleted.Checked = doc.completed; if (doc.completed) { Control[] controls = { btnAdd, btnRemove, btnOk, dpDate }; foreach (Control ctl in controls) { ctl.Enabled = false; } chkCompleted.Enabled = false; ucSelectProduct.Enabled = false; } }
public static string GetTreatment(GmConnection conn, int patientId) { /* string cmdText = @"select Medicaments.Name from Prescriptions * left join StoreProducts on StoreProducts.Id=StoreProductId * left join Products on Products.Id=ProductId * left join Medicaments on Medicaments.Id=MedicamentId * where PatientId=@PatientId";*/ string cmdText = @"select MedicamentGroups.Name from Prescriptions left join StoreProducts on StoreProducts.Id=StoreProductId left join Products on Products.Id=ProductId left join MedicamentGroupTies on MedicamentGroupTies.MedicamentId=Products.MedicamentId left join MedicamentGroups on MedicamentGroups.Id=MedicamentGroupId where PatientId=@PatientId"; GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("PatientId", patientId); List <string> list = new List <string>(); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { string s = dr.GetString(0); if (!list.Contains(s)) { list.Add(s); } } } list.Sort(); return(Geomethod.CollectionUtils.GetCommaSeparatedList <string>(list)); }
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 Load(Context context) { if (ranges != null) { throw new Exception("Ranges already loaded."); } GmCommand cmd = context.Conn.CreateCommandById("selectCountFromGisRangesWhereTypeId"); cmd.AddInt("TypeId", id); int count = (int)cmd.ExecuteScalar(); ranges = new List <GRange>(count); if (count > 0) { cmd = context.Conn.CreateCommandById("selectAllFromGisRangesWhereTypeId"); cmd.AddInt("TypeId", id); using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { GRange range = new GRange(context, this, dr); } } } }
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); } }
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()); }
protected void Page_Load(object sender, EventArgs e) { log = MainMasterPage.InitPage(this); int forumTopicId = RequestUtils.GetForumTopicId(this); this.SqlDataSource1.SelectParameters["ForumTopicId"].DefaultValue = forumTopicId.ToString(); try { string cmdText = "SELECT Forums.Id AS ForumId, Forums.Name AS ForumName, ForumTopics.Name AS ForumTopicName FROM Forums INNER JOIN ForumTopics ON Forums.Id = ForumTopics.ForumId WHERE (ForumTopics.Id = @ForumTopicId)"; using (GmConnection conn = Global.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("ForumTopicId", forumTopicId); using (GmDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { forumId = dr.GetInt(); forumName = dr.GetString(); forumTopicName = dr.GetString(); } else { return; } } } } catch (Exception ex) { log.Exception(ex); } }
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); } }
public static ReportsDataSet.AnalysisResultDataTable GetAnalysisResultTable(ConnectionFactory factory, Config config, int patientId, int analysisId) { DataTable dataTable = new DataTable(); string cmdText = @" select Code, AnalysisTypes.Name as AnalysisTypeName, ExecutionDate, AnalysisData, HandbookGroupId from Analyses left join AnalysisTypes on AnalysisTypes.Id=AnalysisTypeId where ExecutionDate is not null and "; cmdText += analysisId == 0 ? "PatientId=@PatientId order by ExecutionDate" : "AnalysisId=@AnalysisId"; using (GmConnection conn = factory.CreateConnection()) { GmCommand cmd = new GmCommand(conn, cmdText); cmd.AddInt("PatientId", patientId); cmd.AddInt("AnalysisId", analysisId); cmd.Fill(dataTable); } ReportsDataSet.AnalysisResultDataTable dtAnalysisResult = new ReportsDataSet.AnalysisResultDataTable(); foreach (DataRow dr in dataTable.Rows) { AnalysisData ad = AnalysisData.DeserializeString(dr["AnalysisData"] as string); ReportsDataSet.AnalysisResultRow row = dtAnalysisResult.NewAnalysisResultRow(); row.AnalysisCode = (string)dr["Code"]; row.AnalysisName = (string)dr["AnalysisTypeName"]; row.ExecutionDate = ((DateTime)dr["ExecutionDate"]).ToString("dd.MM.yy"); HandbookGroup hg = config.GetHandbookGroup((string)dr["HandbookGroupId"]); row.Result = ad.GetText(hg); dtAnalysisResult.AddAnalysisResultRow(row); } return(dtAnalysisResult); }
public static ReportsDataSet.AnalysisRequestDataTable GetAnalysisRequestTable(ConnectionFactory factory, Config config, int patientId, int analysisId) { DataTable dataTable = new DataTable(); string cmdText = @" select Code, AnalysisTypes.Name as AnalysisTypeName, RequestDate from Analyses left join AnalysisTypes on AnalysisTypes.Id=AnalysisTypeId where "; cmdText += analysisId == 0 ? "PatientId=@PatientId order by RequestDate" : "AnalysisId=@AnalysisId"; using (GmConnection conn = factory.CreateConnection()) { GmCommand cmd = new GmCommand(conn, cmdText); cmd.AddInt("PatientId", patientId); cmd.AddInt("AnalysisId", analysisId); cmd.Fill(dataTable); } ReportsDataSet.AnalysisRequestDataTable dtAnalysisRequest = new ReportsDataSet.AnalysisRequestDataTable(); foreach (DataRow dr in dataTable.Rows) { ReportsDataSet.AnalysisRequestRow row = dtAnalysisRequest.NewAnalysisRequestRow(); row.AnalysisCode = (string)dr["Code"]; row.AnalysisName = (string)dr["AnalysisTypeName"]; row.RequestDate = ((DateTime)dr["RequestDate"]).ToString("dd.MM.yy"); dtAnalysisRequest.AddAnalysisRequestRow(row); } return(dtAnalysisRequest); }
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(); } }
public string GetAnalysesList(GmConnection conn) { StringBuilder sb = new StringBuilder(); GmCommand cmd = conn.CreateCommand( @"select RequestDate, Name from Analyses left join AnalysisTypes on AnalysisTypes.Id=AnalysisTypeId where PatientId=@Id"); cmd.AddInt("Id", id); using (DbDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { int i = 0; DateTime dt = dr.GetDateTime(i++); string name = dr.GetString(i++); if (sb.Length > 0) { sb.Append("; "); } sb.AppendFormat("{0:dd.MM} {1}", dt, name); } } if (sb.Length > 0) { sb.Append("."); } return(sb.ToString()); }
void LoadData() { using (GmConnection conn = App.ConnectionFactory.CreateConnection()) { GmCommand cmd = conn.CreateCommand("select ProductCode, Name as ProductName, ParentProductCode from Product where DeletedFlag=0 and GroupFlag=1"); using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { Product p = new Product(dr); htProducts.Add(p.Code, p); } } } foreach (Product p in htProducts.Values) { if (p.ParentCode != null) { Product parent = htProducts[p.ParentCode] as Product; p.SetParent(parent); } else { rootProducts.Add(p); } } treeView.BeginUpdate(); BuildTree(treeView.Nodes, rootProducts); treeView.EndUpdate(); UpdateControls(); UpdateStatus(); }
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()); }
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); } } }
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 static DbDataAdapter CreateDataAdapter(GmConnection conn, Document doc) { DbDataAdapter da = conn.CreateDataAdapter(); GmCommand cmd = conn.CreateCommand(selectCmdText); cmd.AddInt("DocumentId", doc.DocumentId); cmd.AddBool("FactFlag", false); (da as IDbDataAdapter).SelectCommand = cmd.DbCommand; cmd = conn.CreateCommand(insertCmdText); cmd.AddString("ProductCode").SourceColumn = "ProductCode"; cmd.AddString("UnitCode").SourceColumn = "UnitCode"; cmd.AddInt("DocumentId", doc.DocumentId); cmd.AddDecimal("Coef").SourceColumn = "Coef"; cmd.AddDecimal("Count").SourceColumn = "Count"; cmd.AddBool("FactFlag", true); cmd.AddBool("HandledFlag").SourceColumn = "HandledFlag"; cmd.DbCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; (da as IDbDataAdapter).InsertCommand = cmd.DbCommand; cmd = conn.CreateCommand(deleteCmdText); cmd.AddInt("DocumentProductId").SourceColumn = "DocumentProductId"; (da as IDbDataAdapter).DeleteCommand = cmd.DbCommand; cmd = conn.CreateCommand(updateCmdText); cmd.AddInt("DocumentProductId").SourceColumn = "DocumentProductId"; cmd.AddDecimal("Count").SourceColumn = "Count"; cmd.AddBool("HandledFlag").SourceColumn = "HandledFlag"; (da as IDbDataAdapter).UpdateCommand = cmd.DbCommand; return(da); }
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 bool IsMultyLoginDenied() { bool denied = false; if (UserId != 0) { using (GmConnection conn = App.ConnectionFactory.CreateConnection()) { GmCommand cmd = conn.CreateCommand("select MultiLoginFlag, lastupdate, GETDATE() from [User] where UserCode=@UserCode"); cmd.AddInt("UserCode", UserId); using (IDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { int i = 0; bool multiLoginFlag = dr.GetBoolean(i++); if (multiLoginFlag) { DateTime lastUpdate = dr.GetDateTime(i++); DateTime curTime = dr.GetDateTime(i++); TimeSpan ts = curTime - lastUpdate; denied = ts.TotalMilliseconds < this.config.PollTime * 2; //+config.CommandTimeout*1000 } } } } } return(denied); }
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()); }
private void InitPager(int parentId, int topNumber, bool enablePager) { ucPager.top = "@TopNumber"; ucPager.fields = "Id, Date, Title, Preview, Header, Link, IsGroup"; ucPager.table = "Articles"; ucPager.cond = "(ParentId = @ParentId) and Articles.Status>=0"; ucPager.order = "Date desc"; if (enablePager) { int count = 0; string cmdText = ucPager.GetCountQuery(); using (GmConnection conn = Global.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("ParentId", parentId); cmd.AddInt("TopNumber", topNumber); count = (int)conn.ExecuteScalar(cmd); } ucPager.GenerateControls(count); this.SqlDataSource1.SelectCommand = ucPager.GetPageQuery(); } else { ucPager.Visible = false; this.SqlDataSource1.SelectCommand = ucPager.GetSelectQuery(); } }
public static ReportsDataSet.PatientMedicamentsDataTable GetPatientMedicamentsTable(ConnectionFactory factory, int patientId) { ReportsDataSet.PatientMedicamentsDataTable dtPatientMedicaments = new ReportsDataSet.PatientMedicamentsDataTable(); string cmdText = @" SELECT StoreProducts.Id, Products.Name, Products.PackedNumber, Products.Maker, Prescriptions.Dose * Prescriptions.Multiplicity * Prescriptions.Duration AS Count, StoreProducts.Price, Prescriptions.Dose * Prescriptions.Multiplicity * Prescriptions.Duration * StoreProducts.Price AS Sum, Series, MedLists FROM Prescriptions LEFT OUTER JOIN StoreProducts ON StoreProducts.Id = Prescriptions.StoreProductId LEFT OUTER JOIN Products ON Products.Id = StoreProducts.ProductId WHERE Prescriptions.PatientId = @PatientId"; using (GmConnection conn = factory.CreateConnection()) { GmCommand cmd = conn.CreateCommand(cmdText); cmd.AddInt("PatientId", patientId); conn.Fill(dtPatientMedicaments, cmd); } int index = 0; foreach (ReportsDataSet.PatientMedicamentsRow row in dtPatientMedicaments.Rows) { row.Id = ++index; } return(dtPatientMedicaments); }
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(); } }
void LoadLib(Context context) { int[] indexerCode; GmCommand cmd = context.Conn.CreateCommandById("selectAllFromGisLibWhereId"); cmd.AddInt("Id", Constants.currentLib); using (IDataReader dr = cmd.ExecuteReader()) { if (!dr.Read()) { throw new GeoLibException("Lib record not found."); } attr = dr.GetInt32((int)LibField.Attr); name = dr.GetString((int)LibField.Name); // DZ 16.01.09 // context.SetStyle(dr.GetString((int)LibField.Style),ref styleStr,ref style); context.SetStyle(dr.IsDBNull((int)LibField.Style) ? "" : dr.GetString((int)LibField.Style), ref styleStr, ref style); // context.SetStyle(dr.GetString((int)LibField.DefaultStyle),ref defaultStyleStr,ref defaultStyle.style); context.SetStyle(dr.IsDBNull((int)LibField.DefaultStyle) ? "" : dr.GetString((int)LibField.DefaultStyle), ref defaultStyleStr, ref defaultStyle); smin = dr.GetInt32((int)LibField.SMin); smax = dr.GetInt32((int)LibField.SMax); bounds = context.Buf.GetRect(dr, (int)LibField.Code); indexerCode = context.Buf.GetIntArray(dr, (int)LibField.IndexerCode); scales.Values = context.Buf.GetIntArray(dr, (int)LibField.Scales); } if (scales.Count == 0) { scales.InitScales(); } id = Constants.currentLib; indexer = new Indexer(indexerCode); }
/* 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()); }
private void Register(GmCommandHandler handler) { GmAttribute[] attribute = handler.Method.GetCustomAttributes(typeof(GmAttribute), true) as GmAttribute[]; if (attribute != null && attribute.Length > 0) { GmCommand command = new GmCommand(); command.attribute = attribute[0]; command.handler = handler; string name = attribute[0].Name.ToUpperInvariant(); CommandList.Add(name, command); } else { throw new SystemException("Cannot register command: no information found"); } }