Пример #1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     PostVO postVO = new PostVO();
     postVO.Title = txtTitle.Text.Trim();
     postVO.SortNo = int.Parse(txtSortNo.Text.Trim());
     postVO.Node = m_PostService.GetNodeById(m_NodeId);
     postVO.PicFileName = m_PicFileName;
     postVO.Flag = int.Parse(ddlFlag.SelectedValue);
     postVO.ShowDate = DateTime.Today;
     //if (!string.IsNullOrEmpty(txtShowDate.Text.Trim()))
     //{
     //    postVO.ShowDate = DateTime.Parse(txtShowDate.Text.Trim());
     //}
     postVO.LinkUrl = txtLinkUrl.Text.Trim();
     if (!string.IsNullOrEmpty(txtLinkUrl.Text.Trim()))
     {
         postVO.Type = 1;
     }
     else
     {
         postVO.Type = 0;
     }
     m_PostService.CreatePost(postVO);
     m_WebLogService.AddSystemLog(MsgVO.Action.新增, postVO);
     ClearUI();
     fillGridView();
 }
Пример #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DateTime date;

        if (DateTime.TryParse(txtDate.Text.Trim(), out date))
        {
            NodeVO nodeSpecial = m_PostService.GetNodeByName("#特別現金收支");

            PostVO postVO = new PostVO();
            postVO.Node = nodeSpecial;
            postVO.CloseDate = date;
            postVO.Title = txtTitle.Text.Trim();
            postVO.Type = int.Parse(ddlType.SelectedValue);
            if (postVO.Type == 1)
            {
                postVO.Price = -1 * (int.Parse(txtPrice.Text.Trim()));
            }
            else
            {
                postVO.Price = (int.Parse(txtPrice.Text.Trim()));
            }
            m_PostService.CreatePost(postVO);

            UIHelper.ClearUI(pnlSpecialToday);
            ddlType.SelectedValue = "";
            LoadDataToUI();
        }

        else
        {
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "js", JavascriptUtil.AlertJS("日期格式錯誤!"), false);
            return;
        }
    }
Пример #3
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     PostVO postVO = new PostVO();
     UIHelper.FillVO(pnlContent, postVO);
     postVO.Node = m_PostService.GetNodeById(m_NodeId);
     //postVO.PicFileName = m_PicFileName;
     postVO.Flag = 1;
     postVO.NeedUpdate = true;
     postVO.CreatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
     postVO.UpdatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
     postVO.CreatedDate = DateTime.Now;
     postVO.UpdatedDate = DateTime.Now;
     //if (!string.IsNullOrEmpty(txtShowDate.Text.Trim()))
     //{
     //    postVO.ShowDate = DateTime.Parse(txtShowDate.Text.Trim());
     //}
     //if (!string.IsNullOrEmpty(txtCloseDate.Text.Trim()))
     //{
     //    postVO.ShowDate = DateTime.Parse(txtCloseDate.Text.Trim());
     //}
     m_PostService.CreatePost(postVO);
     m_WebLogService.AddSystemLog(MsgVO.Action.新增, postVO);
     new Thread(new ThreadStart(() => ApiUtil.UpdatePostToServer(2))).Start();
     ClearUI();
     fillGridView();
 }
Пример #4
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     PostVO postVO = new PostVO();
     UIHelper.FillVO(pnlContent, postVO);
     postVO.Node = m_PostService.GetNodeById(m_NodeId);
     m_PostService.CreatePost(postVO);
     m_WebLogService.AddSystemLog(MsgVO.Action.新增, postVO);
     ClearUI();
     fillGridView();
 }
