Example #1
0
        public SingleResponeMessage <BidPlanInfo> Get(int id, string _userID)
        {
            SingleResponeMessage <BidPlanInfo> ret = new SingleResponeMessage <BidPlanInfo>();

            try
            {
                BidPlanInfo item = BidPlanService.GetInstance().getBidPlan(id, _userID);
                if (item == null)
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "001";
                    ret.err.msgString = "no BidPlan 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);
        }
Example #2
0
        public ListResponeMessage <BidPlanInfo> GetListWithCondition(
            string bidPlanCode,
            string quoteCode,
            int customerID,
            DateTime fromDate, DateTime toDate, string _userID, int pageSize = 10, int pageIndex = 0)
        {
            ListResponeMessage <BidPlanInfo> ret = new ListResponeMessage <BidPlanInfo>();

            try
            {
                BidPlanSeachCriteria _criteria = new BidPlanSeachCriteria();
                _criteria.BidPlanCode = bidPlanCode;
                _criteria.QuoteCode   = quoteCode;
                _criteria.CustomerID  = customerID;
                _criteria.FromDate    = fromDate;
                _criteria.ToDate      = toDate;
                _criteria.pageSize    = pageSize;
                _criteria.pageIndex   = pageIndex;

                ret.isSuccess    = true;
                ret.data         = BidPlanService.GetInstance().getAllBidPlan(pageSize, pageIndex, _criteria, _userID);
                ret.totalRecords = BidPlanService.GetInstance().getTotalRecords(_criteria, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "005";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Example #3
0
        public SingleResponeMessage <BidPlanInfo> GetByCode(string code)
        {
            SingleResponeMessage <BidPlanInfo> ret = new SingleResponeMessage <BidPlanInfo>();

            ret.isSuccess = true;
            ret.item      = BidPlanService.GetInstance().GetBidPlanByCode(code);
            return(ret);
        }
Example #4
0
        public ActionMessage DeleteAll(string bidPlanIDs, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = BidPlanService.GetInstance().DeleteMuti(bidPlanIDs, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Example #5
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] BidPlanInfo BidPlanObj, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = await BidPlanService.GetInstance().createBidPlan2(BidPlanObj, GetUserId(), files, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Example #6
0
        public ActionMessage Post([FromBody] BidPlanInfo _bidPlan)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = BidPlanService.GetInstance().createBidPlan(_bidPlan, GetUserId());
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Example #7
0
        public ListResponeMessage <string> getListBidPlanCode(string bidPlanCode = "")
        {
            ListResponeMessage <string> ret = new ListResponeMessage <string>();

            try
            {
                ret.isSuccess = true;
                ret.data      = BidPlanService.GetInstance().getListBidPlanCode(bidPlanCode);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
Example #8
0
        public async Task <ActionMessage> Put(int id, [FromForm] BidPlanInfo _BidPlan, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = await BidPlanService.GetInstance().editBidPlan(id, _BidPlan, GetUserId(), files, _userID);
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);

            //ActionMessage ret = new ActionMessage();
            //try
            //{
            //    ret = BidPlanService.GetInstance().editBidPlan(id, _BidPlan, getUserId(), files);
            //    //update list file
            //    //ProposalService.DelteDocument(id.ToString());
            //    foreach (var item in files)
            //    {
            //        DocumentInfo documentInfo = new DocumentInfo();
            //        documentInfo.TableName = "BidPlan";
            //        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("BidPlan", _BidPlan.ProposalID.ToString(), item, documentInfo.Link);
            //        DocumentService.InsertDocument(documentInfo, getUserId());
            //    }
            //}
            //catch (Exception ex)
            //{
            //    ret.isSuccess = false;
            //    ret.err.msgCode = "Internal Error !!!";
            //    ret.err.msgString = ex.ToString();
            //}
            //return ret;
        }
Example #9
0
        public static MemoryStream GetTemplate(int id, string path, out string code, string _userID)
        {
            double      Totalcost    = 0;
            var         memoryStream = new MemoryStream();
            BidPlanInfo item         = BidPlanService.GetInstance().getBidPlan(id, _userID);


            SearchAuditInfo audit = AuditService.GetInstance().GetAuditWordByQuoteID(item.QuoteID);

            using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
                fileStream.CopyTo(memoryStream);
            code = item.BidPlanCode;
            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;
                }
                if (item.IsVAT)
                {
                    Totalcost = Totalcost * (item.VATNumber + 100) / 100;
                }
                string auditCodeEmpty = "         /BB-BKG";
                if (audit.AuditCode == null || audit.AuditCode == "")
                {
                    audit.AuditCode = auditCodeEmpty;
                }
                List <string> row = new List <string>();
                row.Add("1");
                row.Add(item.BidName);

                row.Add(string.Format("{0:0,0}", Totalcost).Replace(",", ".") + " VNĐ");

                row.Add(WordUtils.checkNull(item.CapitalName));
                row.Add((HardData.bidMethod[item.BidMethod - 1]));
                row.Add(item.BidTime);
                row.Add(item.BidType);
                row.Add(item.BidExpirated + " " + item.BidExpiratedUnit);
                items.Add(row);

                Table tableData1 = CreateBidplan1(headers, items, string.Format("{0:0,0}", Totalcost).Replace(",", ".") + " VNĐ");
                Table tableData2 = CreateBidplan2(item, Totalcost);

                string dateInStr      = "";
                string auditDateInStr = "";
                dateInStr      = "ngày " + item.DateIn.Day + " tháng " + item.DateIn.Month + " năm " + item.DateIn.Year;
                auditDateInStr = "ngày " + audit.InTime.Day + " tháng " + audit.InTime.Month + " năm " + audit.InTime.Year;
                foreach (var text in body.Descendants <Text>())
                {
                    text.Text = text.Text.Replace("#", "");
                    text.Text = text.Text.Replace("bidcompany", WordUtils.checkNull(item.Bid));
                    text.Text = text.Text.Replace("bidplandatein", WordUtils.checkNull(dateInStr));
                    text.Text = text.Text.Replace("currentYear ", DateTime.Now.Year.ToString());
                    text.Text = text.Text.Replace("bidname", WordUtils.checkNull(item.BidName));
                    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("bidtime", WordUtils.checkNull(item.BidTime));
                    text.Text = text.Text.Replace("capname", WordUtils.checkNull(item.CapitalName));
                    text.Text = text.Text.Replace("bidcontracttype", WordUtils.checkNull(item.BidType));
                    text.Text = text.Text.Replace("bidExpirated", WordUtils.checkNull(item.BidExpirated + " " + item.BidExpiratedUnit));
                    text.Text = text.Text.Replace("bidmethod", WordUtils.checkNull(HardData.bidMethod[item.BidMethod - 1]));
                    text.Text = text.Text.Replace("auditdate", auditDateInStr);
                    text.Text = text.Text.Replace("auditcode", audit.AuditCode + "/BB-BKG");
                    text.Text = text.Text.Replace("location", WordUtils.checkNull(HardData.location[Int32.Parse(item.BidLocation) - 1]));
                    if (text.Text == "table1")
                    {
                        DocumentFormat.OpenXml.OpenXmlElement textP1 = text.Parent;
                        DocumentFormat.OpenXml.OpenXmlElement textP2 = textP1.Parent;
                        body.InsertAfter(tableData1, textP2);
                        textP1.Remove();
                    }
                    if (text.Text == "table2")
                    {
                        DocumentFormat.OpenXml.OpenXmlElement textP1 = text.Parent;
                        DocumentFormat.OpenXml.OpenXmlElement textP2 = textP1.Parent;
                        body.InsertAfter(tableData2, textP2);
                        textP1.Remove();
                    }
                }

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