Beispiel #1
0
    protected void bt_Approve_Click(object sender, EventArgs e)
    {
        int           ID          = ViewState["ID"] != null && int.TryParse(ViewState["ID"].ToString(), out ID) ? ID : 0;
        CM_VehicleBLL _VehicleBLL = new CM_VehicleBLL(ID);

        if (ID == 0 || _VehicleBLL.Model == null | _VehicleBLL.Model.ApproveFlag == 1)
        {
            MessageBox.Show(Page, "审核失败");
            return;
        }


        CM_WareHouseBLL _WareHouseBLL = new CM_WareHouseBLL();

        _WareHouseBLL.Model.Client        = (int)Session["OwnerClient"];
        _WareHouseBLL.Model.Code          = _VehicleBLL.Model.VehicleNo;
        _WareHouseBLL.Model.Name          = _VehicleBLL.Model.VehicleNo + "-仓库";
        _WareHouseBLL.Model.OfficialCity  = new CM_ClientBLL((int)Session["OwnerClient"]).Model.OfficialCity;
        _WareHouseBLL.Model.Classify      = 3;  //车仓库
        _WareHouseBLL.Model.RelateVehicle = ID;
        _WareHouseBLL.Model.ActiveState   = 1;
        _WareHouseBLL.Model.InsertStaff   = (int)Session["UserID"];
        int warehouse = _WareHouseBLL.Add();

        if (warehouse > 0)
        {
            _VehicleBLL.Model.RelateWareHouse = warehouse;
            _VehicleBLL.Model.ApproveFlag     = 1;
            _VehicleBLL.Model.UpdateStaff     = (int)Session["UserID"];
            _VehicleBLL.Update();
            MessageBox.ShowAndRedirect(this, "审核成功!", "VehicleList.aspx");
        }
    }
    protected void bt_Approve_Click(object sender, EventArgs e)
    {
        int ID = ViewState["ID"] != null && int.TryParse(ViewState["ID"].ToString(), out ID) ? ID : 0;
        CM_VehicleBLL _VehicleBLL = new CM_VehicleBLL(ID);
        if (ID == 0 || _VehicleBLL.Model == null | _VehicleBLL.Model.ApproveFlag == 1)
        {
            MessageBox.Show(Page, "审核失败");
            return;
        }

        CM_WareHouseBLL _WareHouseBLL = new CM_WareHouseBLL();
        _WareHouseBLL.Model.Client = (int)Session["OwnerClient"];
        _WareHouseBLL.Model.Code = _VehicleBLL.Model.VehicleNo;
        _WareHouseBLL.Model.Name = _VehicleBLL.Model.VehicleNo + "-仓库";
        _WareHouseBLL.Model.OfficialCity = new CM_ClientBLL((int)Session["OwnerClient"]).Model.OfficialCity;
        _WareHouseBLL.Model.Classify = 3;       //车仓库
        _WareHouseBLL.Model.RelateVehicle = ID;
        _WareHouseBLL.Model.ActiveState = 1;
        _WareHouseBLL.Model.InsertStaff = (int)Session["UserID"];
        int warehouse = _WareHouseBLL.Add();

        if (warehouse > 0)
        {
            _VehicleBLL.Model.RelateWareHouse = warehouse;
            _VehicleBLL.Model.ApproveFlag = 1;
            _VehicleBLL.Model.UpdateStaff = (int)Session["UserID"];
            _VehicleBLL.Update();
            MessageBox.ShowAndRedirect(this, "审核成功!", "VehicleList.aspx");
        }
    }
    private void BindDropDown()
    {
        ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1);
        ddl_SupplierWareHouse.DataBind();

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1");
        ddl_Salesman.DataBind();
        ddl_Salesman.Items.Insert(0, new ListItem("请选择", "0"));
    }
    private void BindDropDown()
    {
        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.ID IN (SELECT SalesMan FROM MCS_PBM.dbo.PBM_Delivery WHERE Supplier=" + Session["OwnerClient"].ToString() +
                                                            " AND InsertTime>DATEADD(MONTH,-6,GETDATE()) ) AND Org_Staff.Dimission = 1");
        ddl_Salesman.DataBind();
        ddl_Salesman.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_DeliveryMan.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Dimission=1");
        ddl_DeliveryMan.DataBind();
        ddl_DeliveryMan.Items.Insert(0, new ListItem("请选择", "0"));

        ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
        ddl_SupplierWareHouse.DataBind();
    }
    private void BindData()
    {
        CM_WareHouse m = new CM_WareHouseBLL((int)ViewState["ID"]).Model;

        if (m != null)
        {
            if (m.Client != (int)Session["OwnerClient"])
            {
                Response.Redirect("~/SubModule/Desktop.aspx");
            }

            pl_detail.BindData(m);
        }
    }
    private void BindDropDown()
    {
        ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
        ddl_SupplierWareHouse.DataBind();
        ddl_SupplierWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
        ddl_ClientWareHouse.DataBind();
        ddl_ClientWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString());
        ddl_Salesman.DataBind();
        ddl_Salesman.SelectedValue = Session["UserID"].ToString();
    }
