예제 #1
0
        public NewContractInfo getContractNew(int _ID, string _userID)
        {
            NewContractInfo      record        = new NewContractInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record             = ContractDataLayer.GetInstance().getContractNew(connection, _ID);
                record.negotiation = NegotiationService.GetInstance().GetNegotiation(record.NegotiationID, _userID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Contract.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Contract.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);
            }
        }
예제 #2
0
        public ActionMessage DeleteAll(string ids)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Explanation.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Explanation.ToString(), ids);
                    //delete records
                    ExplanationDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
예제 #3
0
        public ActionMessage Delete(int id)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.Acceptance.ToString(), id);

                    //delete commet
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Acceptance.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete record
                    AcceptanceDataLayer.GetInstance().Delete(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
예제 #4
0
        public ActionMessage Delete(int id, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.Negotiation.ToString(), id);


                    //delete commet
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Negotiation.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete record
                    List <string> quoteID = NegotiationDataLayer.GetInstance().GetQuoteByNegotiationIds(connection, id.ToString());
                    QuoteService.GetInstance().deleteProcess(connection, "Negotiation", String.Join(", ", quoteID.ToArray()), _userID);
                    NegotiationDataLayer.GetInstance().Delete(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
예제 #5
0
        public ContractInfo getContract(int _ID, string _userID)
        {
            ContractInfo         record        = new ContractInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record       = ContractDataLayer.GetInstance().getContract(connection, _ID, _userID);
                record.Items = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection,
                                                                                  record.QuoteID);
                //bidPlanDetail.ListMember = BidPlanDataLayer.GetInstance().GetBidPlanMembers(connection, _ID);
                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Contract.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Contract.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);
            }
        }
예제 #6
0
 public void DeleteComment(SqlConnection connection, CommentSeachCriteria _criteria)
 {
     using (var command = new SqlCommand(" delete tbl_Comment where TableName=@TableName and PreferId = @PreferId ", connection))
     {
         AddSqlParameter(command, "@TableName", _criteria.TableName, System.Data.SqlDbType.VarChar);
         AddSqlParameter(command, "@PreferId", _criteria.PreferId, System.Data.SqlDbType.Int);
         WriteLogExecutingCommand(command);
         command.ExecuteScalar();
     }
 }
예제 #7
0
        public ActionMessage DeleteMuti(string ids, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete employees
                    List <DeliveryReceiptEmployeeInfo> currentItems = DeliveryReceiptDataLayer.GetInstance().GetDeliveryReceiptEmployeesByIds(connection, ids);
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        DeliveryReceiptDataLayer.GetInstance().DeleteDeliveryReceiptEmployees(connection, autoIds);
                    }

                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.DeliveryReceipt.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.DeliveryReceipt.ToString(), ids);
                    //delete records

                    /* List<string> acceptanceSids = AcceptanceDataLayer.GetInstance().getAcceptanceByDeliveryReceiptids(connection,ids);
                     * if (acceptanceSids.Count > 0) {
                     *   AcceptanceDataLayer.GetInstance().DeleteMuti(connection,String.Join(", ", acceptanceSids.ToArray()));
                     * }*/
                    List <string> quoteID = DeliveryReceiptDataLayer.GetInstance().GetQuoteByDeliveryReceiptIds(connection, ids);
                    QuoteService.GetInstance().deleteProcess(connection, "DeliveryReceipt", String.Join(", ", quoteID.ToArray()), _userID);
                    DeliveryReceiptDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
