コード例 #1
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true);

        this.Gv_List.DataSource = kpOrder.KPItems;
        this.ExportXLS(this.Gv_List, "KPOrder" + DateTime.Now.ToString("ddhhmmss") + ".xls");
    }
コード例 #2
0
ファイル: KPOrderMgr.cs プロジェクト: Novthirteen/yfkey-scms
        public KPOrder LoadKPOrder(decimal orderId, bool includeDetail)
        {
            KPOrder kpOrder = this.LoadKPOrder(orderId);

            if (includeDetail && kpOrder.KPItems != null && kpOrder.KPItems.Count > 0)
            {
            }

            return(kpOrder);
        }
コード例 #3
0
ファイル: RepBillMgr.cs プロジェクト: Novthirteen/yfkey-scms
        public override IList <object> GetDataList(string code)
        {
            IList <object> list    = new List <object>();
            KPOrder        kpOrder = kpOrderMgr.LoadKPOrder(decimal.Parse(code), true);

            if (kpOrder != null)
            {
                list.Add(kpOrder);
                list.Add(kpOrder.KPItems);
            }
            return(list);
        }
コード例 #4
0
 protected void btnRejectInvoice_Click(object sender, EventArgs e)
 {
     try
     {
         KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true);
         kpOrder.InvoiceStatus = BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_REJECTED;
         //if (kpOrder.CLN_ORDER != null)
         //    UnBindSP(kpOrder);
         TheKPOrderMgr.UpdateKPOrder(kpOrder);
         this.ShowSuccessMessage("MasterData.Bill.RejectInvoice.Successful");
         UpdateView();
     }
     catch (BusinessErrorException ex)
     {
         ShowErrorMessage(ex);
     }
 }
コード例 #5
0
    protected void UnBindSP(KPOrder kpOrder)
    {
        string[] cln_order = kpOrder.CLN_ORDER.Split(new char[] { ',' });

        foreach (string orderno in cln_order)
        {
            KPOrder ko = TheKPOrderMgr.LoadKPOrder(decimal.Parse(orderno));
            if (ko != null)
            {
                ko.CLN_ORDER = null;

                TheKPOrderMgr.UpdateKPOrder(ko);
            }
        }
        kpOrder.CLN_ORDER  = null;
        kpOrder.CLN_amount = 0;
        TheKPOrderMgr.UpdateKPOrder(kpOrder);
    }
コード例 #6
0
    private void CreateFile(KPOrder kpOrder)
    {
        //随便写写,谁叫他们不给钱的
        #region 抽取数据导入文件
        string   fileFolder = "D:\\Dss\\out\\";
        string   fileName   = "SCONIT_QAD_" + DateTime.Now.ToString("yyyyMMddhhmmss") + "_KPCONF.REQ";
        string[] line1      = new string[]
        {
            "1",
            kpOrder.QAD_ORDER_ID,
            DateTime.Now.ToShortDateString()
        };

        string[][]     data           = new string[][] { line1 };
        StreamWriter   streamWriter   = new StreamWriter(fileFolder + fileName, false, Encoding.GetEncoding(Encoding.Default.WebName));
        FlatFileWriter flatFileWriter = new FlatFileWriter(streamWriter, Environment.NewLine, "|");
        flatFileWriter.Write(data);
        flatFileWriter.Dispose();
        #endregion
    }
コード例 #7
0
    protected void btnSubmitInvoice_Click(object sender, EventArgs e)
    {
        try
        {
            KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true);

            decimal invoiceAmountWithoutTax = Convert.ToDecimal(tbInvoiceAmountWithoutTax.Text.Trim());
            if (kpOrder.CLN_ORDER == null)
            {
                process(kpOrder);
            }

            #region 只校验不含税金额
            if (System.Math.Abs(kpOrder.TotalAmount - invoiceAmountWithoutTax - kpOrder.CLN_amount) > 1)
            {
                ShowErrorMessage("MasterData.Bill.InvoiceAmountWithoutTax.AmountMustLessThanOne");
                return;
            }

            #endregion

            kpOrder.InvoiceCount = Convert.ToInt32(tbInvoceCount.Text.Trim());

            kpOrder.InvoiceDate             = DateTime.Parse(tbInvoiceDate.Text.Trim());
            kpOrder.InvoiceNumber           = tbInvoiceNumber.Text.Trim();
            kpOrder.InvoiceRemark           = tbInvoiceRemark.Text.Trim();
            kpOrder.InvoiceTax              = tbInvoiceTax.Text.Trim();
            kpOrder.InvoiceAmountWithoutTax = invoiceAmountWithoutTax;

            kpOrder.InvoiceAmount = Convert.ToDecimal(tbInvoiceAmount.Text.Trim());
            kpOrder.InvoiceStatus = BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_INPROCESS;
            TheKPOrderMgr.UpdateKPOrder(kpOrder);
            this.ShowSuccessMessage("MasterData.Bill.SubmitInvoice.Successful");
            UpdateView();
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
    }
