Ejemplo n.º 1
0
    /// <summary>
    /// 运单导出
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnExport_Click(object sender, EventArgs e)
    {
        TransportationBill tb = TheTransportationBillMgr.LoadTransportationBill(this.BillNo, true);
        IList <TransportationBillDetail> detail = tb.TransportationBillDetails;

        getExcel(tb, detail, true);
    }
Ejemplo n.º 2
0
    protected void lbtnDelete_Click(object sender, EventArgs e)
    {
        string billNo = ((com.Sconit.Control.LinkButton)sender).CommandArgument;

        try
        {
            TheTransportationBillMgr.DeleteTransportationBill(billNo, this.CurrentUser);
            ShowSuccessMessage("MasterData.Bill.DeleteSuccessfully", billNo);
            UpdateView();
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 3
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        try
        {
            IList <TransportationActBill> transportationActBillList = this.ucNewList.PopulateSelectedData();
            IList <TransportationBill>    transportationBillList    = TheTransportationBillMgr.CreateTransportationBill(transportationActBillList, this.CurrentUser);
            this.ShowSuccessMessage("Transportation.TransportationBill.CreateSuccessfully", transportationBillList[0].BillNo);

            if (this.IsRelease.Checked)
            {
                TheTransportationBillMgr.ReleaseTransportationBill(transportationBillList[0].BillNo, this.CurrentUser);
                this.ShowSuccessMessage("Transportation.TransportationBill.ReleaseSuccessfully", transportationBillList[0].BillNo);
            }
            this.PageCleanUp();
            CreateEvent(transportationBillList[0].BillNo, null);
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 4
0
    protected void CostCenterCal()
    {
        CostString  = string.Empty;
        ErrorString = string.Empty;
        // string billno = ((com.Sconit.Control.ReadonlyTextBox)(FV_TransportationBill.FindControl("tbBillNo"))).Text;
        string billno = this.BillNo;

        if (billno != string.Empty)
        {
            #region Sql语句
            StringBuilder cc = new StringBuilder();
            cc.Append("select c.orderno,sum(vol) as V,plant,tactbill.billedqty*tactbill.unitprice as cost1,min(tbilldet.amount) as cost from " +
                      "(select a.orderno,orderdet.packvol,qty,orderdet.packvol*qty as vol,item.plant  from (" +
                      "select orderloctransid,ipdet.ipno,sum(abs(qty)) as  QTY ,orderno " +
                      "from torderdet  join ipdet on torderdet.ipno=ipdet.ipno " +
                      "where orderno in(" +
                      "select tordermstr.orderno from tactbill " +
                      "left join tordermstr  on tactbill.orderno=tordermstr.orderno " +
                      "where id in(" +
                      "select distinct transid from tbillmstr  join tbilldet on tbillmstr.billno=tbilldet.billno ");
            cc.Append(
                "where tbillmstr.billno='" + billno + "'))" +
                "group by orderloctransid,ipdet.ipno,orderno    ) a " +
                "left join orderloctrans on a.orderloctransid=id " +
                "left join orderdet on orderdet.id=orderloctrans.orderdetid " +
                "left join item on item.code=orderdet.item " +
                ") c  left join tactbill on c.orderno=tactbill.orderno left join tbilldet on transid=tactbill.id and tbilldet.billno='" + billno + "' " +
                "group by c.orderno,plant,tactbill.billedqty,tactbill.unitprice,tactbill.id " +
                " having   min(tbilldet.amount) is not null " +
                "order by c.orderno");
            #endregion
            string        sql    = cc.ToString();
            XmlTextReader reader = new XmlTextReader(Server.MapPath("Config/properties.config"));
            XmlDocument   doc    = new XmlDocument();
            doc.Load(reader); //
            reader.Close();   //
            string  ConnString = doc.SelectSingleNode("/configuration/properties/connectionString").InnerText.Trim();
            DataSet result     = SqlHelper.ExecuteDataset(ConnString, CommandType.Text, sql);
            Dictionary <string, decimal> orderTotal = new Dictionary <string, decimal>();
            Dictionary <string, decimal> plantcost  = new Dictionary <string, decimal>();
            Dictionary <string, string>  error      = new Dictionary <string, string>();
            Dictionary <string, string>  noplant    = new Dictionary <string, string>();
            // Dictionary<string, decimal> lxcost = new Dictionary<string, decimal>();
            Dictionary <string, string> filter = new Dictionary <string, string>();
            #region 处理常规的
            foreach (DataRow i in result.Tables[0].Rows)
            {
                if (error.ContainsKey(i["orderno"].ToString()) || noplant.ContainsKey(i["orderno"].ToString()))
                {
                    continue;
                }
                if (i["V"].ToString() == "")
                {
                    error.Add(i["orderno"].ToString(), "");
                    continue;
                }
                if (i["plant"].ToString() == "")
                {
                    noplant.Add(i["orderno"].ToString(), "");
                    continue;
                }
                if (orderTotal.ContainsKey(i["orderno"].ToString()) == false)
                {
                    orderTotal.Add(i["orderno"].ToString(), decimal.Parse(i["V"].ToString()));
                }
                else
                {
                    orderTotal[i["orderno"].ToString()] = orderTotal[i["orderno"].ToString()] + decimal.Parse(i["V"].ToString());
                }
            }
            foreach (DataRow i in result.Tables[0].Rows)
            {
                if (error.ContainsKey(i["orderno"].ToString()) || noplant.ContainsKey(i["orderno"].ToString()))
                {
                    continue;
                }
                decimal cost = decimal.Parse(i["V"].ToString()) / orderTotal[i["orderno"].ToString()] * decimal.Parse(i["cost"].ToString());
                cost = Math.Round(cost, 2);
                if (plantcost.ContainsKey(mappingCC(i["plant"].ToString())) == false)
                {
                    plantcost.Add(mappingCC(i["plant"].ToString()), cost);
                }
                else
                {
                    plantcost[mappingCC(i["plant"].ToString())] = plantcost[mappingCC(i["plant"].ToString())] + cost;
                }
            }
            #endregion
            #region 零星运单
            StringBuilder lxsb = new StringBuilder();
            lxsb.Append("select tordermstr.orderno,torderdet.ipno,expense from tordermstr left join torderdet on tordermstr.orderno=torderdet.orderno  " +
                        "where tordermstr.orderno in (" +
                        "select distinct  tordermstr.orderno from tactbill " +
                        "left join tordermstr  on tactbill.orderno=tordermstr.orderno " +
                        "where id in( " +
                        "select distinct transid from tbillmstr  join tbilldet on tbillmstr.billno=tbilldet.billno " +
                        "where tbillmstr.billno='" + billno + "')) " +
                        "and   (left(ipno,1)='W' or expense is not null)");

            string  lxsql = lxsb.ToString();
            DataSet lxdt  = SqlHelper.ExecuteDataset(ConnString, CommandType.Text, lxsql);
            foreach (DataRow r in lxdt.Tables[0].Rows)
            {
                TransportationOrder to = TheTransportationOrderMgr.LoadTransportationOrder(r["orderno"].ToString(), true);
                IList <TransportationOrderDetail> tods = to.OrderDetails;
                if (tods.Count == 0)
                {
                    string        wfcon   = @"Data Source=192.168.210.190\SQL2005;Initial Catalog=EPROCESS;Persist Security Info=true;User ID=sa;PWD=temp100;Packet Size=4096;";
                    string        sqltext = "select esportran_costsrc+'_'+cast(esportran_totalcost as nvarchar(50)) from  dbo.eSporadicTran_mstr where esportran_nbr='" + r["expense"].ToString() + "'";
                    SqlConnection con     = new SqlConnection(wfcon);
                    SqlCommand    cmd     = new SqlCommand(sqltext, con);
                    object        obj     = null;
                    try
                    {
                        con.Open();
                        obj = cmd.ExecuteScalar();
                        con.Close();
                    }
                    catch
                    {
                        con.Close();
                    }
                    if (obj != null)
                    {
                        string _obj = obj.ToString();
                        if (_obj.StartsWith("AR"))
                        {
                            string  obj_cc = _obj.Split(new char[] { '_' })[0].Substring(3);
                            decimal cost   = decimal.Parse(_obj.Split(new char[] { '_' })[1]);
                            if (plantcost.ContainsKey(obj_cc))
                            {
                                plantcost[obj_cc] = plantcost[obj_cc] + Math.Round(cost, 2);
                            }
                            else
                            {
                                plantcost.Add(obj_cc, Math.Round(cost, 2));
                            }
                        }
                        if (_obj.StartsWith("CC"))
                        {
                            string  obj_cc = mappingCC(_obj.Substring(3, 4)).Trim();
                            decimal cost   = decimal.Parse(_obj.Split(new char[] { '_' })[1]);
                            if (plantcost.ContainsKey(obj_cc))
                            {
                                plantcost[obj_cc] = plantcost[obj_cc] + Math.Round(cost, 2);
                            }
                            else
                            {
                                plantcost.Add(obj_cc, Math.Round(cost, 2));
                            }
                        }
                    }
                    continue;
                }
                #endregion

                if (tods != null)
                {
                    var l = (from i in tods where i.InProcessLocation.IpNo.Substring(0, 1) == "W" select i).ToList();
                    if (l != null && l.Count == tods.Count)
                    {
                        if (filter.ContainsKey(r["orderno"].ToString()) == true)
                        {
                            continue;
                        }
                        filter.Add(r["orderno"].ToString(), r["ipno"].ToString());
                        InProcessLocation ip             = TheInProcessLocationMgr.LoadInProcessLocation(r["ipno"].ToString());
                        string            orderAmountsql = "select top 1 BilledAmount from tactbill where orderno='" + r["orderno"].ToString() + "' order by lastmodifydate desc ";//and status='Close'
                        SqlConnection     ordercon       = new SqlConnection(ConnString);
                        SqlCommand        ordercmd       = new SqlCommand(orderAmountsql, ordercon);
                        object            amount         = null;
                        try
                        {
                            ordercon.Open();
                            amount = ordercmd.ExecuteScalar();
                            ordercon.Close();
                        }
                        catch
                        {
                            ordercon.Close();
                        }
                        string ip_cc = mappingCC(ip.HuTemplate);
                        if (amount != null)
                        {
                            if (plantcost.ContainsKey(ip_cc))
                            {
                                plantcost[ip_cc] = plantcost[ip_cc] + Math.Round(decimal.Parse(amount.ToString()), 2);
                            }
                            else
                            {
                                plantcost.Add(ip_cc, Math.Round(decimal.Parse(amount.ToString()), 2));
                            }
                        }
                    }
                }
            }


            var disacct = TheCarrierMgr.LoadCarrier(TheTransportationBillMgr.LoadTransportationBill(BillNo).BillAddress.Party.Code).TradeTerm;

            int di = 0;
            if (string.IsNullOrEmpty(disacct))
            {
                disacct = "0";
            }
            foreach (KeyValuePair <string, decimal> key in plantcost)
            {
                decimal tax = 0;
                if (disacct.StartsWith("$"))
                {
                    tax = Math.Round(key.Value / (1 + decimal.Parse(disacct.Substring(1)) * (decimal)0.01) * decimal.Parse(disacct.Substring(1)) * (decimal)0.01, 2);
                }
                else
                {
                    tax = Math.Round(key.Value * (decimal.Parse(disacct) * (decimal)0.01), 2);
                }
                decimal outTax = key.Value - tax;
                TaxTotal    += tax;
                OutTaxTotal += outTax;
                if (di % 2 == 0)
                {
                    CostString += "<tr style='background-color:white;text-align:center'><td>" + key.Key + "</td><td>" + mappingAcc(key.Key) + "</td><td>" + outTax + "</td><td>" + tax + "</td></tr>";
                }

                if (di % 2 == 1)
                {
                    CostString += "<tr style='background-color:#DAD6C5;text-align:center'><td>" + key.Key + "</td><td>" + mappingAcc(key.Key) + "</td><td>" + outTax + "</td><td>" + tax + "</td></tr>";
                }
                // CostString += key.Key + ":" + key.Value + "<br/>";
                di++;
            }
            if (error.Count > 0)
            {
                ErrorString = "以下运单货物存在未设置体积不予计算:<br/>";
            }
            foreach (KeyValuePair <string, string> key in error)
            {
                ErrorString += key.Key + "<br/>";
            }
            if (noplant.Count > 0)
            {
                ErrorString += "以下运单中含有为设置工厂的零件不予计算:<br/>";
            }
            foreach (KeyValuePair <string, string> key in noplant)
            {
                ErrorString += key.Key + "<br/>";
            }
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 文件上传 taskno:181695
    /// djin 2013-9-2
    /// </summary>
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        HSSFWorkbook excel = new HSSFWorkbook(fileUpload.PostedFile.InputStream);
        Sheet        sheet = excel.GetSheetAt(0);
        IEnumerator  rows  = sheet.GetRowEnumerator();

        //Row custrow = sheet.GetRow(2);
        // string sup = custrow.GetCell(1).StringCellValue;//客户代码
        //Supplier su = TheSupplierMgr.LoadSupplier(sup);
        //Row row_startdate = sheet.GetRow(3);
        //string startdate = row_startdate.GetCell(1).StringCellValue;//开始日期
        //Row row_enddate = sheet.GetRow(4);
        //string enddate = row_enddate.GetCell(1).StringCellValue;//结束日期
        //startdate = startdate == string.Empty ? DateTime.Now.AddMonths(-1).ToShortDateString() : startdate;
        //enddate = enddate == string.Empty ? DateTime.Now.ToShortDateString() : enddate;
        ImportHelper.JumpRows(rows, 1);
        IList <TransportationActBill> tactbillList = new List <TransportationActBill>();
        Hashtable th     = new Hashtable();
        string    supply = string.Empty;

        while (rows.MoveNext())
        {
            Row    curow     = (HSSFRow)rows.Current;
            string shiporder = curow.GetCell(0).StringCellValue;
            if (th.ContainsKey(shiporder))
            {
                continue;                           //避免重复
            }
            // decimal cur = decimal.Parse(curow.GetCell(1).NumericCellValue.ToString());
            if (shiporder != string.Empty)
            {
                IList <TransportationActBill> tactbill = TheTransportationActBillMgr.GetTransportationActBill(shiporder);

                if (tactbill.Count > 0)
                {
                    foreach (TransportationActBill tbill in tactbill)
                    {
                        if (!string.IsNullOrEmpty(supply))
                        {
                            if (tbill.BillAddress.Party.Code != supply)
                            {
                                ShowErrorMessage("行" + curow.RowNum.ToString() + "供应商的代码不一致!");
                                return;
                            }
                        }
                        else
                        {
                            supply = tbill.BillAddress.Party.Code;
                        }
                        if (tbill.Status == "Create")
                        {
                            tbill.CurrentBillQty    = tbill.BillQty - tbill.BilledQty;
                            tbill.CurrentBillAmount = tbill.CurrentBillQty * tbill.UnitPrice;
                            tactbillList.Add(tbill);
                        }
                    }
                }
                else
                {
                    ShowErrorMessage("行" + curow.RowNum.ToString() + "还没有计价!");
                    return;
                }
            }
            else
            {
                ShowErrorMessage("行" + curow.RowNum.ToString() + "无运单号!");
                return;
            }
        }
        if (tactbillList.Count > 0)
        {
            try
            {
                IList <TransportationBill> transportationBillList = TheTransportationBillMgr.CreateTransportationBill(tactbillList, this.CurrentUser);
                if (transportationBillList != null && transportationBillList.Count > 0)
                {
                    ExportResult(transportationBillList);
                    btnBack_Click(sender, e);
                }
            }
            catch (BusinessErrorException ex)
            {
                ShowErrorMessage(ex);
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex.Message);
            }
        }
        else
        {
            ShowErrorMessage("账单创建失败!");
        }
    }