예제 #8
0
        public ActionMessage Delete(int id, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete Items Table
                    List <AuditEmployeeInfo> currentItems = AuditDataLayer.GetInstance().GetAuditEmployeesById(connection, id.ToString());
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        //    AuditDataLayer.GetInstance().DeleteAuditEmployees(connection, autoIds);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.Audit.ToString(), id);


                    //delete commet
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Audit.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete Process

                    List <string> quoteID = AuditDataLayer.GetInstance().GetQuoteByAuditIds(connection, id.ToString());
                    QuoteService.GetInstance().deleteProcess(connection, "Audit", String.Join(", ", quoteID.ToArray()), _userID);
                    AuditDataLayer.GetInstance().Delete(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
예제 #9
0
 public List <CommentInfo> getComment(CommentSeachCriteria _criteria)
 {
     if (!string.IsNullOrEmpty(_criteria.TableName) && !string.IsNullOrEmpty(_criteria.PreferId))
     {
         SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
         using (SqlConnection connection = sqlConnection.GetConnection())
         {
             List <CommentInfo> ListComment = CommentDataLayer.GetInstance().getComment(connection, _criteria);
             return(ListComment);
         }
     }
     else
     {
         return(null);
     }
 }
예제 #10
0
        public ContractInfo GetContractByCode(string code, string _userID)
        {
            ContractInfo         record        = new ContractInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = ContractDataLayer.GetInstance().GeContractByCode(connection, code, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.Items = new List <ItemInfo>();
                record.Items = QuoteDataLayer.GetInstance().GetQuoteItems(connection, record.QuoteID);

                QuoteInfo quote = QuoteDataLayer.GetInstance().getQuote(connection, record.QuoteID, _userID);
                if (quote.TotalCost > 30000000)
                {
                    record.DeliveryReceiptType = 2;
                }
                else
                {
                    record.DeliveryReceiptType = 1;
                }
                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Contract.ToString();
                documentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Contract.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);
            }
        }
예제 #11
0
        public ProposalDetailInfo GetDetailProposalByCode(string code, string _userID)
        {
            ProposalDetailBase   proposalDetail = new ProposalDetailBase();
            SqlConnectionFactory sqlConnection  = new SqlConnectionFactory();
            ProposalDetailInfo   ret;

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                proposalDetail = ProposalDataLayer.GetInstance().getProposalDetailByCode(connection, code, _userID);
                if (proposalDetail == null)
                {
                    return(null);
                }
                ret             = new ProposalDetailInfo(proposalDetail);
                ret.ListComment = new List <CommentInfo>();

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Proposal.ToString();
                documentCriteria.PreferId  = proposalDetail.ProposalID.ToString();
                ret.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria);

                ret.Items = new List <ItemPropsalInfo>();
                ret.Items = ProposalDataLayer.GetInstance().GetPropsalItems(connection, proposalDetail.ProposalID);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Proposal.ToString();
                commentCriteria.PreferId  = proposalDetail.ProposalID.ToString();
                ret.ListComment           = CommentService.GetInstance().getComment(commentCriteria);
                foreach (var item in ret.ListComment)
                {
                    DocumentSeachCriteria documentCriteria2 = new DocumentSeachCriteria();
                    documentCriteria2.TableName = TableFile.Comment.ToString();
                    documentCriteria2.PreferId  = item.AutoID.ToString();
                    item.ListDocument           = DocumentService.GetInstance().GetDocument(documentCriteria2);
                }
            }
            return(ret);
        }
예제 #12
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);
            }
        }