コード例 #8
0
    public void InitPageParameter(decimal orderId)
    {
        this.OrderId = orderId;
        KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(orderId, true);

        this.tbOrderId.Text = kpOrder.QAD_ORDER_ID;
        if (kpOrder.InvoiceStatus == null)
        {
            process(kpOrder);
        }
        //this.tbTotalAmount.Text = kpOrder.TotalAmount.ToString("0.########");
        //  this.tbTotalAmount.Text = (kpOrder.TotalAmount - kpOrder.CLN_amount).ToString("0.########");
        if (kpOrder.ORDER_PUB_DATE != null)
        {
            this.tbCreateDate.Text = ((DateTime)kpOrder.ORDER_PUB_DATE).ToString("yyyy-MM-dd");
        }

        UpdateView();

        this.Gv_List.DataSource = kpOrder.KPItems;
        this.Gv_List.DataBind();
    }
コード例 #9
0
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            KPOrder        kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true);
            IList <object> list    = new List <object>();
            if (kpOrder != null)
            {
                list.Add(kpOrder);
                list.Add(kpOrder.KPItems);
            }

            string barCodeUrl = "";
            //测试
            //if (kpOrder.SYS_CODE == "YK")
            //{
            //    barCodeUrl = WriteToFile("Bill_BJ.xls", list);
            //}
            if (kpOrder.SYS_CODE == "YK")
            {
                barCodeUrl = TheReportMgr.WriteToFile("Bill.xls", list);
            }
            if (kpOrder.SYS_CODE == "BJ")
            {
                barCodeUrl = WriteToFile("Bill_BJ.xls", list);
            }
            Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>");

            kpOrder.ORDER_PRINT       = "Y";
            kpOrder.PRINT_MODIFY_DATE = DateTime.Now;
            TheKPOrderMgr.UpdateKPOrder(kpOrder);

            this.ShowSuccessMessage("MasterData.Bill.Print.Successful");
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
    }
コード例 #10
0
 protected void process(KPOrder kpOrder)
 {
     if (string.IsNullOrEmpty(kpOrder.CLN_ORDER) &&
         kpOrder.ORDER_TYPE_ID == "KP")
     {
         DetachedCriteria clnorder = DetachedCriteria.For <KPOrder>()
                                     .Add(Expression.Eq("ORDER_TYPE_ID", "SP"))
                                     .Add(Expression.IsNull("CLN_ORDER"))
                                     .Add(Expression.Eq("PARTY_FROM_ID", kpOrder.PARTY_FROM_ID))
                                     .Add(Expression.Eq("SYS_CODE", kpOrder.SYS_CODE));
         IList <KPOrder> kpcln = TheCriteriaMgr.FindAll <KPOrder>(clnorder);
         if (kpcln != null && kpcln.Count > 0)
         {
             decimal?tempamount      = 0;
             decimal offsetamount    = 0;
             decimal tempOrderAmount = kpOrder.TotalAmount;
             string  _clnorder       = string.Empty;
             // tempamount = kpOrder.InvoiceAmountWithoutTax;
             foreach (KPOrder kp in kpcln)
             {
                 tempamount = kp.TotalAmount;
                 if (tempamount.HasValue)
                 {
                     if (tempOrderAmount - tempamount > 0)
                     {
                         _clnorder    += kp.ORDER_ID.ToString() + ",";
                         kp.CLN_ORDER  = kpOrder.ORDER_ID.ToString();
                         offsetamount += (decimal)tempamount;
                         TheKPOrderMgr.UpdateKPOrder(kp);
                     }
                 }
             }
             //kpOrder.InvoiceAmountWithoutTax += offsetamount;
             kpOrder.CLN_amount = offsetamount;
             kpOrder.CLN_ORDER  = _clnorder.Trim(new char[] { ',' });
             TheKPOrderMgr.UpdateKPOrder(kpOrder);
         }
     }
 }