Beispiel #7
0
        private void FillModel(CM_Vehicle m)
        {
            if (m == null)
            {
                return;
            }

            ID              = m.ID;
            VehicleNo       = m.VehicleNo;
            RelateStaff     = m.RelateStaff;
            RelateWareHouse = m.RelateWareHouse;

            if (RelateStaff != 0)
            {
                Org_Staff s = new Org_StaffBLL(RelateStaff).Model;
                if (s != null)
                {
                    RelateStaffName = s.RealName;
                }
            }

            if (RelateWareHouse != 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(RelateWareHouse).Model;
                if (w != null)
                {
                    RelateWareHouseName = w.Name;
                }
            }

            #region 获取字典表名称
            try
            {
                if (m.VehicleClassify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("CM_VehicleClassify")[m.VehicleClassify.ToString()];
                    if (dic != null)
                    {
                        VehicleClassifyName = dic.Name;
                    }
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Vehicle", err);
            }
            #endregion
        }
    private void BindDropDown()
    {
        ddl_Supplier.DataSource = CM_ClientBLL.GetSupplierByTDP((int)Session["OwnerClient"]).OrderBy(p => p.FullName);
        ddl_Supplier.DataBind();

        CM_Client _c = new CM_ClientBLL((int)Session["OwnerClient"]).Model;

        if (_c != null && ddl_Supplier.Items.FindByValue(_c.OwnerClient.ToString()) != null)
        {
            ddl_Supplier.SelectedValue = _c.OwnerClient.ToString();
        }

        ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1);
        ddl_ClientWareHouse.DataBind();

        ddl_Salesman.DataSource = Org_StaffBLL.GetStaffList("Org_Staff.OwnerClient=" + Session["OwnerClient"].ToString() + " AND Org_Staff.Dimission=1");
        ddl_Salesman.DataBind();
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_WareHouseBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new CM_WareHouseBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new CM_WareHouseBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
                Response.Redirect("WareHouseList.aspx");
            }
        }
        else
        {
            //新增
            _bll.Model.Client      = (int)Session["OwnerClient"];
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 1;
            ViewState["ID"]        = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                MessageBox.ShowAndRedirect(this, "新增成功!", "WareHouseList.aspx");
            }
        }
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_WareHouseBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new CM_WareHouseBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new CM_WareHouseBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            if (_bll.Update() == 0)
            {
                Response.Redirect("WareHouseList.aspx");
            }
        }
        else
        {
            //新增
            _bll.Model.Client = (int)Session["OwnerClient"];
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 1;
            ViewState["ID"] = _bll.Add();
            if ((int)ViewState["ID"] > 0)
            {
                MessageBox.ShowAndRedirect(this, "新增成功!", "WareHouseList.aspx");
            }
        }
    }
    protected void ddl_Classify_SelectedIndexChanged(object sender, EventArgs e)
    {
        switch (ddl_Classify.SelectedValue)
        {
        case "3":       //仓库间调拨
            ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify != 3);
            ddl_SupplierWareHouse.DataBind();
            ddl_SupplierWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

            ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify != 3);
            ddl_ClientWareHouse.DataBind();
            ddl_ClientWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));
            break;

        case "5":       //车销移库单
            ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify != 3);
            ddl_SupplierWareHouse.DataBind();
            ddl_SupplierWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

            ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 3);
            ddl_ClientWareHouse.DataBind();
            ddl_ClientWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));
            break;

        case "6":       //车销退库单
            ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 3);
            ddl_SupplierWareHouse.DataBind();
            ddl_SupplierWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));

            ddl_ClientWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify != 3);
            ddl_ClientWareHouse.DataBind();
            ddl_ClientWareHouse.Items.Insert(0, new ListItem("请选择...", "0"));
            break;

        default:
            break;
        }
    }
    protected void ddl_DeliveryVehicle_SelectedIndexChanged(object sender, EventArgs e)
    {
        int vehicle = 0;

        int.TryParse(ddl_DeliveryVehicle.SelectedValue, out vehicle);

        if (vehicle != 0)
        {
            CM_VehicleBLL v = new CM_VehicleBLL(vehicle);
            CM_WareHouse  w = v.GetRelateWareHouse();

            ddl_SupplierWareHouse.Items.Clear();
            if (w != null)
            {
                ddl_SupplierWareHouse.Items.Add(new ListItem(w.Name, w.ID.ToString()));
            }
        }
        else
        {
            ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]).Where(p => p.Classify == 1);
            ddl_SupplierWareHouse.DataBind();
        }
    }