예제 #13
0
        public QuoteInfo GetQuoteDetailsBycode(string code, string _userID)
        {
            QuoteInfo            record        = new QuoteInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = QuoteDataLayer.GetInstance().getQuoteByCode(connection, code, _userID);
                if (record == null)
                {
                    return(null);
                }

                record.ListComment = new List <CommentInfo>();

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Quote.ToString();
                documentCriteria.PreferId  = record.QuoteID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Items = new List <ItemInfo>();
                record.Items = QuoteDataLayer.GetInstance().GetQuoteItems(connection, record.QuoteID);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Quote.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 AuditDetailInfo getAuditInfo(int _ID, string _userID)
        {
            AuditDetailInfo      record        = new AuditDetailInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AuditDataLayer.GetInstance().getAudtiGeneralInfo(connection, _ID, _userID);
                if (record == null)
                {
                    return(null);
                }
                record.Quotes = getListQuoteInfos(_ID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Audit.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Employees = new List <AuditEmployeeInfo>();
                record.Employees = AuditDataLayer.GetInstance().GetAuditEmployeesById(connection, record.AuditID.ToString());

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Audit.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
        public List <CommentInfo> getComment(SqlConnection connection, CommentSeachCriteria _criteria)
        {
            var result = new List <CommentInfo>();

            using (var command = new SqlCommand("Select C.*, U.UserName  " +
                                                " from tbl_Comment C left join tbl_User U on C.UserI = U.UserID where 1 = 1 ", connection))
            {
                if (!string.IsNullOrEmpty(_criteria.TableName))
                {
                    command.CommandText += " and TableName = @TableName";
                    AddSqlParameter(command, "@TableName", _criteria.TableName, System.Data.SqlDbType.VarChar);
                }
                if (!string.IsNullOrEmpty(_criteria.PreferId))
                {
                    command.CommandText += " and PreferId = @PreferId";
                    AddSqlParameter(command, "@PreferId", _criteria.PreferId, System.Data.SqlDbType.Int);
                }
                command.CommandText += " order by InTime  ";
                WriteLogExecutingCommand(command);
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var info = new CommentInfo();
                        info.AutoID    = GetDbReaderValue <int>(reader["AutoID"]);
                        info.TableName = GetDbReaderValue <string>(reader["TableName"]);
                        info.PreferId  = GetDbReaderValue <int>(reader["PreferId"]).ToString();
                        info.Comment   = GetDbReaderValue <string>(reader["Comment"]);
                        info.UserI     = GetDbReaderValue <string>(reader["UserI"]);
                        info.UserName  = GetDbReaderValue <string>(reader["UserName"]);
                        info.Intime    = GetDbReaderValue <DateTime?>(reader["InTime"]);
                        result.Add(info);
                    }
                }
                return(result);
            }
        }
예제 #16
0
        public AcceptanceInfo GetDetail(int id, string _userID)
        {
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();
            AcceptanceInfo       record        = new AcceptanceInfo();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                record = AcceptanceDataLayer.GetInstance().GetDetail(connection, id, _userID);
                if (record == null)
                {
                    return(null);
                }
                record.ListComment = new List <CommentInfo>();

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Acceptance.ToString();
                documentCriteria.PreferId  = id.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Items = new List <DeliveryReceiptItemInfoNew>();
                record.Items = DeliveryReceiptDataLayer.GetInstance().getSelectedItems(connection, record.DeliveryReceiptID, _userID);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Acceptance.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);
        }
예제 #17
0
        public ExplanationDetailInfo getDetailExplanation(int _ID, string _userID)
        {
            ExplanationDetailInfo record        = new ExplanationDetailInfo();
            SqlConnectionFactory  sqlConnection = new SqlConnectionFactory();

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

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Explanation.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);

                record.Items = new List <ItemPropsalInfo>();
                record.Items = ProposalDataLayer.GetInstance().GetPropsalItems(connection, record.ProposalID);

                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Explanation.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);
            }
        }
예제 #18
0
        public DecisionInfo GetDecision(int _ID, string _userID)
        {
            DecisionInfo         record        = new DecisionInfo();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

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

                record.Items           = new List <ItemInfo>();
                record.Items           = QuoteDataLayer.GetInstance().getSelectedItemsQuote(connection, record.QuoteID);
                record.DepartmentNames = DepartmentDataLayer.GetInstance().GetDepartmentNamesFromQuote(connection, record.QuoteID);

                //Get document
                DocumentSeachCriteria documentCriteria = new DocumentSeachCriteria();
                documentCriteria.TableName = TableFile.Decision.ToString();
                documentCriteria.PreferId  = _ID.ToString();
                record.ListDocument        = DocumentService.GetInstance().GetDocument(documentCriteria);
                //get Comment
                CommentSeachCriteria commentCriteria = new CommentSeachCriteria();
                commentCriteria.TableName = TableFile.Decision.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);
        }
예제 #19
0
        public ActionMessage DeleteMuti(string ids, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Decision.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Decision.ToString(), ids);
                    //delete records
                    List <string> quoteID = DecisionDataLayer.GetInstance().GetQuoteByDecisionIds(connection, ids);
                    QuoteService.GetInstance().deleteProcess(connection, "Decision", String.Join(", ", quoteID.ToArray()), _userID);
                    DecisionDataLayer.GetInstance().DeleteMuti(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }
