Пример #1
0
        public SingleResponeMessage <NegotiationInfo> Get(int id, string _userID)
        {
            SingleResponeMessage <NegotiationInfo> ret = new SingleResponeMessage <NegotiationInfo>();

            try
            {
                NegotiationInfo item = NegotiationService.GetInstance().GetNegotiation(id, _userID);
                if (item == null)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "001";
                    ret.err.msgString = "no Negotiation found";
                    return(ret);
                }
                ret.item      = item;
                ret.isSuccess = true;
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Пример #2
0
        public ActionMessage editNegotiation(int id, NegotiationInfo _Negotiation, string _userU, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                var chkNegotiationInfo = NegotiationDataLayer.GetInstance().getNegotiation(connection, id, _userID);
                if (chkNegotiationInfo != null)
                {
                    try
                    {
                        NegotiationDataLayer.GetInstance().UpdateNegotiation(connection, id, _Negotiation, _userU);
                        ret.isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        ret.isSuccess     = false;
                        ret.err.msgCode   = "123";
                        ret.err.msgString = "123";
                    }
                }
            }
            return(ret);
        }
Пример #3
0
        public async Task <ActionMessage> Put(int id, [FromForm] NegotiationInfo _Negotiation, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = NegotiationService.GetInstance().editNegotiation(id, _Negotiation, GetUserId(), _userID);
                //update list file

                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Negotiation.ListDocument, TableFile.Negotiation.ToString(), id);
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Negotiation.ToString();
                    documentInfo.PreferId  = id.ToString();
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Negotiation.ToString(), _Negotiation.NegotiationID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Пример #4
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] NegotiationInfo NegotiationObj, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret     = new ActionMessage();
            int           insetId = -1;

            try
            {
                insetId       = NegotiationService.GetInstance().createNegotiation2(NegotiationObj, GetUserId());
                ret.isSuccess = true;
                if (insetId > -1)
                {
                    ret.id = insetId;
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Negotiation.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.Negotiation.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Пример #5
0
        public ContractPrintModel GetNegotiationPrintModel(int contractID, string _userID)
        {
            ContractPrintModel   record        = new ContractPrintModel();
            NegotiationInfo      info          = new NegotiationInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            NewContractInfo      contractInfo  = getContractNew(contractID, _userID);

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                info = NegotiationDataLayer.GetInstance().getNegotiation(connection, contractInfo.NegotiationID, _userID);
                if (record == null || info == null)
                {
                    return(null);
                }

                CustomerInfo cusInfo = CustomerDataLayer.GetInstance().getCustomer(connection, info.CustomerID);

                record.ContractCode = contractInfo.ContractCode;
                record.DateIn       = contractInfo.DateIn;
                record.ASide        = "BỆNH VIỆN TRUYỀN MÁU HUYẾT HỌC";
                record.BSide        = info.CustomerName;

                record.ALocation  = info.Location;
                record.APhone     = info.Phone;
                record.AFax       = info.Fax;
                record.ABankID    = info.BankID;
                record.ATaxCode   = info.TaxCode;
                record.ARepresent = info.Represent;
                record.APosition  = info.Position;

                record.BLocation       = cusInfo.Address;
                record.BPhone          = cusInfo.Phone;
                record.BFax            = cusInfo.Fax;
                record.BBankID         = cusInfo.BankNumber + " " + cusInfo.BankName;
                record.BTaxCode        = cusInfo.TaxCode;
                record.BRepresent      = cusInfo.Surrogate;
                record.BPosition       = cusInfo.Position;
                record.NegotiationTime = info.DateIn;
                record.Term            = info.Term;
                record.NegotiationCode = info.NegotiationCode;
                record.VATNumber       = info.VATNumber;
                record.IsVAT           = info.IsVAT;
                record.QuoteTotalCost  = info.QuoteTotalCost;
                record.Items           = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                            record.QuoteID);
                record.QuoteID   = info.QuoteID;
                record.QuoteCode = info.QuoteCode;


                record.BidType          = info.BidType;
                record.BidExpirated     = info.BidExpirated;
                record.BidExpiratedUnit = info.BidExpiratedUnit;

                record.Items = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                  record.QuoteID);

                return(record);
            }
        }