Beispiel #13
0
        private void FillModel(int DeliveryID)
        {
            PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID);
            if (bll.Model == null) { ID = -1; return; }

            PBM_Delivery m = bll.Model;
            ID = m.ID;
            SheetCode = m.SheetCode;
            Supplier = m.Supplier;
            SupplierWareHouse = m.SupplierWareHouse;
            ClientWareHouse = m.ClientWareHouse;
            Client = m.Client;
            SalesMan = m.SalesMan;
            DeliveryMan = m.DeliveryMan;
            Classify = m.Classify;
            PrepareMode = m.PrepareMode;
            State = m.State;
            StandardPrice = m.StandardPrice;
            OrderID = m.OrderId;
            DiscountAmount = m.DiscountAmount;
            WipeAmount = m.WipeAmount;
            ActAmount = m.ActAmount;
            DeliveryVehicle = m.DeliveryVehicle;
            PreArrivalDate = m.PreArrivalDate;
            LoadingTime = m.LoadingTime;
            DepartTime = m.DepartTime;
            ActArriveTime = m.ActArriveTime;
            InsertTime = m.InsertTime;

            WorkList = m.WorkList;
            ApproveFlag = m.ApproveFlag;

            Remark = m.Remark;

            //发货单明细
            Items = new List<DeliveryDetail>();
            foreach (PBM_DeliveryDetail item in bll.Items)
            {
                Items.Add(new DeliveryDetail(item));
            }

            //付款信息列表
            PayInfos = new List<DeliveryPayInfo>();
            foreach (PBM_DeliveryPayInfo item in bll.GetPayInfoList())
            {
                PayInfos.Add(new DeliveryPayInfo(item));
            }

            #region 获取各字段ID对应的名称
            if (Supplier > 0)
            {
                CM_Client c = new CM_ClientBLL(Supplier).Model;
                if (c != null) SupplierName = c.FullName;
            }
            if (Client > 0)
            {
                CM_Client c = new CM_ClientBLL(Client).Model;
                if (c != null)
                {
                    ClientName = c.FullName;
                    ClientAddress = c.DeliveryAddress == "" ? c.Address : c.DeliveryAddress;
                    ClientLinkMan = c.LinkManName;
                    ClientTeleNum = c.Mobile == "" ? c.TeleNum : c.Mobile;
                }
            }
            if (SupplierWareHouse > 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(SupplierWareHouse).Model;
                if (w != null) SupplierWareHouseName = w.Name;
            }
            if (ClientWareHouse > 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(ClientWareHouse).Model;
                if (w != null) ClientWareHouseName = w.Name;
            }
            if (SalesMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(SalesMan).Model;
                if (s != null) SalesManName = s.RealName;
            }
            if (DeliveryMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(DeliveryMan).Model;
                if (s != null) DeliveryManName = s.RealName;
            }
            if (StandardPrice > 0)
            {
                PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model;
                if (s != null) StandardPriceName = s.Name;
            }
            if (DeliveryVehicle > 0)
            {
                CM_Vehicle v = new CM_VehicleBLL(DeliveryVehicle).Model;
                if (v != null) DeliveryVehicleName = v.VehicleNo;
            }
            #endregion

            #region 获取字典表名称
            try
            {
                if (m.Classify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify")[m.Classify.ToString()];
                    if (dic != null) ClassifyName = dic.Name;
                }
                if (m.PrepareMode > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryPrepareMode")[m.PrepareMode.ToString()];
                    if (dic != null) PrepareModeName = dic.Name;
                }
                if (m.State > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryState")[m.State.ToString()];
                    if (dic != null) StateName = dic.Name;
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Delivery", err);
            }
            #endregion
        }
    private void BindData()
    {
        CM_WareHouse m = new CM_WareHouseBLL((int)ViewState["ID"]).Model;
        if (m != null)
        {
            if (m.Client != (int)Session["OwnerClient"])
            {
                Response.Redirect("~/SubModule/Desktop.aspx");
            }

            pl_detail.BindData(m);
        }
    }
        public string DoImportInventory(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【期初库存】Excel表:";
            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List<string> listSupplier = new List<string>() { "序号", "商品编码", "商品名称", "批号", "生产日期", "库存成本价", "整件数量", "零散数量" };

            DataTable dt = null;
            bool flag = VertifySheet(Sheet, listSupplier, out dt, ref ImportInfo);
            if (!flag) { State = 4; return ImportInfo; }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    int _pdtTrafficPackaging = (!string.IsNullOrEmpty(dr["整件数量"].ToString())) ? Convert.ToInt32(dr["整件数量"].ToString()) : 0;
                    int _pdtPackaging = (!string.IsNullOrEmpty(dr["零散数量"].ToString())) ? Convert.ToInt32(dr["零散数量"].ToString()) : 0;
                    if (_pdtPackaging == 0 && _pdtTrafficPackaging == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行导入库存数量为0,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    string _pdtCode = dr["商品编码"].ToString();
                    IList<PDT_ProductExtInfo> _listPdtExtInfo = PDT_ProductExtInfoBLL.GetProductExtInfoList_BySupplier(_template.Model.ClientID);
                    PDT_ProductExtInfo _ProductExtInfo = _listPdtExtInfo.FirstOrDefault(m => m.Code == _pdtCode);
                    if (_ProductExtInfo == null || _ProductExtInfo.ID == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行找不到对应编码的产品,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    int _pdtID = _ProductExtInfo.Product;

                    //string _pdtName = dr["商品名称"].ToString();
                    string _pdtLotNumber = dr["批号"].ToString();
                    DateTime _pdtProductDate; DateTime.TryParse(dr["生产日期"].ToString(), out _pdtProductDate);
                    decimal _pdtPrice = (!string.IsNullOrEmpty(dr["库存成本价"].ToString())) ? Convert.ToDecimal(dr["库存成本价"].ToString()) : 0;
                    int _pdtQuantity = new PDT_ProductBLL(_pdtID).Model.ConvertFactor * _pdtTrafficPackaging + _pdtPackaging;

                    #region 获取经销商主仓库
                    int _WareHouse = 0;
                    IList<CM_WareHouse> _listWareHouse = CM_WareHouseBLL.GetModelList("  Classify=1 AND ApproveFlag=1 AND Client=" + _template.Model.ClientID.ToString());
                    if (_listWareHouse != null || _listWareHouse.Count > 0) _WareHouse = _listWareHouse[0].ID;
                    else
                    {
                        CM_WareHouseBLL _bllWareHouse = new CM_WareHouseBLL();
                        _bllWareHouse.Model.Name = "默认主仓库";
                        _bllWareHouse.Model.Client = _template.Model.ClientID;
                        _bllWareHouse.Model.InsertStaff = _template.Model.InsertStaff;
                        _bllWareHouse.Model.ApproveFlag = 1;
                        _WareHouse = _bllWareHouse.Add();
                    }
                    #endregion

                    int _result = INV_InventoryBLL.IncreaseQuantity(_WareHouse, _pdtID, _pdtLotNumber, _pdtPrice, _pdtQuantity);
                    if (_result != 0)
                    {
                        ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的销量时出现错误";
                        State = 5;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State = 5;
                    continue;
                }
            }
            if (State == 0) State = 3;
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return ImportInfo;
        }
 private void BindDropDown()
 {
     ddl_SupplierWareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
     ddl_SupplierWareHouse.DataBind();
 }
        public void ImportSAPService()
        {
            while (bIsRunning)
            {
                try
                {
                    ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService sd = new ImportExcelTDP.SAP_ZSD.Z_SD_SD_SHService();

                    NetworkCredential c = new NetworkCredential();
                    c.UserName     = ConfigHelper.GetConfigString("SAP_ZSD_User");
                    c.Password     = ConfigHelper.GetConfigString("SAP_ZSD_Password");
                    sd.Credentials = c;

                    ImportExcelTDP.SAP_ZSD.Ztdplog[] results1 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024];
                    ImportExcelTDP.SAP_ZSD.Ztdplog[] results2 = new ImportExcelTDP.SAP_ZSD.Ztdplog[1024];
                    sd.ZSdSdSh("1", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1);
                    sd.ZSdSdSh("2", "5200", DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), ref results1);
                    sd.ZSdSdSh("1", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results1);
                    sd.ZSdSdSh("2", "5200", DateTime.Today.ToString("yyyyMMdd"), ref results2);

                    List <ImportExcelTDP.SAP_ZSD.Ztdplog> results = new List <ImportExcelTDP.SAP_ZSD.Ztdplog>();
                    results.AddRange(results1);
                    results.AddRange(results2);
                    SendMessage("ImportSAPService", "获取到" + results.Count().ToString() + "条发货数量!");

                    if (results.Count() == 0)
                    {
                        Thread.Sleep(3600 * 1000); continue;
                    }

                    PBM_DeliveryBLL bll         = new PBM_DeliveryBLL();
                    decimal         totalamount = 0;
                    foreach (ImportExcelTDP.SAP_ZSD.Ztdplog item in results.OrderBy(p => p.Vgbel))
                    {
                        if (item.Vgbel != bll.Model.SheetCode)
                        {
                            #region 更新发货单
                            if (bll.Model.SheetCode != "" && bll.Items.Count > 0)
                            {
                                //计算折扣金额
                                bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) *
                                                                         Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor);

                                //明细合计金额
                                decimal actamount = Math.Round(bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor), 2);

                                //优惠金额(明细合计金额与实际采购金额的差额)
                                bll.Model.WipeAmount = actamount - totalamount;

                                //计算实际销售金额
                                bll.Model.ActAmount = (bll.Model.Classify == 12 ? -1 : 1) * (actamount - bll.Model.WipeAmount);



                                int ret = bll.Add();
                                if (ret > 0)
                                {
                                    SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",正在提交,总金额" + bll.Model.ActAmount.ToString("0.##") + "!");
                                }
                                else
                                {
                                    SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",提交失败!Ret=" + ret.ToString());
                                }

                                bll         = null;
                                totalamount = 0;
                            }
                            #endregion

                            #region 新增采购单据

                            //判断单号有没有导入过
                            if (PBM_DeliveryBLL.GetModelList("SheetCode='" + item.Vgbel + "' AND Supplier=1000 AND Classify IN (11,12)").Count > 0)
                            {
                                SendMessage("ImportSAPService", "单据号" + item.Vgbel + ",之前已存在!");
                                continue;
                            }

                            bll = new PBM_DeliveryBLL();
                            bll.Model.Classify = 11;

                            #region 判断TDP编码Kunage
                            string tdpcode = item.Kunag.Substring(3);
                            IList <CM_ClientManufactInfo> _clients = CM_ClientManufactInfoBLL.GetModelList("Code='" + tdpcode + "' AND Manufacturer=1000 AND State = 1");
                            if (_clients.Count == 0)
                            {
                                SendMessage("ImportSAPService", "门店编码无效,单据号" + item.Vgbel + ",客户编号:" + tdpcode);
                                continue;
                            }
                            #endregion

                            bll.Model.SheetCode = item.Vgbel;
                            bll.Model.Supplier  = 1000;
                            bll.Model.Client    = _clients[0].Client;

                            #region 获取经销商主仓库
                            IList <CM_WareHouse> _warehouses = CM_WareHouseBLL.GetEnbaledByClient(bll.Model.Client).Where(p => p.Classify == 1).OrderBy(p => p.ID).ToList();
                            if (_warehouses.Count == 0)
                            {
                                SendMessage("ImportSAPService", "未找到客户主仓库,单据号" + item.Vgbel + ",客户编号:" + tdpcode);
                                continue;
                            }
                            #endregion

                            bll.Model.ClientWareHouse = _warehouses[0].ID;
                            bll.Model.PrepareMode     = 1;
                            bll.Model.State           = 1; //默认制单状态
                            bll.Model.WipeAmount      = 0;
                            bll.Model.Remark          = "SAP导入";
                            bll.Model.ApproveFlag     = 2;
                            bll.Model.InsertStaff     = 1;
                            DateTime _prearrivaldate = DateTime.Today;
                            DateTime.TryParse(item.WadatIst, out _prearrivaldate);
                            bll.Model.PreArrivalDate = _prearrivaldate;
                            #endregion
                        }

                        #region 新增商品明细
                        string productcode            = item.Matnr.Substring(item.Matnr.Length - 6);
                        IList <PDT_Product> _products = PDT_ProductBLL.GetModelList("FactoryCode='" + productcode + "' AND State=1");
                        if (_products.Count == 0)
                        {
                            SendMessage("ImportSAPService", "商品编码无效,单据号" + item.Vgbel + ",商品编号:" + productcode);
                            continue;
                        }
                        int            productid  = _products[0].ID;
                        PDT_ProductBLL productbll = new PDT_ProductBLL(productid);


                        PBM_DeliveryDetail d = new PBM_DeliveryDetail();
                        d.Product          = productid;
                        d.ConvertFactor    = _products[0].ConvertFactor == 0 ? 1 : _products[0].ConvertFactor;
                        d.SalesMode        = 1;
                        d.DeliveryQuantity = (int)Math.Round(item.Fkimg * d.ConvertFactor, 0);

                        if (d.DeliveryQuantity < 0)
                        {
                            bll.Model.Classify = 12;        //采购退库单
                            d.DeliveryQuantity = 0 - d.DeliveryQuantity;
                        }

                        d.SignInQuantity = d.DeliveryQuantity;
                        d.CostPrice      = Math.Round(item.Kzwi / d.DeliveryQuantity, 4);
                        d.Price          = d.CostPrice;
                        d.DiscountRate   = Math.Round(item.Kzwi5 / item.Kzwi, 4);
                        d.LotNumber      = item.Charg;
                        totalamount     += item.Kzwi5;

                        DateTime _productdate = new DateTime(1900, 1, 1);
                        DateTime.TryParse(item.Hsdat, out _productdate);

                        if (_productdate.Year < 1900)
                        {
                            _productdate = new DateTime(1900, 1, 1);
                        }
                        d.ProductDate = _productdate;
                        d.Remark      = item.Fkart;

                        bll.Items.Add(d);
                        #endregion

                        #region 判断是否在默认价表中
                        PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Client);
                        if (extinfo == null)
                        {
                            extinfo            = new PDT_ProductExtInfo();
                            extinfo.Supplier   = bll.Model.Client;
                            extinfo.Product    = productid;
                            extinfo.Category   = productbll.Model.Category;
                            extinfo.Code       = productbll.Model.FactoryCode;
                            extinfo.SalesState = 1;
                            extinfo.BuyPrice   = d.Price;
                            extinfo.SalesPrice = d.Price;
                            new PDT_ProductBLL(productid).SetProductExtInfo(extinfo);
                        }
                        #endregion
                    }

                    #region 更新发货单
                    if (bll.Model.SheetCode != "" && bll.Items.Count > 0)
                    {
                        //计算折扣金额
                        bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) *
                                                                 Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor);

                        //计算实际销售金额
                        bll.Model.ActAmount = Math.Round((bll.Model.Classify == 12 ? -1 : 1) *
                                                         bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.SignInQuantity / p.ConvertFactor)
                                                         - bll.Model.WipeAmount, 2);

                        int ret = bll.Add();
                        if (ret > 0)
                        {
                            SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交成功,总金额" + bll.Model.ActAmount.ToString("0.##") + "!");
                        }
                        else
                        {
                            SendMessage("ImportSAPService", "单据号" + bll.Model.SheetCode + ",提交失败!Ret=" + ret.ToString());
                        }
                    }
                    #endregion

                    Thread.Sleep(3600 * 1000);
                }
                catch (ThreadAbortException e)
                {
                    this.SendMessage("ImportSAPService.ThreadAbortException", e.Message);
                    Thread.Sleep(10000);
                    continue;
                }
                catch (Exception ex)
                {
                    this.SendMessage("ImportSAPService.Exception", ex.Message);
                    Thread.Sleep(10000);
                    continue;
                }
            }
        }
