Summary description for Connection
Example #1
1
 public bool FindUserEmailID(int userEmailID)
 {
     string sql = string.Format("SELECT * FROM UserEmails WHERE UserEmailID = '{0}' ", userEmailID);
     using(Connection cn = new Connection())
     {
         using (SqlCommand cmd = new SqlCommand())
         {
             try
             {
                 cmd.Connection = cn.SqlConnection;
                 cmd.CommandText = sql;
                 int recordsAffected = cmd.ExecuteNonQuery();
                 SqlDataReader reader = cmd.ExecuteReader();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         //UserID = (int)reader["UserID"];
                         //loginName = reader["LoginName"].ToString();
                     }
                     return true;
                 }
                 else
                     return false;
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine(ex.Message);
                 return false;
             }
         }
     }
     //return true;
 }
Example #2
0
 //insert update
 public Entities.KhoHang InsertUpdate(Entities.KhoHang kh1)
 {
     Entities.KhoHang k = new Entities.KhoHang();
     try
     {
         kh = new Constants.KhoHang();
         Sql = new Constants.Sql();
         string sql = Sql.InsertUpdateKhoHang;
         Connection conn = new Connection();
         SqlConnection cn = conn.openConnection();
         SqlCommand cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(kh.HanhDong, SqlDbType.NVarChar, 20).Value = kh1.HanhDong;
         cmd.Parameters.Add(kh.KhoHangID, SqlDbType.Int).Value = kh1.KhoHangID;
         cmd.Parameters.Add(kh.MaKho, SqlDbType.VarChar, 20).Value = kh1.MaKho;
         cmd.Parameters.Add(kh.TenKho, SqlDbType.NVarChar, 200).Value = kh1.TenKho;
         cmd.Parameters.Add(kh.DiaChi, SqlDbType.NVarChar, 200).Value = kh1.DiaChi;
         cmd.Parameters.Add(kh.DienThoai, SqlDbType.NVarChar, 200).Value = kh1.DienThoai;
         cmd.Parameters.Add(kh.MaNhanVien, SqlDbType.NVarChar, 200).Value = kh1.MaNhanVien;
         cmd.Parameters.Add(kh.GhiChu, SqlDbType.NVarChar, 100).Value = kh1.GhiChu;
         cmd.Parameters.Add(kh.Deleted, SqlDbType.Bit).Value = kh1.Deleted;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         while (dr.Read())
         {
             k.GhiChu = dr[0].ToString();
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); k.GhiChu = null; }
     return k;
 }
Example #3
0
        public Recordset GetDataByID(Connection cn, int id)
        {
            string sql = "ad_GetCategoryByID " + id;
            Recordset rs = conn.Execute(sql, cn);

            return rs;
        }
Example #4
0
 internal DCC(ServerConnection creatorsServerConnection, Connection Parent)
     : base(creatorsServerConnection)
 {
     chat = new DCCChatContainer(creatorsServerConnection);
     transfer = new DCCTransferContainer(creatorsServerConnection);
     parent = Parent;
 }
Example #5
0
 public BinaryDecoder(Connection conn)
 {
     Connection = conn;
     // some messages have multiple blank lines between the header & message body
     while(conn.PeekLine() == string.Empty)
         conn.ReadLine();
 }
        public override void SetUp()
        {
            this.connection = (Connection) CreateConnection();
            this.connection.RedeliveryPolicy = GetRedeliveryPolicy();

            this.counter = 0;
        }
        public override void Handle(Connection connection)
        {
            var account = connection.Session.Account;
            var notification = new Notification();

            notification.UserId = account.Id;
            notification.Regex = new Regex(RegexPattern);
            notification.DeviceToken = DeviceToken;

            if (Program.NotificationManager.Exists(DeviceToken))
            {
                notification.Save();
            }
            else
            {
                if (Program.NotificationManager.FindWithId(account.Id).Count() < 5)
                {
                    notification.Insert();
                }
                else
                {
                    connection.SendSysMessage("You may only have 5 devices registered for push notifications.");
                    return;
                }
            }

            Program.NotificationsDirty = true;

            var notificationSubscription = new NotificationSubscription();
            notificationSubscription.DeviceToken = DeviceToken;
            notificationSubscription.RegexPattern = RegexPattern;
            notificationSubscription.Registered = true;

            connection.Send(notificationSubscription);
        }