예제 #20
0
        public ActionMessage DeleteProposal(int id, string user, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    ProposalDetailInfo temp = ProposalService.GetInstance().getDetailProposal(id, "");

                    UserLogInfo info = new UserLogInfo();
                    info.Action = "Delete ";

                    if (temp != null)
                    {
                        info.Description = "code : " + temp.ProposalCode + " id : " + id;
                    }
                    else
                    {
                        info.Description = " id : " + id;
                    }
                    info.Feature  = TableFile.Proposal.ToString();
                    info.Time     = DateTime.Now;
                    info.UserName = user;
                    info.UserID   = 1;
                    UserService.GetInstance().TrackUserAction(info);

                    //delete Items Table
                    List <ItemPropsalInfo> currentItems = ProposalDataLayer.GetInstance().GetPropsalItems(connection, id);
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        ProposalDataLayer.GetInstance().DeleteProposalItems(connection, autoIds);
                    }


                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Proposal.ToString();
                    _criteria.PreferId  = id.ToString();
                    CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentByFeature(TableFile.Proposal.ToString(), id);

                    //deleteRelatedProsal
                    //             ..   var quoteIds = QuoteDataLayer.GetInstance().GetQuotesByProposalId(connection,id.ToString());
                    // if(quoteIds.Count > 0)
                    //                  QuoteService.DeleteMuti(String.Join(", ", quoteIds.ToArray()));


                    var surveyIds = SurveyDataLayer.GetInstance().GetSurveyByProposalId(connection, id.ToString());


                    if (surveyIds.Count > 0)
                    {
                        SurveyDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", surveyIds.ToArray()));
                    }

                    var explanationServiceIds = ExplanationDataLayer.GetInstance().GetExplanationsByProposalId(connection, id.ToString(), _userID);

                    if (explanationServiceIds.Count > 0)
                    {
                        ExplanationDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", explanationServiceIds.ToArray()));
                    }


                    //delete record
                    ProposalDataLayer.GetInstance().DeleteProposal(connection, id);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.ToString();
                }
            }
            return(ret);
        }
예제 #21
0
        public ActionMessage DeleteProposals(string ids, string user, string _userID)
        {
            ActionMessage ret  = new ActionMessage();
            UserLogInfo   info = new UserLogInfo();

            info.Action      = "Delete ";
            info.Description = " ids: " + ids;
            info.Feature     = TableFile.Proposal.ToString();
            info.Time        = DateTime.Now;
            info.UserName    = user;
            info.UserID      = 1;
            UserService.GetInstance().TrackUserAction(info);
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    //delete Items Table
                    List <ItemPropsalInfo> currentItems = ProposalDataLayer.GetInstance().GetPropsalItemsByIds(connection, ids);
                    if (currentItems.Count > 0)
                    {
                        string autoIds = "";
                        foreach (var item in currentItems)
                        {
                            autoIds = autoIds + item.AutoID + ',';
                        }
                        autoIds = autoIds.Remove(autoIds.Length - 1);
                        ProposalDataLayer.GetInstance().DeleteProposalItems(connection, autoIds);
                    }

                    //delete comments
                    CommentSeachCriteria _criteria = new CommentSeachCriteria();
                    _criteria.TableName = TableFile.Proposal.ToString();
                    string[] IDsarray = ids.Split(',');
                    foreach (string id in IDsarray)
                    {
                        _criteria.PreferId = id;
                        CommentDataLayer.GetInstance().DeleteComment(connection, _criteria);
                    }

                    //delete attach files and DB of attach files
                    DocumentService.GetInstance().DeleteDocumentsByFeature(TableFile.Proposal.ToString(), ids);
                    //delete records

                    /*  //deleteRelatedProsal
                     * var quoteIds = QuoteDataLayer.GetInstance().GetQuotesByProposalId(connection, ids);
                     *
                     * QuoteService.DeleteMuti(String.Join(", ", quoteIds.ToArray()));*/

                    var surveyIds = SurveyDataLayer.GetInstance().GetSurveyByProposalId(connection, ids);

                    if (surveyIds != null && surveyIds.Count > 0)
                    {
                        SurveyDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", surveyIds.ToArray()));
                    }

                    var explanationServiceIds = ExplanationDataLayer.GetInstance().GetExplanationsByProposalId(connection, ids, _userID);
                    if (explanationServiceIds != null && explanationServiceIds.Count > 0)
                    {
                        ExplanationDataLayer.GetInstance().DeleteMuti(connection, String.Join(", ", explanationServiceIds.ToArray()));
                    }


                    ProposalDataLayer.GetInstance().DeleteProposals(connection, ids);
                    ret.isSuccess = true;
                }
                catch (Exception ex)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "Internal Error";
                    ret.err.msgString = ex.Message;
                }
            }
            return(ret);
        }