Ejemplo n.º 1
0
        public ListResponeMessage <NegotiationInfo> GetListWithCondition(
            string negotiationCode,
            string quoteCode,
            int customerID,
            DateTime fromDate, DateTime toDate, int pageSize = 10, int pageIndex = 0, string _userID = "")
        {
            ListResponeMessage <NegotiationInfo> ret = new ListResponeMessage <NegotiationInfo>();

            try
            {
                NegotiationSeachCriteria _criteria = new NegotiationSeachCriteria();
                _criteria.QuoteCode       = quoteCode;
                _criteria.NegotiationCode = negotiationCode;
                _criteria.CustomerID      = customerID;
                _criteria.FromDate        = Helpers.Utils.StartOfDate(fromDate);
                _criteria.ToDate          = Helpers.Utils.EndOfDate(toDate);
                _criteria.pageSize        = pageSize;
                _criteria.pageIndex       = pageIndex;

                ret.isSuccess    = true;
                ret.data         = NegotiationService.GetInstance().getAllNegotiation(pageSize, pageIndex, _criteria, _userID);
                ret.totalRecords = NegotiationService.GetInstance().getTotalRecords(_criteria, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "005";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
 public NegotiationServiceTest()
 {
     _NegotiationService = new NegotiationService(
         new ValidationCollection(),
         new FakeNegotiationRepository(),
         new FakeProductRepository());
 }
Ejemplo n.º 6
0
        public SingleResponeMessage <NegotiationInfo> GetByCode(string code)
        {
            SingleResponeMessage <NegotiationInfo> ret = new SingleResponeMessage <NegotiationInfo>();

            ret.isSuccess = true;
            ret.item      = NegotiationService.GetInstance().GetNegotiationByCode(code);
            return(ret);
        }
Ejemplo n.º 7
0
        public ActionMessage DeleteAll(string negotiationIDs, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = NegotiationService.GetInstance().DeleteMuti(negotiationIDs, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public ListResponeMessage <NegotiationLstcb> GetListNegotiationByCode(string code = "")
        {
            ListResponeMessage <NegotiationLstcb> ret = new ListResponeMessage <NegotiationLstcb>();

            try
            {
                ret.isSuccess = true;
                ret.data      = NegotiationService.GetInstance().GetListNegotiationByCode(code);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Ejemplo n.º 11
0
        public static MemoryStream GetTemplate(int id, string path, out string code, string _userID)
        {
            double Totalcost           = 0;
            var    memoryStream        = new MemoryStream();
            NegotiationPrintModel item = NegotiationService.GetInstance().GetNegotiationPrintModel(id, _userID);

            code = item.NegotiationCode;
            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                fileStream.CopyTo(memoryStream);
            //  code = item.ProposalCode;
            using (var document = WordprocessingDocument.Open(memoryStream, true))
            {
                document.ChangeDocumentType(WordprocessingDocumentType.Document); // change from template to document
                DateTime date        = DateTime.Now;
                string   currentDate = " Ngày " + date.ToString("dd/MM/yyyy");
                var      body        = document.MainDocumentPart.Document.Body;
                var      paras       = body.Elements <Paragraph>();

                List <string>         headers = new List <string>();
                List <List <string> > items   = new List <List <string> >();
                headers.Add("STT");
                headers.Add("Tên gói thầu");
                headers.Add("Giá gói thầu");
                headers.Add("Nguồn vốn");
                headers.Add("Hình thức phương thức lựa chọn nhà thầu");
                headers.Add("Thời gian tổ chức lựa chọn nhà thầu");
                headers.Add("Loại hợp đồng");
                headers.Add("Thời gian thực hiện hợp đồng");

                foreach (ItemInfo record in item.Items)
                {
                    Totalcost += record.ItemPrice * record.Amount;
                }

                List <string> row = new List <string>();



                Table tableData = CreateTable(item, Totalcost);


                string dateInStr      = "";
                string auditDateInStr = "";
                dateInStr = item.DateIn.Hour + " giờ ";
                if (item.DateIn.Minute != 0)
                {
                    dateInStr += item.DateIn.Minute + " phút ";
                }
                dateInStr += ", ngày" + item.DateIn.Day + " tháng " + item.DateIn.Month + " năm " + item.DateIn.Year;
                //    auditDateInStr = "ngày " + item.AuditTime.Day + " tháng " + item.AuditTime.Month + " năm " + item.AuditTime.Year;
                foreach (var text in body.Descendants <Text>())
                {
                    text.Text = text.Text.Replace("#", "");
                    text.Text = text.Text.Replace("datein", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("audittime", WordUtils.checkNull(auditDateInStr));
                    text.Text = text.Text.Replace("inputcode", WordUtils.checkNull(item.Code));
                    //A side
                    text.Text = text.Text.Replace("aaddress", WordUtils.checkNull(HardData.location[Int32.Parse(item.ALocation) - 1]));
                    text.Text = text.Text.Replace("aside", WordUtils.checkNull(item.ASide));
                    text.Text = text.Text.Replace("aphone", WordUtils.checkNull(item.APhone));
                    text.Text = text.Text.Replace("arepresent", WordUtils.checkNull(item.ARepresent));
                    text.Text = text.Text.Replace("afax", WordUtils.checkNull(item.AFax));
                    text.Text = text.Text.Replace("aposition", WordUtils.checkNull(item.APosition));
                    text.Text = text.Text.Replace("ataxcode", WordUtils.checkNull(item.ATaxCode));
                    text.Text = text.Text.Replace("abankidlabel", WordUtils.checkNull(HardData.NegotiationBankIDArr[Int32.Parse(item.ABankID) - 1]));
                    //B side
                    text.Text = text.Text.Replace("baddress", WordUtils.checkNull(item.BLocation));
                    text.Text = text.Text.Replace("bside", WordUtils.checkNull(item.BSide));
                    text.Text = text.Text.Replace("bphone", WordUtils.checkNull(item.BPhone));
                    text.Text = text.Text.Replace("brepresent", WordUtils.checkNull(item.BRepresent));
                    text.Text = text.Text.Replace("bfax", WordUtils.checkNull(item.BFax));
                    text.Text = text.Text.Replace("bposition", WordUtils.checkNull(item.BPosition));
                    text.Text = text.Text.Replace("btaxcode", WordUtils.checkNull(item.BTaxCode));
                    text.Text = text.Text.Replace("bbankidlabel", WordUtils.checkNull(item.BBankID));

                    text.Text = text.Text.Replace("costnumber", string.Format("{0:0,0}", Totalcost).Replace(",", "."));
                    text.Text = text.Text.Replace("coststring", WordUtils.checkNull(Utils.NumberToTextVN((decimal)Totalcost)));
                    text.Text = text.Text.Replace("bidtype", item.BidType);
                    text.Text = text.Text.Replace("term", WordUtils.checkNull(item.Term.ToString()));
                    text.Text = text.Text.Replace("bidtime", item.BidExpirated + " " + item.BidExpiratedUnit);
                    if (text.Text == "table")
                    {
                        DocumentFormat.OpenXml.OpenXmlElement textP1 = text.Parent;
                        DocumentFormat.OpenXml.OpenXmlElement textP2 = textP1.Parent;
                        body.InsertAfter(tableData, textP2);
                        textP1.Remove();
                    }
                }

                document.Save();
                document.Close();
            }
            return(memoryStream);
        }