Пример #5
0
 public PostDto(PostVO postVO)
 {
     this.PostId            = postVO.PostId;
     this.PicFileName       = postVO.PicFileName;
     this.PicFileName2      = postVO.PicFileName2;
     this.DocFileName       = postVO.DocFileName;
     this.SortNo            = postVO.SortNo;
     this.Flag              = postVO.Flag;
     this.Quantity          = postVO.Quantity;
     this.ShowDate          = postVO.ShowDate;
     this.CloseDate         = postVO.CloseDate;
     this.Type              = postVO.Type;
     this.LinkUrl           = postVO.LinkUrl;
     this.IsRecommend       = postVO.IsRecommend;
     this.Price             = postVO.Price;
     this.SellPrice         = postVO.SellPrice;
     this.IsTemp            = postVO.IsTemp;
     this.CustomField1      = postVO.CustomField1;
     this.CustomField2      = postVO.CustomField2;
     this.MemberName        = postVO.MemberName;
     this.MemberPhone       = postVO.MemberPhone;
     this.ProductSer        = postVO.ProductSer;
     this.WarrantySuppliers = postVO.WarrantySuppliers;
     this.Wholesalers       = postVO.Wholesalers;
     this.MemberId          = string.IsNullOrEmpty(postVO.MemberId) ? "" : "Y";
     this.Store             = postVO.Store;
     this.Title             = postVO.Title;
     this.Summary           = postVO.Summary;
     this.HtmlContent       = postVO.HtmlContent;
     this.KeyWord           = postVO.KeyWord;
     this.UpdateId          = postVO.UpdateId;
     this.ServerId          = postVO.ServerId;
     this.NeedUpdate        = postVO.NeedUpdate;
     this.CreatedBy         = postVO.CreatedBy;
     this.UpdatedBy         = postVO.UpdatedBy;
     this.CreatedDate       = postVO.CreatedDate;
     this.UpdatedDate       = postVO.UpdatedDate;
 }