Пример #6
0
        public int InsertNegotiation(SqlConnection connection, NegotiationInfo _Negotiation, string _userI)
        {
            int lastestInserted = 0;
            var currenttime     = DateTime.Now.Date;

            if (_Negotiation.NegotiationCode == null)
            {
                _Negotiation.NegotiationCode = "TT-" + DateTime.Now.ToString("yyyyMMddHHmmss");
            }

            using (var command = new SqlCommand("Insert into [dbo].[tbl_Negotiation]" +
                                                " (NegotiationCode, QuoteID , Location, Phone, Fax, BankID, TaxCode, Represent, Position,UserI, DateIn, Term , CustomerID ,BidExpirated, BidExpiratedUnit, BidType)" +                        //, CapitalID
                                                "VALUES( @NegotiationCode, @QuoteID , @Location, @Phone, @Fax, @BankID, @TaxCode, @Represent, @Position, @UserI, @DateIn, @Term, @CustomerID ,@BidExpirated, @BidExpiratedUnit, @BidType) " + //, @CapitalID
                                                "select IDENT_CURRENT('dbo.tbl_Negotiation') as LastInserted ", connection))
            {
                AddSqlParameter(command, "@NegotiationCode", _Negotiation.NegotiationCode, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@QuoteID", _Negotiation.QuoteID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@CustomerID", _Negotiation.CustomerID, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@Location", _Negotiation.Location, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@Phone", _Negotiation.Phone, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@Fax", _Negotiation.Fax, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@BankID", _Negotiation.BankID, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@TaxCode", _Negotiation.TaxCode, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@Represent", _Negotiation.Represent, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@Position", _Negotiation.Position, System.Data.SqlDbType.NText);
                AddSqlParameter(command, "@DateIn", _Negotiation.DateIn, System.Data.SqlDbType.DateTime);
                AddSqlParameter(command, "@UserI", _userI, System.Data.SqlDbType.VarChar);
                AddSqlParameter(command, "@Term", _Negotiation.Term, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@BidExpirated", _Negotiation.BidExpirated, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@BidExpiratedUnit", _Negotiation.BidExpiratedUnit, System.Data.SqlDbType.NVarChar);
                AddSqlParameter(command, "@BidType", _Negotiation.BidType, System.Data.SqlDbType.NText);


                WriteLogExecutingCommand(command);
                var lastInsertedRaw = command.ExecuteScalar();
                if (lastInsertedRaw != null && !DBNull.Value.Equals(lastInsertedRaw))
                {
                    lastestInserted = Convert.ToInt32(lastInsertedRaw);
                }
            }

            if (lastestInserted > 0)
            {
                using (var command = new SqlCommand("update  tbl_Proposal_Process " +
                                                    "set NegotiationID=@NegotiationID  , NegotiationTime=@NegotiationTime ,  CurrentFeature=@CurrentFeature where QuoteID=@QuoteID", connection))
                {
                    AddSqlParameter(command, "@QuoteID", _Negotiation.QuoteID, System.Data.SqlDbType.Int);
                    AddSqlParameter(command, "@NegotiationID", lastestInserted, System.Data.SqlDbType.Int);
                    AddSqlParameter(command, "@NegotiationTime", currenttime, System.Data.SqlDbType.DateTime);
                    AddSqlParameter(command, "@CurrentFeature", "Negotiation", System.Data.SqlDbType.VarChar);
                    WriteLogExecutingCommand(command);
                    command.ExecuteScalar();
                }
            }
            return(lastestInserted);
        }
Пример #7
0
        public ActionMessage Put(int id, [FromBody] NegotiationInfo _negotiation, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = NegotiationService.GetInstance().editNegotiation(id, _negotiation, GetUserId(), _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Пример #8
0
        public ActionMessage Post([FromBody] NegotiationInfo _negotiation)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = NegotiationService.GetInstance().createNegotiation(_negotiation, GetUserId());
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Пример #9
0
        public int createNegotiation2(NegotiationInfo _Negotiation, string _userI)
        {
            int ret = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    ret = NegotiationDataLayer.GetInstance().InsertNegotiation(connection, _Negotiation, _userI);
                }
                catch (Exception ex)
                {
                    ret = -1;
                }
            }
            return(ret);
        }
Пример #10
0
        public NegotiationInfo GetNegotiationByCode(SqlConnection connection, string code)
        {
            NegotiationInfo info = null;

            using (var command = new SqlCommand("" +
                                                "SELECT tblN.* , tbl_Quote.QuoteCode , tbl_Customer.CustomerName  from  tbl_Negotiation tblN" +
                                                "  inner join tbl_Quote " +
                                                "  on tblN.QuoteID = tbl_Quote.QuoteID" +
                                                "  inner join tbl_Customer" +
                                                "  on tblN.CustomerID = tbl_Customer.CustomerID  " +
                                                " where tblN.NegotiationCode = @NegotiationCode ", connection))
            {
                AddSqlParameter(command, "@NegotiationID", code, System.Data.SqlDbType.NVarChar);
                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        info = new NegotiationInfo();
                        info.NegotiationID    = GetDbReaderValue <int>(reader["NegotiationID"]);
                        info.NegotiationCode  = GetDbReaderValue <string>(reader["NegotiationCode"]);
                        info.BidType          = GetDbReaderValue <string>(reader["BidType"]);
                        info.BidExpirated     = GetDbReaderValue <int>(reader["BidExpirated"]);
                        info.BidExpiratedUnit = GetDbReaderValue <string>(reader["BidExpiratedUnit"]);

                        info.QuoteCode    = GetDbReaderValue <string>(reader["QuoteCode"]);
                        info.QuoteID      = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.CustomerName = GetDbReaderValue <string>(reader["CustomerName"]);
                        info.CustomerID   = GetDbReaderValue <int>(reader["CustomerID"]);



                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);
                        info.Term       = GetDbReaderValue <int>(reader["Term"]);
                    }
                }
                return(info);
            }
        }