コード例 #11
0
ファイル: RepBillMgr.cs プロジェクト: Novthirteen/yfkey-scms
        /**
         * 填充报表
         *
         * Param list [0]OrderHead
         * Param list [0]IList<OrderDetail>
         */
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                KPOrder        kpOrder = (KPOrder)(list[0]);
                IList <KPItem> kpItems = (IList <KPItem>)(list[1]);


                if (kpOrder == null ||
                    kpItems == null || kpItems.Count == 0)
                {
                    return(false);
                }

                this.CopyPage(kpItems.Count);

                this.FillHead(kpOrder);

                int     pageIndex  = 1;
                int     rowIndex   = 0;
                int     rowTotal   = 0;
                decimal totalPrice = 0;
                foreach (KPItem kpItem in kpItems)
                {
                    //采购单
                    this.SetRowCell(pageIndex, rowIndex, 0, kpItem.PURCHASE_ORDER_ID);
                    //零件号
                    this.SetRowCell(pageIndex, rowIndex, 1, kpItem.PART_CODE);
                    //入库单号
                    this.SetRowCell(pageIndex, rowIndex, 2, kpItem.INCOMING_ORDER_ID);
                    //序号
                    this.SetRowCell(pageIndex, rowIndex, 3, kpItem.SEQ_ID);
                    //入库数量
                    if (kpItem.INCOMING_QTY != null)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 4, ((decimal)kpItem.INCOMING_QTY).ToString("0.########"));
                    }
                    //采购单价
                    if (kpItem.PRICE != null)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 5, ((decimal)kpItem.PRICE).ToString("0.########"));
                    }
                    //单位
                    this.SetRowCell(pageIndex, rowIndex, 6, kpItem.UM);
                    //发票单价
                    if (kpItem.PRICE1 != null)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 7, ((decimal)kpItem.PRICE1).ToString("0.########"));
                    }
                    //发票单价 @金额
                    if (kpItem.PRICE1 != null)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 8, ((decimal)kpItem.PRICE2).ToString("0.########"));
                        totalPrice += (decimal)kpItem.PRICE2;
                    }
                    //零件名称
                    this.SetRowCell(pageIndex, rowIndex, 9, kpItem.PART_NAME);

                    //送货单号
                    this.SetRowCell(pageIndex, rowIndex, 10, kpItem.DELIVER_ORDER_ID);

                    //入库日期
                    if (kpItem.INCOMING_DATE != null)
                    {
                        this.SetRowCell(pageIndex, rowIndex, 11, ((DateTime)kpItem.INCOMING_DATE).ToString("yyyy-MM-dd"));
                    }

                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        //合计发票金额:
                        this.SetRowCell(pageIndex, this.pageDetailRowCount, 10, totalPrice.ToString("0.########"));
                        rowIndex = 0;
                        pageIndex++;
                        totalPrice = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
コード例 #12
0
ファイル: RepBillMgr.cs プロジェクト: Novthirteen/yfkey-scms
 /*
  * 填充报表头
  *
  * Param repack 报验单头对象
  */
 private void FillHead(KPOrder kpOrder)
 {
     this.SetRowCell(8, 2, kpOrder.PARTY_FROM_ID);
     this.SetRowCell(8, 10, kpOrder.QAD_ORDER_ID);
 }
コード例 #13
0
 public virtual void DeleteKPOrder(KPOrder entity)
 {
     entityDao.DeleteKPOrder(entity);
 }
コード例 #14
0
 public virtual void UpdateKPOrder(KPOrder entity)
 {
     entityDao.UpdateKPOrder(entity);
 }
コード例 #15
0
 public virtual void CreateKPOrder(KPOrder entity)
 {
     entityDao.CreateKPOrder(entity);
 }
コード例 #16
0
 public virtual void DeleteKPOrder(KPOrder entity)
 {
     Delete(entity);
 }
コード例 #17
0
 public virtual void UpdateKPOrder(KPOrder entity)
 {
     Update(entity);
 }
コード例 #18
0
 public virtual void CreateKPOrder(KPOrder entity)
 {
     Create(entity);
 }