Example #8
0
 public NodePingInfo(IConnection con, string nodeName = null)
 {
     Connection = new Connection(con);
     NextPingDate = DateTime.Now;
     IsPinged = false;
     NodeName = nodeName;
 }
Example #9
0
 public SeekerData(SeekerData original, Connection connection, float gScore, float hScore)
 {
     m_Path = new List<Connection> (original.Path);
     m_Path.Add (connection);
     m_GScore = original.GScore + gScore;
     m_HScore = original.HScore + hScore;
 }
Example #10
0
        /// <summary>
        /// lay bang cong ty
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        public Entities.ThongTinCongTy sp_ThongTinCongTy(Entities.TruyenGiaTri ct)
        {
            Entities.ThongTinCongTy banghi = new Entities.ThongTinCongTy();
            try
            {
                string sql = "exec sp_ThongTinCongTy @MaCongTy";
                conn = new Connection();
                cn = conn.openConnection();
                cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add("MaCongTy", SqlDbType.VarChar, 20).Value = ct.Giatritruyen;
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                ArrayList arr = new ArrayList();
                while (dr.Read())
                {

                    banghi.MaCongTy = dr[0].ToString();
                    banghi.TenCongTy = dr[1].ToString();
                    banghi.DiaChi = dr[2].ToString();
                    banghi.SoDienThoai = dr[3].ToString();
                    banghi.Email = dr[4].ToString();
                    banghi.Website = dr[5].ToString();
                    banghi.Fax = dr[6].ToString();
                }
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); banghi = null; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
            }
            return banghi;
        }
 public static Dictionary<string, Category> GetTarget_CategoriesToTransfer(Connection connection)
 {
     var transferCategories =
         connection.ThisSideCategories
                   .Where(
                       tCat => tCat.NativeCategoryDomainName == "AaltoGlobalImpact.OIP" &&
                               tCat.NativeCategoryObjectName == "Category")
                   .ToArray();
     CategoryCollection categoryCollection = CategoryCollection.RetrieveFromOwnerContent(
         InformationContext.CurrentOwner, "MasterCollection");
     var sourceCategoryDict = categoryCollection.CollectionContent.ToDictionary(cat => cat.ID);
     var sourceCategoryList = categoryCollection.CollectionContent;
     var childrenInclusiveSourceIDs = connection.CategoryLinks.Where(catLink => catLink.LinkingType == TheBall.Interface.Category.LINKINGTYPE_INCLUDECHILDREN).Select(catLink => catLink.SourceCategoryID).ToArray();
     var childrenInclusiveIDs = transferCategories
         .Where(tCat => childrenInclusiveSourceIDs.Contains(tCat.ID))
         .Select(tCat => tCat.NativeCategoryID).OrderBy(str => str)
         .ToList();
     var exactMatchSourceIDs = connection.CategoryLinks.Where(catLink => catLink.LinkingType == TheBall.Interface.Category.LINKINGTYPE_ONE).Select(catLink => catLink.SourceCategoryID).ToArray();
     var exactMatchIDs = transferCategories
         .Where(tCat => exactMatchSourceIDs.Contains(tCat.ID))
         .Select(tCat => tCat.NativeCategoryID).OrderBy(str => str)
         .ToList();
     var result =
         sourceCategoryList
             .Where(cat => matchesOrParentMatches(cat, exactMatchIDs, childrenInclusiveIDs, sourceCategoryDict))
             .ToArray();
     return result.ToDictionary(cat => cat.ID);
 }
        public void SendingCommandObjectSetsCommandOnBus()
        {
            var messageBus = new Mock<IMessageBus>();
            var counters = new Mock<IPerformanceCounterWriter>();
            Message message = null;
            messageBus.Setup(m => m.Publish(It.IsAny<Message>())).Returns<Message>(m =>
            {
                message = m;
                return TaskAsyncHelper.Empty;
            });

            var serializer = new JsonNetSerializer();
            var traceManager = new Mock<ITraceManager>();
            var connection = new Connection(messageBus.Object,
                                            serializer,
                                            "signal",
                                            "connectonid",
                                            new[] { "a", "signal", "connectionid" },
                                            new string[] { },
                                            traceManager.Object,
                                            counters.Object);

            connection.Send("a", new Command
            {
                Type = CommandType.AddToGroup,
                Value = "foo"
            });

            Assert.NotNull(message);
            Assert.True(message.IsCommand);
            var command = serializer.Parse<Command>(message.Value);
            Assert.Equal(CommandType.AddToGroup, command.Type);
            Assert.Equal("foo", command.Value);
        }
 public JDBCCategoryDataset(string url, string driverName, string user, string passwd)
 {
   JDBCCategoryDataset jdbcCategoryDataset = this;
   this.transpose = true;
   Class.forName(driverName, JDBCCategoryDataset.__\u003CGetCallerID\u003E());
   this.connection = DriverManager.getConnection(url, user, passwd, JDBCCategoryDataset.__\u003CGetCallerID\u003E());
 }