Пример #6
0
 public PostDto(PostVO postVO)
 {
     this.PostId = postVO.PostId;
     this.PicFileName = postVO.PicFileName;
     this.PicFileName2 = postVO.PicFileName2;
     this.DocFileName = postVO.DocFileName;
     this.SortNo = postVO.SortNo;
     this.Flag = postVO.Flag;
     this.Quantity = postVO.Quantity;
     this.ShowDate = postVO.ShowDate;
     this.CloseDate = postVO.CloseDate;
     this.Type = postVO.Type;
     this.LinkUrl = postVO.LinkUrl;
     this.IsRecommend = postVO.IsRecommend;
     this.Price = postVO.Price;
     this.SellPrice = postVO.SellPrice;
     this.IsTemp = postVO.IsTemp;
     this.CustomField1 = postVO.CustomField1;
     this.CustomField2 = postVO.CustomField2;
     this.MemberName = postVO.MemberName;
     this.MemberPhone = postVO.MemberPhone;
     this.ProductSer = postVO.ProductSer;
     this.WarrantySuppliers = postVO.WarrantySuppliers;
     this.Wholesalers = postVO.Wholesalers;
     this.MemberId = string.IsNullOrEmpty(postVO.MemberId) ? "" : "Y";
     this.Store = postVO.Store;
     this.Title = postVO.Title;
     this.Summary = postVO.Summary;
     this.HtmlContent = postVO.HtmlContent;
     this.KeyWord = postVO.KeyWord;
     this.UpdateId = postVO.UpdateId;
     this.ServerId = postVO.ServerId;
     this.NeedUpdate = postVO.NeedUpdate;
     this.CreatedBy = postVO.CreatedBy;
     this.UpdatedBy = postVO.UpdatedBy;
     this.CreatedDate = postVO.CreatedDate;
     this.UpdatedDate = postVO.UpdatedDate;
 }
        public void UpdateCashByPeriod(DateTime dateFrom, DateTime dateTo)
        {
            m_Log.Debug("UpdateCashByPeriod dateFrom: " + dateFrom.ToString("yyyy/MM/dd"));
            m_Log.Debug("UpdateCashByPeriod dateTo: " + dateTo.ToString("yyyy/MM/dd"));
            NodeVO node = PostService.GetNodeByName("#每日結帳");

            for (DateTime day = dateFrom; day.Date <= dateTo; day = day.AddDays(1))
            {
                m_Log.Debug("UpdateCashByPeriod day: " + day.ToString("yyyy/MM/dd"));
                CashStatisticsVO cashStatisticsVO = GetCashStatisticsVO(day);

                if (cashStatisticsVO != null)
                {
                    //找出有沒有這天的舊的結帳資料,有的話刪除
                    Dictionary<string, string> conditionsOldCash = new Dictionary<string, string>();
                    conditionsOldCash.Add("Flag", "1");
                    conditionsOldCash.Add("NodeId", node.NodeId.ToString());
                    conditionsOldCash.Add("CloseDate", day.ToString("yyyy/MM/dd"));
                    conditionsOldCash.Add("PageIndex", "0");
                    conditionsOldCash.Add("PageSize", "1");

                    IList<PostVO> cashList = PostService.GetPostList(conditionsOldCash);
                    if (cashList != null && cashList.Count > 0)
                    {
                        PostService.DeletePost(cashList[0]);
                    }

                    PostVO post = new PostVO();
                    post.Node = node;
                    post.Title = "每日結帳";
                    post.CreatedBy = "admin";
                    post.UpdatedBy = "admin";
                    post.CloseDate = cashStatisticsVO.CloseDate;
                    post.Price = cashStatisticsVO.CashToday;

                    PostService.CreatePost(post);
                }
            }
        }
        private void FixTimeZone(PostVO postVO)
        {
            int addHours = m_ConfigHelper.AddHours;

            if (postVO.ShowDate.HasValue)
            {
                postVO.ShowDate = postVO.ShowDate.Value.AddHours(addHours);
            }

            if (postVO.CloseDate.HasValue)
            {
                postVO.CloseDate = postVO.CloseDate.Value.AddHours(addHours);
            }
        }
        // POST api/<controller>
        public HttpResponseMessage Post(PostDto postDto)
        {
            if (postDto != null)
            {
                try
                {
                    PostVO postVO = null;
                    //檢查是否有ServerId 有的話把狀態改成刪除, 重新建立一筆
                    if (postDto.ServerId != 0)
                    {
                        PostVO oldPostVO = m_PostService.GetPostById(postDto.ServerId);
                        if (oldPostVO != null)
                        {
                            oldPostVO.NeedUpdate = false;
                            oldPostVO.Flag = 0;
                            oldPostVO.UpdateId = "系統API";
                            m_PostService.UpdatePost(oldPostVO);
                        }
                    }

                    postVO = new PostVO(postDto);
                    postVO.Node = m_PostService.GetNodeById(2);
                    postVO.PostId = 0;
                    postVO.ServerId = 0;
                    postVO.NeedUpdate = false;
                    postVO.UpdateId = "系統API";
                    FixTimeZone(postVO);

                    //有memberId 就要用Ser去查Server的Member
                    if (!string.IsNullOrWhiteSpace(postDto.MemberId) && !string.IsNullOrWhiteSpace(postDto.ProductSer))
                    {
                        Dictionary<string, string> conditions = new Dictionary<string, string>();
                        conditions.Add("Status", "1");
                        conditions.Add("KeyWord", postDto.ProductSer);
                        conditions.Add("Store", postDto.Store);

                        IList<MemberVO> memberList = m_MemberService.GetMemberList(conditions);
                        if (memberList != null && memberList.Count > 0 && postDto.ProductSer.Equals(memberList[0].PhoneSer))
                        {
                            postVO.MemberId = memberList[0].MemberId.ToString();
                        }
                        else
                        {
                            postVO.MemberId = "";
                        }
                    }

                    postVO = m_PostService.CreatePost(postVO);
                    postVO.ServerId = postVO.PostId;

                    return Request.CreateResponse<PostDto>(HttpStatusCode.Created, new PostDto(postVO));
                }
                catch (Exception ex)
                {
                    return Request.CreateResponse(HttpStatusCode.NoContent, ex.ToString());
                }
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.NoContent);
            }
        }