コード例 #19
0
    public override void UpdateView()
    {
        KPOrder kpOrder = TheKPOrderMgr.LoadKPOrder(this.OrderId, true);

        this.tbInvoceCount.Text             = kpOrder.InvoiceCount.ToString();
        this.tbInvoiceAmount.Text           = kpOrder.InvoiceAmount.ToString("F2");
        this.tbInvoiceDate.Text             = kpOrder.InvoiceDate.ToString();
        this.tbInvoiceNumber.Text           = kpOrder.InvoiceNumber;
        this.tbInvoiceRemark.Text           = kpOrder.InvoiceRemark;
        this.tbInvoiceTax.Text              = Convert.ToDecimal(kpOrder.InvoiceTax).ToString("F2");
        this.tbInvoiceAmountWithoutTax.Text = kpOrder.InvoiceAmountWithoutTax.ToString("F2");
        this.tbTotalAmount.Text             = (kpOrder.TotalAmount - kpOrder.CLN_amount).ToString("0.########");
        this.tbCln.Text = kpOrder.CLN_ORDER;
        div_inv.Visible = true;
        if (kpOrder.ORDER_TYPE_ID == "SP")
        {
            this.btnSubmitInvoice.Visible           = false;
            this.btnRejectInvoice.Visible           = false;
            this.btnApproveInvoice.Visible          = false;
            this.tbInvoceCount.ReadOnly             = false;
            this.tbInvoiceAmountWithoutTax.ReadOnly = false;
            this.tbInvoiceDate.ReadOnly             = false;
            this.tbInvoiceNumber.ReadOnly           = false;
            this.tbInvoiceRemark.ReadOnly           = false;
            this.tbInvoiceTax.ReadOnly = false;
            this.lblCln.Text           = "绑定账单:";
            div_inv.Visible            = false;
        }

        else if (kpOrder.InvoiceStatus == null || kpOrder.InvoiceStatus == string.Empty ||
                 kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_REJECTED)
        {
            this.btnSubmitInvoice.Visible  = true;
            this.btnRejectInvoice.Visible  = false;
            this.btnApproveInvoice.Visible = false;

            this.tbInvoceCount.ReadOnly             = false;
            this.tbInvoiceAmountWithoutTax.ReadOnly = false;
            this.tbInvoiceDate.ReadOnly             = false;
            this.tbInvoiceNumber.ReadOnly           = false;
            this.tbInvoiceRemark.ReadOnly           = false;
            this.tbInvoiceTax.ReadOnly = false;

            this.tbInvoiceTax.Attributes["onchange"] += "calculate();";
            this.tbInvoiceAmountWithoutTax.Attributes["onchange"] += "calculate();";
        }
        else if (kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_INPROCESS)
        {
            this.btnSubmitInvoice.Visible  = false;
            this.btnRejectInvoice.Visible  = true;
            this.btnApproveInvoice.Visible = true;

            this.tbInvoceCount.ReadOnly             = true;
            this.tbInvoiceAmountWithoutTax.ReadOnly = true;
            this.tbInvoiceDate.ReadOnly             = true;
            this.tbInvoiceNumber.ReadOnly           = true;
            this.tbInvoiceRemark.ReadOnly           = true;
            this.tbInvoiceTax.ReadOnly = true;
        }
        else if (kpOrder.InvoiceStatus == BusinessConstants.CODE_MASTER_INVOICE_STATUS_VALUE_APPROVED)
        {
            this.btnSubmitInvoice.Visible  = false;
            this.btnRejectInvoice.Visible  = false;
            this.btnApproveInvoice.Visible = false;

            this.tbInvoceCount.ReadOnly             = true;
            this.tbInvoiceAmountWithoutTax.ReadOnly = true;
            this.tbInvoiceDate.ReadOnly             = true;
            this.tbInvoiceNumber.ReadOnly           = true;
            this.tbInvoiceRemark.ReadOnly           = true;
            this.tbInvoiceTax.ReadOnly = true;
        }
    }