Example #14
0
        public Mensalista getMensalistabyId_cliente(int id_cliente)
        {
            Mensalista returnMensalista = null;

            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "select * from Mensalistas m inner join Clientes c on m.Id_cliente = c.Id_Cliente where m.Id_cliente = " + id_cliente + " ";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            if (reader.Read())
            {
                while (reader.Read())
                {
                    returnMensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                    returnMensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));
                    returnMensalista.nome_cliente = string.Format("{0}", reader[4]);
                    returnMensalista.data_termino = string.Format("{0}", reader[2]);
                }
            }

            return returnMensalista;
        }
Example #15
0
        public List<Mensalista> buscar(String nomeCliente)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Mensalistas m INNER JOIN Clientes c ON m.Id_cliente = c.Id_Cliente WHERE c.Nome like '%"+ nomeCliente +"%'";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Mensalista> listaMensalistas = new List<Mensalista>();

            while (reader.Read())
            {
                Mensalista mensalista = new Mensalista();
                mensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                mensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));

                Cliente cliente = new Cliente();
                cliente.nome = string.Format("{0}", reader[4]);

                mensalista.nome_cliente = cliente.nome;
                mensalista.data_termino = string.Format("{0}", reader[2]);

                listaMensalistas.Add(mensalista);
            }
            con.closeConnection();
            return listaMensalistas;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Menu menu = Master.FindControl("NavigationMenu") as Menu;
                menu.Items[2].ChildItems[0].ChildItems.RemoveAt(1);

                if (Session.Contents["rol"].ToString().Equals("DSTADM"))
                    Response.Redirect("../Default.aspx");

                Connection conexion = new Connection();
                string query = String.Empty;

                SqlDataSource1.ConnectionString = conexion.getConnectionString();

                if (Session.Contents["rol"].ToString().Equals("KCPADM"))
                    query = String.Format("SELECT USER_ID, USER_NAME, STATUS, E_MAIL FROM USUARIOS AS U WHERE USER_ID <> '{0}' AND ID_COUNTRY = '{1}' AND 0 = (SELECT count(Kam.KAM_NAME) from Kam where Kam.KAM_ID = U.USER_ID AND Kam.KAM_ACTIVE = 1)",
                        Session.Contents["userid"].ToString(), conexion.getUserCountry(Session.Contents["userid"].ToString()));
                else if (Session.Contents["rol"].ToString().Equals("KCPCCR"))
                    query = String.Format("SELECT USER_ID, USER_NAME, STATUS, E_MAIL FROM USUARIOS WHERE USER_ID <> '{0}' AND ID_COUNTRY = '{1}' AND (ID_ROL <> 'KCPADM' AND ID_ROL <> 'KCPCCR')",
                        Session.Contents["userid"].ToString(), conexion.getUserCountry(Session.Contents["userid"].ToString()));

                SqlDataSource1.SelectCommand = query;
                SqlDataSource1.ConflictDetection = ConflictOptions.CompareAllValues;
            }
            catch (Exception error)
            {
                RadAjaxManager1.ResponseScripts.Add(String.Format("errorEnvio('{0}');", error.Message));
            }
        }