Пример #11
0
 public void UpdateNegotiation(SqlConnection connection, int _id, NegotiationInfo _Negotiation, string _userI)
 {
     using (var command = new SqlCommand("update  [dbo].[tbl_Negotiation]" +
                                         "  set " +
                                         "  NegotiationCode = @NegotiationCode " +
                                         " , QuoteID = @QuoteID" +
                                         " , Location=@Location " +
                                         " , Phone=@Phone " +
                                         " , Fax=@Fax " +
                                         " , BankID=@BankID " +
                                         " , TaxCode=@TaxCode " +
                                         " , Represent=@Represent " +
                                         " , Position=@Position " +
                                         " , UserI=@UserI " +
                                         " , DateIn =@DateIn " +
                                         " , Term  =@Term " +
                                         " , CustomerID = @CustomerID  " +
                                         " , BidExpirated = @BidExpirated  " +
                                         " , BidExpiratedUnit = @BidExpiratedUnit  " +
                                         " , BidType = @BidType  " +
                                         " where NegotiationID = " + _id.ToString()// " , CapitalID = @CapitalID  " +
                                         , connection))
     {
         AddSqlParameter(command, "@NegotiationCode", _Negotiation.NegotiationCode, System.Data.SqlDbType.NVarChar);
         AddSqlParameter(command, "@QuoteID", _Negotiation.QuoteID, System.Data.SqlDbType.Int);
         AddSqlParameter(command, "@CustomerID", _Negotiation.CustomerID, System.Data.SqlDbType.Int);
         AddSqlParameter(command, "@Location", _Negotiation.Location, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@Phone", _Negotiation.Phone, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@Fax", _Negotiation.Fax, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@BankID", _Negotiation.BankID, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@TaxCode", _Negotiation.TaxCode, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@Represent", _Negotiation.Represent, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@Position", _Negotiation.Position, System.Data.SqlDbType.NText);
         AddSqlParameter(command, "@DateIn", _Negotiation.DateIn, System.Data.SqlDbType.DateTime);
         AddSqlParameter(command, "@UserI", _userI, System.Data.SqlDbType.VarChar);
         AddSqlParameter(command, "@Term", _Negotiation.Term, System.Data.SqlDbType.Int);
         AddSqlParameter(command, "@BidExpirated", _Negotiation.BidExpirated, System.Data.SqlDbType.Int);
         AddSqlParameter(command, "@BidExpiratedUnit", _Negotiation.BidExpiratedUnit, System.Data.SqlDbType.NVarChar);
         AddSqlParameter(command, "@BidType", _Negotiation.BidType, System.Data.SqlDbType.NText);
         command.ExecuteScalar();
     }
 }
