public bool IsExists(int customerSysNo) { DataCommand cmd = DataCommandManager.GetDataCommand("CustomerIsExists"); cmd.SetParameterValue("@CustomerSysNo", customerSysNo); if (cmd.ExecuteScalar() == null) { return(false); } else { return((int)cmd.ExecuteScalar() > 0); } }
public static int CreateNewRefundSysNo() { DataCommand command = DataCommandManager.GetDataCommand("CreateNewRMARefundSysNo"); object result = command.ExecuteScalar(); return(Convert.ToInt32(result)); }
public decimal GetSOIncomeAmt(int sosysNo) { DataCommand command = DataCommandManager.GetDataCommand("GetSOIncomeAmt"); command.SetParameterValue("@SOSysNo", sosysNo); return(command.ExecuteScalar <decimal>()); }
public int GetProductsCount() { using (DataCommand cmd = DataCommandManager.GetDataCommand("GetProductsCount")) { return(Convert.ToInt32(cmd.ExecuteScalar())); } }
/// <summary> /// 检查是否存在相同的阻止词 /// </summary> /// <param name="item"></param> /// <returns></returns> public bool CheckStopWords(StopWordsInfo item) { DataCommand cmd = DataCommandManager.GetDataCommand("StopWord_CheckStopword"); cmd.SetParameterValue <StopWordsInfo>(item); return(cmd.ExecuteScalar() != null); }
public static string GetMaxBarcode(string barPrefix) { DataCommand command = DataCommandManager.GetDataCommand("Item_GetGiftCardPool_MaxBarcode"); command.SetParameterValue("Barcode", barPrefix); return(command.ExecuteScalar <string>()); }
/// <summary> /// 取商品图片数 /// </summary> /// <param name="productCommonInfoSysNo"></param> /// <returns></returns> public static int GetCommonInfoPicNumber(int productCommonInfoSysNo) { DataCommand cmd = DataCommandManager.GetDataCommand("GetCommonInfoPicNumber"); cmd.SetParameterValue("@ProductCommonInfoSysNo", productCommonInfoSysNo); return(cmd.ExecuteScalar <int>()); }
/// <summary> /// 查询用户是否存在关联角色 /// </summary> public static bool HasExistUserRoleAssociation(int roleId) { var cmd = new DataCommand("RoleUser.HasExistUserRoleAssociation"); cmd.SetParameter("@RoleId", DbType.Int32, roleId);; return(cmd.ExecuteScalar <int?>().HasValue); }
public bool ContainUser(int uerGroupId) { var cmd = new DataCommand("ContainUser", new SqlCustomDbCommand()); cmd.SetParameterValue("@UserGroupId", uerGroupId); return(int.Parse(cmd.ExecuteScalar().ToString()) == 0 ? false : true); }
public int GetStoreCount(string name, int status) { StringBuilder builder = new StringBuilder(); builder.Append(StoreStatement.GetStoreCount); if (!string.IsNullOrEmpty(name)) { builder.Append(" AND SupplierName LIKE '%'+@key+'%'"); } if (status > -1) { builder.Append(" AND Status=@Status"); } DataCommand command = new DataCommand(ConnectionString, GetDbCommand(builder.ToString(), "Text")); if (!string.IsNullOrEmpty(name)) { command.AddInputParameter("@key", DbType.String, name); } if (status > -1) { command.AddInputParameter("@Status", DbType.Int32, status); } var o = command.ExecuteScalar <object>(); return(Convert.ToInt32(o)); }
/// <summary> /// 获取告警类型 /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public int GetAlarmIndexCount(QueryAlarmNew alarmNew) { int intPazeSize = alarmNew.PageSize; int intNext = intPazeSize * (alarmNew.PageIndex - 1); DataTable dtAlarmType = new DataTable(); string strSql = @" SELECT count(id) from AlarmAreaDevice where 1=1"; string whereStr = ""; whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'"; if (alarmNew.AlarmStatus != "") { whereStr += " and STATUS = " + alarmNew.AlarmStatus; } if (!whereStr.Equals(string.Empty)) { strSql = strSql + whereStr; } // Object obj = SqlHelper.GetSingle(strSql); var cmd = new DataCommand("GetBaseDataItem", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#SQLSTR#", strSql); return(int.Parse(cmd.ExecuteScalar().ToString())); }
public void Init() { _dataCommand = new DataCommand(); if (!_dataCommand.DbExists()) { try { _dataCommand.CreateDbFile(); _dataCommand.ExecuteAsNonQuery(@"CREATE TABLE 'TimeRecords' ( 'Id' VARCHAR(20) PRIMARY KEY NOT NULL UNIQUE , 'CreatedAt' INTEGER NOT NULL, 'CreatedAtDate' INTEGER NOT NULL, 'TotalMinutes' DOUBLE NOT NULL, 'IsSynced' INT )"); var result = _dataCommand.ExecuteScalar<long>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='TimeRecords';"); } catch (Exception e) { MessageBox.Show("Error: " + e); } } }
public long CreateNew(InventoryDetailInfo InventoryDetail) { DataCommand command = new DataCommand(ConnectionString, GetDbCommand(InventoryDetailStatement.CreateNewInventoryDetail, "Text")); command.AddInputParameter("@InventoryID", DbType.Int32, InventoryDetail.InventoryID); command.AddInputParameter("@GoodsID", DbType.Int32, InventoryDetail.GoodsID); command.AddInputParameter("@StorageID", DbType.Int32, InventoryDetail.StorageID); command.AddInputParameter("@Quantity", DbType.Int32, InventoryDetail.Quantity); command.AddInputParameter("@CustomerID", DbType.Int32, InventoryDetail.CustomerID); command.AddInputParameter("@InventoryType", DbType.String, InventoryDetail.InventoryType); command.AddInputParameter("@BatchNumber", DbType.String, InventoryDetail.BatchNumber); command.AddInputParameter("@ProductDate", DbType.DateTime, InventoryDetail.ProductDate); command.AddInputParameter("@InventoryDate", DbType.DateTime, InventoryDetail.InventoryDate); command.AddInputParameter("@UnitPrice", DbType.Decimal, InventoryDetail.UnitPrice); command.AddInputParameter("@Remark", DbType.String, InventoryDetail.Remark); command.AddInputParameter("@OrderType", DbType.String, InventoryDetail.OrderType); command.AddInputParameter("@OrderNo", DbType.String, InventoryDetail.OrderNo); command.AddInputParameter("@OrderID", DbType.Int64, InventoryDetail.OrderID); command.AddInputParameter("@OperatorID", DbType.String, InventoryDetail.OperatorID); command.AddInputParameter("@CreateDate", DbType.DateTime, InventoryDetail.CreateDate); command.AddInputParameter("@ChangeDate", DbType.DateTime, InventoryDetail.ChangeDate); var o = command.ExecuteScalar <object>(); return(Convert.ToInt64(o)); }
public int InsertOPCOfflineMessage(OPCOfflineMessageInfo info) { DataCommand command = DataCommandManager.GetDataCommand("SO_Insert_OPCOfflineMessage"); command.SetParameterValue(info); return(command.ExecuteScalar <int>()); }
private void InnerCreateInvoiceMaster(InvoiceMasterInfo invoiceMaster, out int invoiceSysNo) { DataCommand dataCommand = DataCommandManager.GetDataCommand("InsertInvoiceMaster"); dataCommand.SetParameterValue <InvoiceMasterInfo>(invoiceMaster); invoiceSysNo = Convert.ToInt32(dataCommand.ExecuteScalar()); }
public bool IsExistCommissionTypeName(string commissionTypeName) { DataCommand cmd = DataCommandManager.GetDataCommand("IsExistCommissionTypeName"); cmd.SetParameterValue("@CommissionTypeName", commissionTypeName); return(cmd.ExecuteScalar().ToInteger() == 0 ? false : true); }
public static int GetProductInventroyType(int productSysNo) { DataCommand cmd = DataCommandManager.GetDataCommand("Inventory_GetProductInventroyType"); cmd.SetParameterValue("@ProductSysNo", productSysNo); return(cmd.ExecuteScalar <int>()); }
public static bool IsExistSuspectInfo(SOEntity4FPEntity entity, string CompanyCode) { DataCommand command = DataCommandManager.GetDataCommand("IsExistSuspectInfo"); int searchType = 0; if (string.IsNullOrEmpty(entity.BrowseInfo) && string.IsNullOrEmpty(entity.IPAddress)) { searchType = 1; } command.SetParameterValue("@CustomerSysNo", entity.CustomerSysNo); command.SetParameterValue("@EmailAddress", entity.EmailAddress); command.SetParameterValue("@BrowseInfo", entity.BrowseInfo); command.SetParameterValue("@IPAddress", entity.IPAddress); command.SetParameterValue("@MobilePhone", entity.MobilePhone); command.SetParameterValue("@ShippingAddress", entity.ShippingAddress); command.SetParameterValue("@ShippingContact", entity.ShippingContact); command.SetParameterValue("@Telephone", entity.Telephone); command.SetParameterValue("@SearchType", searchType); command.SetParameterValue("@CompanyCode", CompanyCode); object o = command.ExecuteScalar(); if (o != null) { return(true); } return(false); }
/// <summary> /// 获取商品库存成本 /// </summary> /// <param name="productSysNo"></param> /// <returns></returns> public static decimal GetItemCost(int productSysNo) { DataCommand cmd = DataCommandManager.GetDataCommand("Inventory_GetItemCost"); cmd.SetParameterValue("@ProductSysNo", productSysNo); return(cmd.ExecuteScalar <decimal>()); }
public bool IsCategoryInUsing(int categorySysNo) { DataCommand cmd = DataCommandManager.GetDataCommand("IsCategoryInUsing"); cmd.SetParameterValue("@CategorySysNo", categorySysNo); return(cmd.ExecuteScalar <int>() > 0); }
public static FreeShippingChargeRuleInfo CreateMasterInfo(FreeShippingChargeRuleInfo entity) { DataCommand command = DataCommandManager.GetDataCommand("InsertFreeShippingChargeRule"); command.SetParameterValue("@StartDate", entity.StartDate); command.SetParameterValue("@EndDate", entity.EndDate); command.SetParameterValue("@Status", entity.Status); command.SetParameterValue("@AmountSettingType", entity.AmountSettingType); command.SetParameterValue("@AmountSettingValue", entity.AmountSettingValue); command.SetParameterValue("@IsGlobal", entity.IsGlobal); command.SetParameterValue("@Description", entity.Description); command.SetParameterValue("@InUser", entity.InUserSysNo); command.SetParameterValue("@SellerSysNo", entity.SellerSysNo); string payTypeSettingValue = string.Empty; if (entity.PayTypeSettingValue != null) { payTypeSettingValue = ECommerce.DataAccess.Utility.StringUtility.Join(entity.PayTypeSettingValue, ","); } command.SetParameterValue("@PayTypeSettingValue", payTypeSettingValue); string shipAreaSettingValue = string.Empty; if (entity.ShipAreaSettingValue != null) { shipAreaSettingValue = ECommerce.DataAccess.Utility.StringUtility.Join(entity.ShipAreaSettingValue, ","); } command.SetParameterValue("@ShipAreaSettingValue", shipAreaSettingValue); entity.SysNo = Convert.ToInt32(command.ExecuteScalar()); return(entity); }
/// <summary> /// 检查是否存在相同的同义词 /// </summary> /// <param name="item"></param> /// <returns></returns> public bool CheckThesaurusWordsForInsert(ThesaurusInfo item) { DataCommand cmd = DataCommandManager.GetDataCommand("ThesaurusKeywords_CheckThesaurusWordsForInsert"); cmd.SetParameterValue <ThesaurusInfo>(item); return(cmd.ExecuteScalar() != null); }
/// <summary> /// 获取公司的用户SysNo /// </summary> /// <param name="companySysNo"></param> /// <returns></returns> public static string GetCompanyUserNoStr(int companySysNo) { DataCommand cmd = new DataCommand("GetCompanyUserNoStr"); cmd.SetParameter("@CompanySysNo", DbType.Int32, companySysNo); return(cmd.ExecuteScalar <string>()); }
public int Insert(RefundPointInfo info) { DataCommand command = DataCommandManager.GetDataCommand("InsertNetPayExtension"); command.SetParameterValue("@OrderType", info.OrderType); command.SetParameterValue("@OrderSysNo", info.OrderSysNo); command.SetParameterValue("@SOSysNo", info.SOSysNo); command.SetParameterValue("@OrderAmt", info.OrderAmt); command.SetParameterValue("@PayAmt", info.PayAmt); command.SetParameterValue("@InUser", info.InUser); command.SetParameterValue("@EditUser", info.EditUser); command.SetParameterValue("@PayTypeSysNo", info.PayTypeSysNo); command.SetParameterValue("@ReferenceID", info.ReferenceID); command.SetParameterValue("@ExternalKey", info.ExternalKey); command.SetParameterValue("@Note", info.Note); command.SetParameterValue("@Status", info.RefundStatus); command.SetParameterValue("@ResponseContent", info.ResponseContent); command.SetParameterValue("@CompanyCode", info.CompanyCode); command.SetParameterValue("@LanguageCode", "zh-CN"); command.SetParameterValue("@CurrencySysNo", info.CurrencySysNo); command.SetParameterValue("@StoreCompanyCode", "8601"); command.SetParameterValue("@RefundLogSysNo", info.RefundLogSysNo); return(Convert.ToInt32(command.ExecuteScalar())); }
public CollectionPaymentItem CreateSettleItem(CollectionPaymentItem entity) { DataCommand command = null; if (entity.AcquireReturnPointType.HasValue) { command = DataCommandManager.GetDataCommand("CreateCollVendorSettleItem"); command.SetParameterValue("@AcquireReturnPoint", entity.AcquireReturnPoint.Value); command.SetParameterValue("@AcquireReturnPointType", entity.AcquireReturnPointType.Value); } else { command = DataCommandManager.GetDataCommand("CreateCollVendorSettleItemNOAcquireRP"); } command.SetParameterValue("@SettleSysNo", entity.SettleSysNo); command.SetParameterValue("@POConsignToAccLogSysNo", entity.POConsignToAccLogSysNo); command.SetParameterValue("@Cost", entity.Cost); //command.SetParameterValue("@CurrencySysNo", entity.); command.SetParameterValue("@SettlePercentage", entity.SettlePercentage); command.SetParameterValue("@SettleType", entity.SettleType); command.SetParameterValue("@ConsignSettleRuleSysNO", entity.SettleRuleSysNo); CommonHelper.SetCommonParams(command); entity.ItemSysNo = System.Convert.ToInt32(command.ExecuteScalar()); return(entity); }
public int SaveGiftVoucherProductRelation(GiftVoucherProductRelation item) { DataCommand cmd = DataCommandManager.GetDataCommand("GiftCard_SaveGiftVoucherRelationInfo"); cmd.SetParameterValue <GiftVoucherProductRelation>(item); return(cmd.ExecuteScalar <int>()); }
public static int InsertConsignToAccLog(ConsignToAccLogEntity entity) { DataCommand command = DataCommandManager.GetDataCommand("InsertConsignToAccLog"); command.SetParameterValue("@CompanyCode", entity.CompanyCode); command.SetParameterValue("@ConsignToAccType", entity.ConsignToAccType); command.SetParameterValue("@CreateCost", entity.CreateCost); command.SetParameterValue("@CreateTime", entity.CreateTime); command.SetParameterValue("@CurrencySysNo", entity.CurrencySysNo); command.SetParameterValue("@FoldCost", entity.FoldCost); command.SetParameterValue("@IsConsign", entity.IsConsign); command.SetParameterValue("@LanguageCode", entity.LanguageCode); command.SetParameterValue("@Note", entity.Note); command.SetParameterValue("@OrderSysNo", entity.OrderSysNo); command.SetParameterValue("@Point", entity.Point); command.SetParameterValue("@ProductSysNo", entity.ProductSysNo); command.SetParameterValue("@Quantity", entity.Quantity); command.SetParameterValue("@RetailPrice", entity.RetailPrice); command.SetParameterValue("@SettleCost", entity.SettleCost); command.SetParameterValue("@SettlePercentage", entity.SettlePercentage); command.SetParameterValue("@SettleType", entity.SettleType); command.SetParameterValue("@Status", entity.Status); command.SetParameterValue("@StockSysNo", int.Parse(entity.StockSysNo)); command.SetParameterValue("@StoreCompanyCode", entity.StoreCompanyCode); command.SetParameterValue("@VendorSysNo", entity.VendorSysNo); return(Convert.ToInt32(command.ExecuteScalar())); }
public bool SOIsProcess(int soSysNo) { DataCommand command = DataCommandManager.GetDataCommand("SO_GetOPCMasterLast"); command.SetParameterValue("@SOSysNo", soSysNo); return(command.ExecuteScalar <int>() > 0); }
///// <summary> ///// 根据区域和项目代码获取是否含有数据 ///// </summary> ///// <param name="itemcode"></param> ///// <param name="areaid"></param> ///// <returns></returns> //public int GetCountItemCodeAreaId(string itemcode, string areaid) //{ // string strSql = @"select count(distinct s1.areaid) from Becm_Device s1 " // + " inner join ( select * from f_GetChildAreaId(" + areaid + " ) ) s2 on s1.areaid = s2.id " // + " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber where s1.itemcodeid = '" + itemcode + "'"; // return int.Parse(SqlHelper.ExecuteScalar(strSql.ToString()).ToString()); //} /// <summary> /// 根据区域和项目代码获取是否含有数据 /// </summary> /// <param name="itemcode"></param> /// <param name="areaid"></param> /// <returns></returns> public int GetCountItemCodeAreaId(string itemcode, string areaid, int classid) { string strSql = ""; if (classid == 1) { //strSql = @" select count(distinct s1.areaid) from Becm_Device s1 " // + "inner join ( select * from f_GetChildAreaId(" + areaid + ") ) s2 on s1.areaid = s2.id " // + " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber " // + " inner join ( select * from f_GetChildItemCode('" + itemcode + "') ) s4 on s1.itemcodeid=s4.code"; var cmd = new DataCommand("GetCountItemCodeAreaId1", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#Areaid#", areaid); cmd.ReplaceParameterValue("#ItemCode#", itemcode); return(int.Parse(cmd.ExecuteScalar().ToString())); } else { var cmd = new DataCommand("GetCountItemCodeAreaId2", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#Areaid#", areaid); cmd.ReplaceParameterValue("#ItemCode#", itemcode); return(int.Parse(cmd.ExecuteScalar().ToString())); // strSql = @" select count(distinct s1.areaid) from Becm_Device s1 " //+ "inner join ( select * from f_GetChildFuncAreaId(" + areaid + ") ) s2 on s1.areaid2 = s2.id " //+ " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber " //+ " inner join ( select * from f_GetChildItemCode('" + itemcode + "') ) s4 on s1.itemcodeid=s4.code"; } //return int.Parse(SqlHelper.ExecuteScalar(strSql.ToString()).ToString()); }
/// <summary> /// Looks up the next incremental primary key value to use for a new record. /// </summary> /// <returns></returns> private ReservedKey GetNextKey() { object dbResult; int nextid = 0; ReservedKey keyReservation; try { DataCommand.Connection = ConnHandler.RequestConnection(Alias, this); DataCommand.CommandText = "SELECT MAX(" + PrimaryKeys[0].Name + ") FROM " + TableName; dbResult = DataCommand.ExecuteScalar(); if (dbResult is int) { nextid = (int)dbResult; } nextid++; keyReservation = ReserveKey(new ReservedKey(TableName, nextid)); } catch (Exception err) { throw err; } finally { ConnHandler.ReleaseConnection(this, DataCommand.Connection); } return(keyReservation); }
/// <summary> /// 获取商家总商品数量 /// </summary> /// <param name="queryFilter"></param> /// <returns></returns> public static int GetTotalProductCount(DashboardQueryFilter queryFilter) { DataCommand command = DataCommandManager.GetDataCommand("Dashboard_GetTotalProductCount"); command.SetParameterValue(queryFilter); return(command.ExecuteScalar <int>()); }
public int GetMaxId() { try { var cmd = new DataCommand("GetMaxUserId", new SqlCustomDbCommand()); return int.Parse(cmd.ExecuteScalar().ToString()); } catch (Exception e) { return 0; } }
public int GetUserGroupID(string username) { try { var cmd = new DataCommand("GetUserGroupID", new SqlCustomDbCommand()); cmd.SetParameterValue("@cname", username); return int.Parse(cmd.ExecuteScalar().ToString()); } catch (Exception ee) { throw ee; } }
public bool HasMenuRight(string where) { try { var cmd = new DataCommand("HasMenuRight", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#whereStr#", where); return int.Parse(cmd.ExecuteScalar().ToString()) == 0 ? false : true; } catch (Exception) { return false; } }
public string GetUserGroupName(int userGroupId) { try { var cmd = new DataCommand("GetUserGroupName", new SqlCustomDbCommand()); cmd.SetParameterValue("@Id", userGroupId); return cmd.ExecuteScalar().ToString(); } catch (Exception) { return string.Empty; } }
public decimal GetFeePrice(string itemcode) { try { var cmd = new DataCommand("GetFeePrice", new SqlCustomDbCommand()); cmd.SetParameterValue("@itemcode", itemcode); object result = cmd.ExecuteScalar(); if (result != null) { return Convert.ToDecimal(result); } throw new Exception("该分项未设置费率"); } catch (Exception ee) { throw ee; } }
/// <summary> /// 获取告警数量 /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public int GetAlarmCount(string whereStr) { //DataTable dtAlarmType = new DataTable(); //string strSql = "select count(id) from TE_ALARM where 1=1 "; //if (!whereStr.Equals(string.Empty)) //{ // strSql = strSql + whereStr; //} //Object obj = SqlHelper.GetSingle(strSql); //int Count = 0; //if (obj != DBNull.Value) //{ // Count = int.Parse(obj.ToString()); //} //return Count; var cmd = new DataCommand("GetAlarmCount", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#whereStr#", whereStr); return int.Parse(cmd.ExecuteScalar().ToString()); }
/// <summary> /// 获取告警类型 /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public int GetAlarmIndexCount(QueryAlarmNew alarmNew) { int intPazeSize = alarmNew.PageSize; int intNext = intPazeSize * (alarmNew.PageIndex - 1); DataTable dtAlarmType = new DataTable(); string strSql = @" SELECT count(id) from AlarmAreaDevice where 1=1"; string whereStr = ""; whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'"; if (alarmNew.AlarmStatus != "") { whereStr += " and STATUS = " + alarmNew.AlarmStatus; } if (!whereStr.Equals(string.Empty)) { strSql = strSql + whereStr; } // Object obj = SqlHelper.GetSingle(strSql); var cmd = new DataCommand("GetBaseDataItem", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#SQLSTR#", strSql); return int.Parse(cmd.ExecuteScalar().ToString()); }
public bool ContainUser(int uerGroupId) { var cmd = new DataCommand("ContainUser", new SqlCustomDbCommand()); cmd.SetParameterValue("@UserGroupId", uerGroupId); return int.Parse(cmd.ExecuteScalar().ToString()) == 0 ? false : true; }
public bool IsContainUser(string userName) { var cmd = new DataCommand("IsContainUser", new SqlCustomDbCommand()); cmd.SetParameterValue("@Name", userName); return int.Parse(cmd.ExecuteScalar().ToString()) == 0 ? false : true; }
///// <summary> ///// 根据区域和项目代码获取是否含有数据 ///// </summary> ///// <param name="itemcode"></param> ///// <param name="areaid"></param> ///// <returns></returns> //public int GetCountItemCodeAreaId(string itemcode, string areaid) //{ // string strSql = @"select count(distinct s1.areaid) from Becm_Device s1 " // + " inner join ( select * from f_GetChildAreaId(" + areaid + " ) ) s2 on s1.areaid = s2.id " // + " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber where s1.itemcodeid = '" + itemcode + "'"; // return int.Parse(SqlHelper.ExecuteScalar(strSql.ToString()).ToString()); //} /// <summary> /// 根据区域和项目代码获取是否含有数据 /// </summary> /// <param name="itemcode"></param> /// <param name="areaid"></param> /// <returns></returns> public int GetCountItemCodeAreaId(string itemcode, string areaid, int classid) { string strSql = ""; if (classid == 1) { //strSql = @" select count(distinct s1.areaid) from Becm_Device s1 " // + "inner join ( select * from f_GetChildAreaId(" + areaid + ") ) s2 on s1.areaid = s2.id " // + " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber " // + " inner join ( select * from f_GetChildItemCode('" + itemcode + "') ) s4 on s1.itemcodeid=s4.code"; var cmd = new DataCommand("GetCountItemCodeAreaId1", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#Areaid#", areaid); cmd.ReplaceParameterValue("#ItemCode#", itemcode); return int.Parse(cmd.ExecuteScalar().ToString()); } else { var cmd = new DataCommand("GetCountItemCodeAreaId2", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#Areaid#", areaid); cmd.ReplaceParameterValue("#ItemCode#", itemcode); return int.Parse(cmd.ExecuteScalar().ToString()); // strSql = @" select count(distinct s1.areaid) from Becm_Device s1 " //+ "inner join ( select * from f_GetChildFuncAreaId(" + areaid + ") ) s2 on s1.areaid2 = s2.id " //+ " inner join Becm_ItemCode s3 on s1.itemcodeid = s3.itemcodenumber " //+ " inner join ( select * from f_GetChildItemCode('" + itemcode + "') ) s4 on s1.itemcodeid=s4.code"; } //return int.Parse(SqlHelper.ExecuteScalar(strSql.ToString()).ToString()); }
/// <summary> /// 获取告警类型 /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public int GetAlarmListCount(QueryAlarmNew alarmNew) { int intPazeSize = alarmNew.PageSize; int intNext = intPazeSize * (alarmNew.PageIndex - 1); DataTable dtAlarmType = new DataTable(); string whereStr = ""; whereStr += " and ALARMTIME between '" + alarmNew.StartTime.ToString("yyyy-MM-dd 00:00:00") + "' and '" + alarmNew.EndTime.ToString("yyyy-MM-dd 23:59:59") + "'"; if (alarmNew.AlarmLevel != "") { whereStr += " and ALARMLEVEL = " + alarmNew.AlarmLevel; } if (alarmNew.AlarmStatus != "") { whereStr += " and STATUS = " + alarmNew.AlarmStatus; } if (alarmNew.AlarmType != "") { whereStr += " and alarmtype = " + alarmNew.AlarmType; } IList<string> lstAreaId = GetAlarmListAreaId(alarmNew.ObjectId, alarmNew.ObjType); IList<string> lstDeviceId = GetAlarmListDeviceId(alarmNew.ObjectId, alarmNew.ObjType); whereStr += " and ("; if (lstAreaId.Count > 0) { string strAreaId = string.Join(",", lstAreaId.ToArray()); whereStr += " ALARMOBJID in (" + strAreaId + ") "; } else { whereStr += "1=2"; } whereStr += " or "; if (lstDeviceId.Count > 0) { string strDeviceId = string.Join(",", lstDeviceId.ToArray()); whereStr += " ALARMOBJID in (" + strDeviceId + ") "; } else { whereStr += "1=2"; } whereStr += ")"; var cmd = new DataCommand("GetAlarmListCount", new SqlCustomDbCommand()); cmd.ReplaceParameterValue("#whereStr#", whereStr); return int.Parse(cmd.ExecuteScalar().ToString()); }