Example #17
0
        public static void Add(
            Connection connection,
            NetworkMessage outMessage,
            Location fromLocation,
            Location toLocation
            )
        {
            if (fromLocation.Y > toLocation.Y)
            { // north, for old x
                outMessage.AddByte((byte)ServerPacketType.MapSliceNorth);
                AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y - 6, toLocation.Z, 18, 1);
            }
            else if (fromLocation.Y < toLocation.Y)
            { // south, for old x
                outMessage.AddByte((byte)ServerPacketType.MapSliceSouth);
                AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y + 7, toLocation.Z, 18, 1);
            }

            if (fromLocation.X < toLocation.X)
            { // east, [with new y]
                outMessage.AddByte((byte)ServerPacketType.MapSliceEast);
                AddMapDescription(connection, outMessage, toLocation.X + 9, toLocation.Y - 6, toLocation.Z, 1, 14);
            }
            else if (fromLocation.X > toLocation.X)
            { // west, [with new y]
                outMessage.AddByte((byte)ServerPacketType.MapSliceWest);
                AddMapDescription(connection, outMessage, toLocation.X - 8, toLocation.Y - 6, toLocation.Z, 1, 14);
            }
        }
        public override async Task<bool> Connect(Connection newConnection)
        {
            var deviceInfo = newConnection.Source as DeviceInformation;
            if (deviceInfo != null)
            {
                this.service = await SerialDevice.FromIdAsync(deviceInfo.Id);
                if (this.service == null)
                {
                    return false;
                }

                this.service.BaudRate = 115200;
                this.service.StopBits = SerialStopBitCount.One;
                this.service.Handshake = SerialHandshake.None;
                this.service.DataBits = 8;

                this.service.ReadTimeout = TimeSpan.FromSeconds(5);
                this.service.WriteTimeout = TimeSpan.FromSeconds(5);
                this.service.IsDataTerminalReadyEnabled = false;

                return this.InstrumentSocket(this.service.InputStream, this.service.OutputStream);
            }

            return false;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionMetadata"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="databaseName">Name of the database.</param>
 /// <param name="collectionName">The name.</param>
 /// <param name="connection">The connection.</param>
 internal CollectionMetadata(MongoConfiguration configuration, string databaseName, string collectionName, Connection connection)
 {
     //Todo: Add public constrcutors for users to call
     _fullName = databaseName + "." + collectionName;
     _name = collectionName;
     _database = new MongoDatabase(configuration, connection, databaseName);
 }
Example #20
0
 public void CheckIn(Connection value)
 {
     lock (_ConnectionQueue)
     {
         _ConnectionQueue.Enqueue(value);
     }
 }
Example #21
0
        public override Connection CreateClientConnection(Connection connection)
        {
            if (this.HasCertificate)
                this.LoadCertificate();

            return new HttpSslConnection(this, connection);
        }
Example #22
0
        public void TestConnectionSerialization()
        {
            var obj = new Connection
                          {
                              Id = Guid.NewGuid(),
                              Type = ExpressionNodeType.Connection,
                              Sink = new ConnectorIn(null) {Id = Guid.NewGuid()},
                              Source = new ConnectorOut(null) {Id = Guid.NewGuid()}
                          };

            var tw = new StringWriter();

            using (var xw = XmlWriter.Create(tw))
            {
                xw.WriteStartElement("Node");
                obj.Serialize(xw);
                xw.WriteEndElement();
            }

            var sr = new StringReader(tw.ToString());

            using (var wr = XmlReader.Create(sr))
            {
                wr.ReadToFollowing("Node");
                var result = new Connection();
                result.Deserialize(wr);

                Assert.AreEqual(obj.Id, result.Id);
                Assert.AreEqual(obj.Type, result.Type);
                Assert.AreEqual(obj.Sink.Id, result.Sink.Id);
                Assert.AreEqual(obj.Source.Id, result.Source.Id);
            }
            
        }
 public void SelectNode(Node node)
 {
     GameObject connection = Instantiate(Resources.Load("Connection")) as GameObject;
     Connection connection_component = connection.GetComponent<Connection>();
     connection_component.InitializeWithStartNode(node);
     m_connection = connection_component;
 }
Example #24
0
        public void Delete(Entities.TKNganHang tk1)
        {
            try
            {
                TKNH = new Constants.TKNganHang();
                Entities.TKNganHang TKNganHang = new Entities.TKNganHang();
                Sql = new Constants.Sql();
                string sql = Sql.DeleteTKNganHang;
                Connection conn = new Connection();
                SqlConnection cn = conn.openConnection();
                SqlCommand cmd = new SqlCommand(sql, cn);
                cmd.Parameters.Add(TKNH.HanhDong, SqlDbType.NVarChar, 20).Value = tk1.HanhDong;
                cmd.Parameters.Add(TKNH.TKNganHangID, SqlDbType.Int).Value = tk1.TKNganHangID;

                cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                conn.closeConnection();
                cn = null;
                conn = null;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }
Example #25
0
        public Recordset GetDataByUsername(Connection cn, string username)
        {
            string sql = "GetUserByUsername " + username;
            Recordset rs = conn.Execute(sql, cn);

            return rs;
        }
Example #26
0
        public int InsertUpdate(Entities.TKNganHang tk1)
        {
            TKNH = new Constants.TKNganHang();
            Sql = new Constants.Sql();
            string sql = Sql.InsertUpdateTKNganHang;
            Connection conn = new Connection();
            SqlConnection cn = conn.openConnection();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.Parameters.Add(TKNH.HanhDong, SqlDbType.NVarChar, 20).Value = tk1.HanhDong;
            cmd.Parameters.Add(TKNH.TKNganHangID, SqlDbType.Int).Value = tk1.TKNganHangID;
            cmd.Parameters.Add(TKNH.MaTKNganHang, SqlDbType.NVarChar, 20).Value = tk1.MaTKNganHang;
            cmd.Parameters.Add(TKNH.SoTK, SqlDbType.NVarChar, 20).Value = tk1.SoTK;
            cmd.Parameters.Add(TKNH.MaTienTe, SqlDbType.NVarChar, 200).Value = tk1.MaTienTe;
            cmd.Parameters.Add(TKNH.SoDu, SqlDbType.Int).Value = tk1.SoDu;
            cmd.Parameters.Add(TKNH.SoSecKeTiep, SqlDbType.NVarChar, 20).Value = tk1.SoSecKeTiep;
            cmd.Parameters.Add(TKNH.NguoiLienHe, SqlDbType.NVarChar, 200).Value = tk1.NguoiLienHe;
            cmd.Parameters.Add(TKNH.DiaChi, SqlDbType.NVarChar, 200).Value = tk1.DiaChi;
            cmd.Parameters.Add(TKNH.DienThoai, SqlDbType.NVarChar, 20).Value = tk1.DienThoai;
            cmd.Parameters.Add(TKNH.Email, SqlDbType.NVarChar, 20).Value = tk1.Email;
            cmd.Parameters.Add(TKNH.Website, SqlDbType.NVarChar, 20).Value = tk1.Website;
            cmd.Parameters.Add(TKNH.GhiChu, SqlDbType.NVarChar, 200).Value = tk1.Ghichu;
            cmd.Parameters.Add(TKNH.Laisuat, SqlDbType.Float).Value = tk1.Laisuat;
            cmd.Parameters.Add(TKNH.Deleted, SqlDbType.Bit).Value = tk1.Deleted;

            int i = cmd.ExecuteNonQuery();
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
            return i;
        }
Example #27
0
 public override string SendQuery(string query)
 {
     var data = encode.GetBytes(query);
     if (Connections.Count > 300)
     {
         throw new Exception("TcpClientPool连接已超过500");
     }
     Connection connection;
     lock (lockObj)
     {
         connection = Connections.Find(b => b.Used == false);
         if (connection == null)
         {
             connectionIndex += 1;
             connection = new Connection() { Socket = new CoreHelper.SocketUtil.TcpClient(server, port, 3, true), Index = connectionIndex };
             Connections.Add(connection);
         }
         connection.Used = true;
     }
     var result = connection.Socket.SendAndReceive(data);
     lock (lockObj)
     {
         connection.Used = false;
         connection.LastUseTime = DateTime.Now;
     }
     if (result == null)
     {
         //connection.Socket.Dispose();
         //Connections.Remove(connection);
         throw new Exception("连接到缓存服务器时发生错误:" + connection.Socket.LastException.Message);
     }
     var response = encode.GetString(result);
     return response;
 }
Example #28
0
        public Instance(AppSettings settings, string instanceName, ConnectionType type)
        {
            //is this necessary to store?
            _connectionType = type;

            _settings = settings;

            if (!_settings.WorkingPath.Exists)
            {
                _settings.WorkingPath.Create();
            }

            if (!_settings.TransferPath.Exists)
            {
                _settings.TransferPath.Create();
            }

            Connection = new Connection(type, settings, instanceName);

            Connection.Service.Instance = this;

            Connection.LostConnection += new EventHandler<ExceptionEventArgs>(Connection_LostConnection);
            Connection.MessageReceived += new EventHandler<MessageEventArgs>(Connection_MessageReceived);
            Connection.MessageSending += new EventHandler<MessageEventArgs>(Connection_MessageSending);
            Connection.ConnectionMade += new EventHandler(Connection_ConnectionMade);
            Connection.ConnectionTermainated += new EventHandler(Connection_ConnectionTermainated);
        }
        protected void grdUsuarios_ItemUpdated(object source, GridUpdatedEventArgs e)
        {
            try
            {
                GridEditableItem item = e.Item as GridEditableItem;
                string userId = item.GetDataKeyValue("USER_ID").ToString();

                Connection conexion = new Connection();
                conexion.Actualizar(String.Format("UPDATE USUARIOS SET P_EXPIRATION = '{0}' WHERE USER_ID = '{1}'", DateTime.Now.AddMonths(1).ToString("yyyMMdd"), userId));

                if (e.Exception != null)
                {
                    e.KeepInEditMode = true;
                    e.ExceptionHandled = true;
                    RadAjaxManager1.ResponseScripts.Add(String.Format("errorEdicion('{0}');", e.Exception.Message.ToString()));
                }
                else
                {
                    RadAjaxManager1.ResponseScripts.Add(String.Format("alert('Usuario actualizado.');"));
                }
            }
            catch (Exception error)
            {
                RadAjaxManager1.ResponseScripts.Add(String.Format("errorEnvio('{0}');", error.Message));
            }
        }
Example #30
0
 //delete
 public int Delete(Entities.KhoHang kh1)
 {
     int tra = 0;
     try
     {
         kh = new Constants.KhoHang();
         Entities.KhoHang khohang = new Entities.KhoHang();
         Sql = new Constants.Sql();
         string sql = Sql.DeleteKhoHang;
         Connection conn = new Connection();
         SqlConnection cn = conn.openConnection();
         SqlCommand cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(kh.HanhDong, SqlDbType.NVarChar, 20).Value = kh1.HanhDong;
         cmd.Parameters.Add(kh.KhoHangID, SqlDbType.Int).Value = kh1.KhoHangID;
         tra = cmd.ExecuteNonQuery();
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
         cn = null;
         conn = null;
     }
     catch (Exception ex)
     { string s = ex.Message; tra = 0; }
     return tra;
 }