Пример #12
0
        public ActionMessage createNegotiation(NegotiationInfo _Negotiation, string _userI)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    ret.id        = NegotiationDataLayer.GetInstance().InsertNegotiation(connection, _Negotiation, _userI);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "123";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
Пример #13
0
        public NegotiationInfo GetNegotiationByCode(string code)
        {
            NegotiationInfo      record        = new NegotiationInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = NegotiationDataLayer.GetInstance().GetNegotiationByCode(connection, code);
                if (record == null)
                {
                    return(null);
                }

                record.Items = new List <ItemInfo>();
                record.Items = QuoteDataLayer.GetInstance().GetQuoteItems(connection, record.QuoteID);
                //bidPlanDetail.ListMember = BidPlanDataLayer.GetInstance().GetBidPlanMembers(connection, _ID);

                //negotiationDetail.ListMember = NegotiationDataLayer.GetInstance().GetNegotiationMembers(connection, _ID);
                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Negotiation.ToString();
                documentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Negotiation.ToString();
                commentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }

                return(record);
            }
        }
Пример #14
0
        public NegotiationInfo GetNegotiation(int _ID, string _userID)
        {
            NegotiationInfo      record        = new NegotiationInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = NegotiationDataLayer.GetInstance().getNegotiation(connection, _ID, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.Items = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                  record.QuoteID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Negotiation.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Negotiation.ToString();
                commentCriteria.PreferId  = _ID.ToString();
                record.ListComment        = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in record.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }

                return(record);
            }
        }