コード例 #20
0
    public string WriteToFile(string template, IList <object> list)
    {
        string path = Server.MapPath(".") + @"\Reports\Templates\YFKExcelTemplates\" + template;

        if (File.Exists(path))
        {
            KPOrder kpOrder  = (KPOrder)list[0];
            string  filename = @"/Reports/Templates/TempFiles/temp_" + DateTime.Now.ToString("yyyyMMddhhmmss") + kpOrder.ORDER_ID + ".xls";
            string  _wpath   = Server.MapPath(".") + filename;
            File.Copy(path, _wpath);
            FileStream   file             = new FileStream(_wpath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            HSSFWorkbook hssfworkbook     = new HSSFWorkbook(file);
            Sheet        sheet            = hssfworkbook.GetSheet("sheet1");
            CellStyle    normalLeftStyle  = setCellstyle(hssfworkbook, new string[] { "Border", "Left" });
            CellStyle    normalRightStyle = setCellstyle(hssfworkbook, new string[] { "Border", "Right" });
            CellStyle    NoneLeftStyle    = setCellstyle(hssfworkbook, new string[] { "BorderNone", "Left" });
            CellStyle    NoneRightStyle   = setCellstyle(hssfworkbook, new string[] { "BorderNone", "Right" });
            CellStyle    dateStyle        = setCellstyle(hssfworkbook, new string[] { "Border", "Left", "DateTime" });
            Cell         cell             = sheet.GetRow(8).GetCell(2);
            cell.SetCellValue(kpOrder.PARTY_FROM_ID);
            cell = sheet.GetRow(8).GetCell(10);
            cell.SetCellValue(kpOrder.QAD_ORDER_ID);
            int     i   = 10;
            decimal cnt = 0;

            foreach (KPItem kpitem in kpOrder.KPItems)
            {
                Row row = sheet.CreateRow(i);
                row.CreateCell(0).SetCellValue(kpitem.PURCHASE_ORDER_ID);        //采购单
                row.GetCell(0).CellStyle = normalLeftStyle;
                row.CreateCell(1).SetCellValue(kpitem.PART_CODE);                //零件号
                row.GetCell(1).CellStyle = normalLeftStyle;
                row.CreateCell(2).SetCellValue(kpitem.INCOMING_ORDER_ID);        //入库单号
                row.GetCell(2).CellStyle = normalLeftStyle;
                row.CreateCell(3).SetCellValue(kpitem.SEQ_ID);                   //序号
                row.GetCell(3).CellStyle = normalLeftStyle;
                row.CreateCell(4).SetCellValue((double)kpitem.INCOMING_QTY);     //入库数量
                row.GetCell(4).CellStyle = normalLeftStyle;
                row.CreateCell(5).SetCellValue((double)kpitem.PRICE);            //采购单价
                row.GetCell(5).CellStyle = normalRightStyle;
                row.CreateCell(6).SetCellValue(kpitem.UM);                       //单位
                row.GetCell(6).CellStyle = normalRightStyle;
                row.CreateCell(7).SetCellValue((double)kpitem.PRICE1);           //发票单价
                row.GetCell(7).CellStyle = normalRightStyle;
                row.CreateCell(8).SetCellValue(kpitem.PRICE2.ToString());        //发票单价@金额
                row.GetCell(8).CellStyle = normalRightStyle;
                row.CreateCell(9).SetCellValue(kpitem.PART_NAME);                //零件名称
                row.GetCell(9).CellStyle = normalLeftStyle;
                row.CreateCell(10).SetCellValue(kpitem.DELIVER_ORDER_ID);        //送货单号
                row.GetCell(10).CellStyle = normalLeftStyle;
                row.CreateCell(11).SetCellValue((DateTime)kpitem.INCOMING_DATE); //入库日期
                row.GetCell(11).CellStyle = dateStyle;

                cnt = (decimal)kpitem.PRICE2 + cnt;

                i++;
            }

            Row _row = sheet.CreateRow(i);
            _row.CreateCell(1).SetCellValue("采购员:");
            _row.CreateCell(6).SetCellValue("主管:");
            _row.CreateCell(9).SetCellValue("合计发票金额:");
            _row.CreateCell(10).SetCellValue(cnt.ToString());
            _row.GetCell(1).CellStyle  = NoneRightStyle;
            _row.GetCell(6).CellStyle  = NoneRightStyle;
            _row.GetCell(9).CellStyle  = NoneRightStyle;
            _row.GetCell(10).CellStyle = NoneLeftStyle;

            MemoryStream ms = new MemoryStream();
            hssfworkbook.Write(ms);

            FileStream f    = new FileStream(_wpath, FileMode.Open, FileAccess.Write);
            byte[]     data = ms.ToArray();
            f.Write(data, 0, data.Length);
            f.Close();
            f.Dispose();
            hssfworkbook = null;
            ms.Close();
            ms.Dispose();
            return("http://" + Request.Url.Authority + filename);
        }

        return("");
    }