Пример #10
0
 /// <summary>
 /// 新增Post
 /// </summary>
 /// <param name="postVO">被新增的Post</param>
 /// <returns>新增後的Post</returns>
 public PostVO CreatePost(PostVO postVO)
 {
     postVO = PostDao.CreatePost(postVO);
     if (postVO.SortNo == 0)
     {
         postVO.SortNo = postVO.PostId;
         postVO = PostDao.UpdatePost(postVO);
     }
     return postVO;
 }
Пример #11
0
 /// <summary>
 /// 刪除Post
 /// </summary>
 /// <param name="postVO">被刪除的Post</param>
 public void DeletePost(PostVO postVO)
 {
     NHibernateDao.Delete(postVO);
 }
Пример #12
0
    public string GetDefaultHeadMeta(PostVO postVO)
    {
        StringBuilder sb = new StringBuilder();

        //設定預設
        PostVO defaultMetaVO = m_PostService.GetPostById(m_DefaultMetaPostId);
        string title = defaultMetaVO.PageTitle;
        string description = defaultMetaVO.PageDescription;
        string keyWord = defaultMetaVO.PageKeyWord;

        //傳入的Post,有值的話就替換
        if (postVO != null)
        {
            if (!string.IsNullOrEmpty(postVO.PageTitle))
            {
                title = postVO.PageTitle;
            }
            else
            {
                title = string.Format("{0} - {1}", GetContent(postVO, "Title"), defaultMetaVO.PageTitle);
            }

            if (!string.IsNullOrEmpty(postVO.PageDescription))
            {
                description = postVO.PageDescription;
            }

            if (!string.IsNullOrEmpty(postVO.PageKeyWord))
            {
                keyWord = postVO.PageKeyWord;
            }
        }

        if (!string.IsNullOrEmpty(title))
        {
            sb.Append(string.Format("<title>{0}</title>", title));
        }

        if (!string.IsNullOrEmpty(description))
        {
            sb.Append(string.Format("<META NAME=\"Description\" CONTENT=\"{0}\">", description));
        }

        if (!string.IsNullOrEmpty(keyWord))
        {
            sb.Append(string.Format("<META NAME=\"KeyWords\" CONTENT=\"{0}\">", keyWord));
        }

        return sb.ToString();
    }
        private PostVO CreatePost(string title, NodeVO nodeVO, int sort, string linkUrl, string picFileName)
        {
            PostVO postVO = new PostVO();
            postVO.Node = nodeVO;
            postVO.Title = title;
            postVO.SortNo = sort;
            postVO.Flag = 1;
            postVO.CreatedBy = "admin";
            postVO.UpdatedBy = "admin";
            postVO.CreatedDate = DateTime.Now;
            postVO.UpdatedDate = DateTime.Now;
            postVO.ShowDate = DateTime.Today;
            postVO.LinkUrl = linkUrl;
            postVO.PicFileName = picFileName;

            return m_PostService.CreatePost(postVO);
        }
        private PostVO CreatePost(string title, NodeVO nodeVO, int sort, int type, string warrantySuppliers, string customField1, string customField2, string summary, string content)
        {
            PostVO postVO = new PostVO();
            postVO.Node = nodeVO;
            postVO.Title = title;
            postVO.SortNo = sort;
            postVO.Type = type;
            postVO.WarrantySuppliers = warrantySuppliers;
            postVO.CustomField1 = customField1;
            postVO.CustomField2 = customField2;
            postVO.Summary = summary;
            postVO.HtmlContent = content;
            postVO.Flag = 1;
            postVO.CreatedBy = "admin";
            postVO.UpdatedBy = "admin";
            postVO.CreatedDate = DateTime.Now;
            postVO.UpdatedDate = DateTime.Now;
            postVO.ShowDate = DateTime.Today;

            return m_PostService.CreatePost(postVO);
        }
        private PostVO CreatePost(string title, NodeVO nodeVO, int sort)
        {
            PostVO postVO = new PostVO();
            postVO.Node = nodeVO;
            postVO.Title = title;
            postVO.SortNo = sort;
            postVO.Flag = 1;
            postVO.CreatedBy = "admin";
            postVO.UpdatedBy = "admin";
            postVO.CreatedDate = DateTime.Now;
            postVO.UpdatedDate = DateTime.Now;
            postVO.ShowDate = DateTime.Today;

            return m_PostService.CreatePost(postVO);
        }