Пример #15
0
        /// <summary>
        /// Hàm lấy tất cả khoa phòng
        /// </summary>
        /// <returns>Return List<NegotiationInfo></returns>
        ///

        public List <NegotiationInfo> getNegotiation(SqlConnection connection, NegotiationSeachCriteria _criteria, string _userID)
        {
            var result = new List <NegotiationInfo>();
            var query  = "SELECT tblN.* , tblQ.QuoteCode , tbl_Customer.CustomerName from  tbl_Negotiation tblN" +
                         "  inner join tbl_Quote tblQ " +
                         "  on tblN.QuoteID = tblQ.QuoteID" +
                         "  inner join tbl_Customer" +
                         "  on tblN.CustomerID = tbl_Customer.CustomerID  " +
                         " where tblN.DateIn between @FromDate and @ToDate ";

            if (_criteria.NegotiationCode != null && _criteria.NegotiationCode != "")
            {
                query += " and tblN.NegotiationCode like '%" + _criteria.NegotiationCode + "%'";
            }
            if (_criteria.QuoteCode != null && _criteria.QuoteCode != "")
            {
                query += " and tblQ.QuoteCode  like '%" + _criteria.QuoteCode + "%'";
            }
            if (_criteria.CustomerID != 0)
            {
                query += " and tbl_Customer.CustomerID =" + _criteria.CustomerID + " ";
            }
            if (!string.IsNullOrEmpty(_userID) && _userID != "admin")
            {
                query += " and ( tblN.UserAssign = " + _userID + " ) or ( tblN.UserI = " + _userID + " )";
            }
            query += " order by tblN.UpdateTime Desc ";


            using (var command = new SqlCommand(query
                                                , connection))
            {
                AddSqlParameter(command, "@FromDate", _criteria.FromDate, System.Data.SqlDbType.DateTime);
                AddSqlParameter(command, "@ToDate", _criteria.ToDate, System.Data.SqlDbType.DateTime);

                if (_criteria.pageSize == 0)
                {
                    _criteria.pageSize = 10;
                }
                var offSet = _criteria.pageIndex * _criteria.pageSize;


                command.CommandText += " OFFSET @OFFSET ROWS FETCH NEXT @PAGESIZE ROWS ONLY ";
                AddSqlParameter(command, "@OFFSET", offSet, System.Data.SqlDbType.Int);
                AddSqlParameter(command, "@PAGESIZE", _criteria.pageSize, System.Data.SqlDbType.Int);

                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new NegotiationInfo();
                        info.NegotiationID    = GetDbReaderValue <int>(reader["NegotiationID"]);
                        info.NegotiationCode  = GetDbReaderValue <string>(reader["NegotiationCode"]);
                        info.BidType          = GetDbReaderValue <string>(reader["BidType"]);
                        info.BidExpirated     = GetDbReaderValue <int>(reader["BidExpirated"]);
                        info.BidExpiratedUnit = GetDbReaderValue <string>(reader["BidExpiratedUnit"]);

                        info.QuoteCode    = GetDbReaderValue <string>(reader["QuoteCode"]);
                        info.QuoteID      = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.CustomerName = GetDbReaderValue <string>(reader["CustomerName"]);
                        info.CustomerID   = GetDbReaderValue <int>(reader["CustomerID"]);

                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);
                        info.Term       = GetDbReaderValue <int>(reader["Term"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
Пример #16
0
        public NegotiationInfo getNegotiation(SqlConnection connection, int _ID, string _userID)
        {
            NegotiationInfo info = null;

            using (var command = new SqlCommand("" +
                                                "SELECT tblN.* , tbl_Quote.QuoteCode , tbl_Customer.CustomerName,  " +
                                                "  tbl_Quote.ISVAT, tbl_Quote.VATNumber  from  tbl_Negotiation tblN" +
                                                "  inner join tbl_Quote " +
                                                "  on tblN.QuoteID = tbl_Quote.QuoteID" +
                                                "  inner join tbl_Customer" +
                                                "  on tblN.CustomerID = tbl_Customer.CustomerID  " +
                                                " where tblN.NegotiationID = @NegotiationID ", connection))
            {
                if (!string.IsNullOrEmpty(_userID) && _userID != "admin")
                {
                    command.CommandText += " and ( tblN.UserAssign = @UserID ) or ( tblN.UserI = @UserID )";
                    AddSqlParameter(command, "@UserID", _userID, SqlDbType.VarChar);
                }
                AddSqlParameter(command, "@NegotiationID", _ID, SqlDbType.Int);
                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        info = new NegotiationInfo();
                        info.NegotiationID   = GetDbReaderValue <int>(reader["NegotiationID"]);
                        info.NegotiationCode = GetDbReaderValue <string>(reader["NegotiationCode"]);

                        info.QuoteCode    = GetDbReaderValue <string>(reader["QuoteCode"]);
                        info.QuoteID      = GetDbReaderValue <int>(reader["QuoteID"]);
                        info.CustomerName = GetDbReaderValue <string>(reader["CustomerName"]);
                        info.CustomerID   = GetDbReaderValue <int>(reader["CustomerID"]);

                        info.Location                = GetDbReaderValue <string>(reader["Location"]);
                        info.Phone                   = GetDbReaderValue <string>(reader["Phone"]);
                        info.Fax                     = GetDbReaderValue <string>(reader["Fax"]);
                        info.BankID                  = GetDbReaderValue <string>(reader["BankID"]);
                        info.TaxCode                 = GetDbReaderValue <string>(reader["TaxCode"]);
                        info.Represent               = GetDbReaderValue <string>(reader["Represent"]);
                        info.Position                = GetDbReaderValue <string>(reader["Position"]);
                        info.contractType            = GetDbReaderValue <string>(reader["contractType"]);
                        info.contractTypeExpired     = GetDbReaderValue <int>(reader["contractTypeExpired"]);
                        info.contractTypeExpiredUnit = GetDbReaderValue <string>(reader["contractTypeExpiredUnit"]);
                        info.BidType                 = GetDbReaderValue <string>(reader["BidType"]);
                        info.BidExpirated            = GetDbReaderValue <int>(reader["BidExpirated"]);
                        info.BidExpiratedUnit        = GetDbReaderValue <string>(reader["BidExpiratedUnit"]);



                        info.IsVAT     = GetDbReaderValue <bool>(reader["ISVAT"]);
                        info.VATNumber = GetDbReaderValue <double>(reader["VATNumber"]);

                        info.DateIn     = GetDbReaderValue <DateTime>(reader["DateIn"]);
                        info.UserI      = GetDbReaderValue <string>(reader["UserI"]);
                        info.InTime     = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        info.UserU      = GetDbReaderValue <string>(reader["UserU"]);
                        info.UpdateTime = GetDbReaderValue <DateTime>(reader["UpdateTime"]);
                        info.Term       = GetDbReaderValue <int>(reader["Term"]);
                    }
                }
                return(info);
            }
        }