Beispiel #18
0
        private void FillModel(CM_Vehicle m)
        {
            if (m == null) return;

            ID = m.ID;
            VehicleNo = m.VehicleNo;
            RelateStaff = m.RelateStaff;
            RelateWareHouse = m.RelateWareHouse;

            if (RelateStaff != 0)
            {
                Org_Staff s = new Org_StaffBLL(RelateStaff).Model;
                if (s != null) RelateStaffName = s.RealName;
            }

            if (RelateWareHouse != 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(RelateWareHouse).Model;
                if (w != null) RelateWareHouseName = w.Name;
            }

            #region 获取字典表名称
            try
            {
                if (m.VehicleClassify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("CM_VehicleClassify")[m.VehicleClassify.ToString()];
                    if (dic != null) VehicleClassifyName = dic.Name;
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Vehicle", err);
            }
            #endregion
        }
Beispiel #19
0
 private void BindDropDown()
 {
     ddl_WareHouse.DataSource = CM_WareHouseBLL.GetByClient((int)Session["OwnerClient"]);
     ddl_WareHouse.DataBind();
     ddl_WareHouse.Items.Insert(0, new ListItem("请选择...", "0"));
 }
        /// <summary>
        /// 获取指定仓库库存
        /// </summary>
        /// <param name="User"></param>
        /// <param name="WareHouse"></param>
        /// <param name="DisplayMode">1:按产品查询库存 2:按批号查询库存</param>
        /// <returns></returns>
        public static List<Inventory> GetInventoryByWareHouse(UserInfo User, int WareHouse, int DisplayMode)
        {
            LogWriter.WriteLog("PBMIFService.GetInventoryByWareHouse:UserName="******",WareHouse=" + WareHouse.ToString()
                + ",IsMergeByProduct=" + DisplayMode);

            CM_WareHouse w = new CM_WareHouseBLL(WareHouse).Model;
            if (w == null) return null;

            if (User.OwnerType == 3 && w.Client != User.ClientID) return null;  //仓库不属于当前登录人员的经销商

            IList<INV_Inventory> invtorys = INV_InventoryBLL.GetModelList("WareHouse=" + WareHouse.ToString() + " AND Quantity>0");
            List<Inventory> list = new List<Inventory>(invtorys.Count);

            foreach (INV_Inventory item in invtorys)
            {
                Inventory inv;
                if (DisplayMode == 1)
                {
                    inv = list.FirstOrDefault(p => p.Product == item.Product);
                    if (inv != null)
                    {
                        inv.Quantity += item.Quantity;

                        inv.Quantity_T = inv.Quantity / inv.ConvertFactor;
                        inv.Quantity_P = inv.Quantity % inv.ConvertFactor;
                        continue;
                    }
                }

                inv = new Inventory(item);

                if (DisplayMode == 1) inv.LotNumber = "";

                #region 获取产品默认销售价
                try
                {
                    inv.Price = new PDT_ProductBLL(item.Product).GetProductExtInfo(w.Client).SalesPrice;
                }
                catch { inv.Price = 0; }
                #endregion

                list.Add(inv);

            }

            return list.OrderBy(p => p.CategoryName).ToList();
        }
Beispiel #21
0
        public string DoImportInventory(int TemplateID, int Client, ISheet Sheet, out int State)
        {
            string ImportInfo = "【期初库存】Excel表:";

            State = 0;
            IPT_UploadTemplateBLL _template = new IPT_UploadTemplateBLL(TemplateID);

            List <string> listSupplier = new List <string>()
            {
                "序号", "商品编码", "商品名称", "批号", "生产日期", "库存成本价", "整件数量", "零散数量"
            };

            DataTable dt   = null;
            bool      flag = VertifySheet(Sheet, listSupplier, out dt, ref ImportInfo);

            if (!flag)
            {
                State = 4; return(ImportInfo);
            }

            foreach (DataRow dr in dt.Rows)//循环导入数据
            {
                try
                {
                    int _pdtTrafficPackaging = (!string.IsNullOrEmpty(dr["整件数量"].ToString())) ? Convert.ToInt32(dr["整件数量"].ToString()) : 0;
                    int _pdtPackaging        = (!string.IsNullOrEmpty(dr["零散数量"].ToString())) ? Convert.ToInt32(dr["零散数量"].ToString()) : 0;
                    if (_pdtPackaging == 0 && _pdtTrafficPackaging == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行导入库存数量为0,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    string _pdtCode = dr["商品编码"].ToString();
                    IList <PDT_ProductExtInfo> _listPdtExtInfo = PDT_ProductExtInfoBLL.GetProductExtInfoList_BySupplier(_template.Model.ClientID);
                    PDT_ProductExtInfo         _ProductExtInfo = _listPdtExtInfo.FirstOrDefault(m => m.Code == _pdtCode);
                    if (_ProductExtInfo == null || _ProductExtInfo.ID == 0)
                    {
                        ImportInfo += string.Format("序号为{0}的行找不到对应编码的产品,跳过此行信息\r\n", dr["序号"]);
                        continue;
                    }
                    int _pdtID = _ProductExtInfo.Product;

                    //string _pdtName = dr["商品名称"].ToString();
                    string   _pdtLotNumber = dr["批号"].ToString();
                    DateTime _pdtProductDate; DateTime.TryParse(dr["生产日期"].ToString(), out _pdtProductDate);
                    decimal  _pdtPrice    = (!string.IsNullOrEmpty(dr["库存成本价"].ToString())) ? Convert.ToDecimal(dr["库存成本价"].ToString()) : 0;
                    int      _pdtQuantity = new PDT_ProductBLL(_pdtID).Model.ConvertFactor *_pdtTrafficPackaging + _pdtPackaging;


                    #region 获取经销商主仓库
                    int _WareHouse = 0;
                    IList <CM_WareHouse> _listWareHouse = CM_WareHouseBLL.GetModelList("  Classify=1 AND ApproveFlag=1 AND Client=" + _template.Model.ClientID.ToString());
                    if (_listWareHouse != null || _listWareHouse.Count > 0)
                    {
                        _WareHouse = _listWareHouse[0].ID;
                    }
                    else
                    {
                        CM_WareHouseBLL _bllWareHouse = new CM_WareHouseBLL();
                        _bllWareHouse.Model.Name        = "默认主仓库";
                        _bllWareHouse.Model.Client      = _template.Model.ClientID;
                        _bllWareHouse.Model.InsertStaff = _template.Model.InsertStaff;
                        _bllWareHouse.Model.ApproveFlag = 1;
                        _WareHouse = _bllWareHouse.Add();
                    }
                    #endregion

                    int _result = INV_InventoryBLL.IncreaseQuantity(_WareHouse, _pdtID, _pdtLotNumber, _pdtPrice, _pdtQuantity);
                    if (_result != 0)
                    {
                        ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的销量时出现错误";
                        State       = 5;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    ImportInfo += "导入序列号为" + dr["序号"].ToString() + "的数据行时出现错误,错误说明:" + ex.Message + "\r\n";
                    State       = 5;
                    continue;
                }
            }
            if (State == 0)
            {
                State = 3;
            }
            ImportInfo += (State == 3 ? "导入完成!\r\n" : "");
            IPT_UploadTemplateMessageBLL _bllUploadTemplateMessage = new IPT_UploadTemplateMessageBLL();
            _bllUploadTemplateMessage.Model.TemplateID  = TemplateID;
            _bllUploadTemplateMessage.Model.MessageType = State;
            _bllUploadTemplateMessage.Model.Content     = ImportInfo;
            _bllUploadTemplateMessage.Add();
            return(ImportInfo);
        }