Пример #16
0
 /// <summary>
 /// 刪除Post
 /// </summary>
 /// <param name="postVO">被刪除的Post</param>
 public void DeletePost(PostVO postVO)
 {
     PostDao.DeletePost(postVO);
 }
Пример #17
0
        /// <summary>
        /// 新增Post
        /// </summary>
        /// <param name="postVO">被新增的Post</param>
        /// <returns>新增後的Post</returns>
        public PostVO CreatePost(PostVO postVO)
        {
            NHibernateDao.Insert(postVO);

            return postVO;
        }
Пример #18
0
 /// <summary>
 /// 更新Post
 /// </summary>
 /// <param name="postVO">被更新的Post</param>
 /// <returns>更新後的Post</returns>
 public PostVO UpdatePost(PostVO postVO)
 {
     return PostDao.UpdatePost(postVO);
 }
Пример #19
0
        /// <summary>
        /// 更新Post
        /// </summary>
        /// <param name="postVO">被更新的Post</param>
        /// <returns>更新後的Post</returns>
        public PostVO UpdatePost(PostVO postVO)
        {
            NHibernateDao.Update(postVO);

            return postVO;
        }
Пример #20
0
    protected void btnSold_Click(object sender, EventArgs e)
    {
        try
        {
            PostVO postVO = m_PostService.GetPostById(m_Mode);

            //判斷數量大於1就另外增加一筆新的
            if (postVO.Quantity > 1)
            {
                PostVO newPostVO = new PostVO();
                UIHelper.FillVO(pnlContent, newPostVO);
                newPostVO.Node = postVO.Node;
                newPostVO.Quantity = 1;
                newPostVO.Type = 1;
                newPostVO.NeedUpdate = true;
                newPostVO.CreatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
                newPostVO.UpdatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
                newPostVO.CreatedDate = DateTime.Now;
                newPostVO.UpdatedDate = DateTime.Now;
                m_PostService.CreatePost(newPostVO);
                m_WebLogService.AddSystemLog(MsgVO.Action.售出, postVO, "", string.Format("單號:{0}", postVO.PostId));

                postVO.Quantity -= 1;
                postVO.NeedUpdate = true;
                postVO.UpdatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
                postVO.UpdatedDate = DateTime.Now;
                m_PostService.UpdatePost(postVO);
                new Thread(new ThreadStart(() => ApiUtil.UpdatePostToServer(2))).Start();
                fillGridView();
                ClearUI();
                ShowMode();
            }
            else
            {
                UIHelper.FillVO(pnlContent, postVO);
                postVO.Type = 1;
                postVO.NeedUpdate = true;
                postVO.UpdatedBy = m_SessionHelper.LoginUser.FullNameInChinese;
                postVO.UpdatedDate = DateTime.Now;
                m_PostService.UpdatePost(postVO);
                m_WebLogService.AddSystemLog(MsgVO.Action.售出, postVO, "", string.Format("單號:{0}", postVO.PostId));
                new Thread(new ThreadStart(() => ApiUtil.UpdatePostToServer(2))).Start();
                fillGridView();
                ClearUI();
                ShowMode();
            }
        }
        catch (Exception ex)
        {
            m_Log.Error(ex);
            lblMsg.Text = ex.ToString();
        }
    }