Ejemplo n.º 1
0
    protected void GV_List_Sorting(Object sender, GridViewSortEventArgs e)
    {
        DataControlFieldCollection dcfc = ((GridView)sender).Columns;

        for (int i = 6; i < dcfc.Count; i++)
        {
            DataControlField dcf = dcfc[i];
            if (dcf.SortExpression == e.SortExpression)
            {
                ColumnNum = i - 6;

                string qty         = "Qty" + (i - 6).ToString();
                string actQty      = "ActQty" + (i - 6).ToString();
                string requiredQty = "RequiredQty" + (i - 6).ToString();

                this.ScheduleDate = DateTime.Parse(e.SortExpression);
                //todo wintime or starttime
                this.hfLastScheduleTime.Value = dcf.FooterText;
                DateTime?lastScheduleDate = null;
                if (this.hfLastScheduleTime.Value != string.Empty)
                {
                    lastScheduleDate = DateTime.Parse(this.hfLastScheduleTime.Value);
                }

                IList <MrpShipPlanView> mrpShipPlanViews = TheMrpShipPlanViewMgr.GetMrpShipPlanViews((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, this.EffDate, null, null);

                DetachedCriteria criteria = DetachedCriteria.For <ExpectTransitInventoryView>();
                criteria.Add(Expression.Eq("EffectiveDate", this.EffDate));
                IList <ExpectTransitInventoryView> transitInventoryViews = this.TheCriteriaMgr.FindAll <ExpectTransitInventoryView>(criteria);


                ScheduleView scheduleView = TheMrpShipPlanViewMgr.TransferMrpShipPlanViews2ScheduleView(mrpShipPlanViews, transitInventoryViews, this.rblFlowOrLoc.SelectedValue, this.rblDateType.SelectedValue);

                foreach (ScheduleBody body in scheduleView.ScheduleBodys)
                {
                    PropertyInfo qtyProp         = typeof(ScheduleBody).GetProperty(qty);
                    PropertyInfo actQtyProp      = typeof(ScheduleBody).GetProperty(actQty);
                    PropertyInfo requiredQtyProp = typeof(ScheduleBody).GetProperty(requiredQty);

                    body.Qty0         = (decimal)qtyProp.GetValue(body, null);
                    body.ActQty0      = (decimal)actQtyProp.GetValue(body, null);
                    body.RequiredQty0 = (decimal)requiredQtyProp.GetValue(body, null);
                }

                this.GV_Order.DataSource = scheduleView.ScheduleBodys;
                this.GV_Order.DataBind();
                this.fld_Search.Visible      = false;
                this.div_OrderDetail.Visible = true;
                this.div_MRP_Detail.Visible  = false;
                this.fld_Group.Visible       = false;
                if (isFlow)
                {
                    this.tbFlow.Text = this.flowOrLoc;
                    dotbFlow_TextChanged(this.flowOrLoc);
                }
                //this.ucShift.Date = DateTime.Today;
                break;
            }
        }
    }
Ejemplo n.º 2
0
    private void dotbFlow_TextChanged(string flowCode)
    {
        try
        {
            Flow currentFlow = TheFlowMgr.LoadFlow(flowCode, true, true);
            if (currentFlow != null)
            {
                this.FlowCode = currentFlow.Code;
                this.FlowType = currentFlow.Type;

                this.cbReleaseOrder.Checked = currentFlow.IsAutoRelease;
                this.cbPrintOrder.Checked   = currentFlow.NeedPrintOrder;
                if (this.ScheduleDate.HasValue)
                {
                    if (isWinTime)
                    {
                        DateTime winTime = FlowHelper.GetWinTime(currentFlow, this.ScheduleDate.Value);
                        this.tbWinTime.Text = winTime.ToString("yyyy-MM-dd HH:mm");
                        double leadTime = currentFlow.LeadTime.HasValue ? (double)currentFlow.LeadTime.Value : 0;
                        this.tbStartTime.Text = winTime.AddHours(-leadTime).ToString("yyyy-MM-dd HH:mm");
                    }
                    else
                    {
                        double   leadTime = currentFlow.LeadTime.HasValue ? (double)currentFlow.LeadTime.Value : 0;
                        DateTime winTime  = FlowHelper.GetWinTime(currentFlow, this.ScheduleDate.Value.AddHours(leadTime));
                        this.tbWinTime.Text   = winTime.ToString("yyyy-MM-dd HH:mm");
                        this.tbStartTime.Text = winTime.AddHours(-leadTime).ToString("yyyy-MM-dd HH:mm");
                    }
                }

                this.hfLeadTime.Value = currentFlow.LeadTime.ToString();
                this.hfEmTime.Value   = currentFlow.EmTime.ToString();

                //  InitDetailParamater(orderHead);

                if (currentFlow.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                {
                    this.ltlShift.Text    = "${MasterData.WorkCalendar.Shift}:";
                    this.ltlShift.Visible = true;
                    this.ucShift.Visible  = true;
                    //this.tbScheduleTime.Visible = false;
                    this.BindShift(currentFlow);
                }
                else if (!enableDiscon && (currentFlow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION ||
                                           currentFlow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_SUBCONCTRACTING ||
                                           currentFlow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PROCUREMENT))
                {
                    this.ltlShift.Visible     = true;
                    this.ltlShift.Text        = "${MasterData.Order.OrderHead.SettleTime}:";
                    this.ucShift.Visible      = false;
                    this.tbSettleTime.Visible = true;
                    //this.tbScheduleTime.Visible = true;
                    this.tbSettleTime.Text = this.tbWinTime.Text;
                }
                else
                {
                    this.ltlShift.Visible     = false;
                    this.ucShift.Visible      = false;
                    this.tbSettleTime.Visible = false;
                }

                IList <MrpShipPlanView> mrpShipPlanViews = TheMrpShipPlanViewMgr.GetMrpShipPlanViews((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, this.EffDate, null, null);

                DetachedCriteria criteria = DetachedCriteria.For <ExpectTransitInventoryView>();
                criteria.Add(Expression.Eq("EffectiveDate", this.EffDate));
                IList <ExpectTransitInventoryView> transitInventoryViews = this.TheCriteriaMgr.FindAll <ExpectTransitInventoryView>(criteria);


                ScheduleView scheduleView = TheMrpShipPlanViewMgr.TransferMrpShipPlanViews2ScheduleView(mrpShipPlanViews, transitInventoryViews, this.rblFlowOrLoc.SelectedValue, this.rblDateType.SelectedValue);

                string qty         = "Qty" + ColumnNum.ToString();
                string actQty      = "ActQty" + ColumnNum.ToString();
                string requiredQty = "RequiredQty" + ColumnNum.ToString();

                IList <ScheduleBody> scheduleBodyList = new List <ScheduleBody>();
                foreach (ScheduleBody body in scheduleView.ScheduleBodys)
                {
                    if (currentFlow.FlowDetails != null && currentFlow.FlowDetails.Count > 0)
                    {
                        var p = from det in currentFlow.FlowDetails
                                where det.Item.Code == body.Item
                                select det;

                        if (p != null && p.Count() > 0)
                        {
                            PropertyInfo qtyProp         = typeof(ScheduleBody).GetProperty(qty);
                            PropertyInfo actQtyProp      = typeof(ScheduleBody).GetProperty(actQty);
                            PropertyInfo requiredQtyProp = typeof(ScheduleBody).GetProperty(requiredQty);

                            body.Qty0         = (decimal)qtyProp.GetValue(body, null);
                            body.ActQty0      = (decimal)actQtyProp.GetValue(body, null);
                            body.RequiredQty0 = (decimal)requiredQtyProp.GetValue(body, null);

                            scheduleBodyList.Add(body);
                        }
                    }
                }

                this.GV_Order.DataSource = scheduleBodyList;
                this.GV_Order.DataBind();
            }
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 3
0
    private void DoSearch(Button button)
    {
        if (this.flowOrLoc == string.Empty)
        {
            ShowErrorMessage("MRP.Schedule.Import.CustomerSchedule.Result.SelectFlow");
            return;
        }
        else if (isFlow)
        {
            Flow flow = TheFlowMgr.LoadFlow(this.flowOrLoc);
            if (flow.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
            {
                this.PartyCode = flow.PartyTo.Code;
            }
            else
            {
                this.PartyCode = flow.PartyFrom.Code;
            }
        }
        //added by [email protected]
        //2012/5
        string plant = "";

        plant = ddlPlant.SelectedValue;
        string        ConnString = string.Empty;
        string        sqlText    = string.Empty;
        DataSet       dsTemp     = new DataSet();
        XmlTextReader reader     = new XmlTextReader(Server.MapPath("Config/properties.config"));
        XmlDocument   doc        = new XmlDocument();

        doc.Load(reader); //
        reader.Close();   //
        ConnString = doc.SelectSingleNode("/configuration/properties/connectionString").InnerText.Trim();
        sqlText    = "select distinct code from item where plant = '" + plant + "'";
        dsTemp     = SqlHelper.ExecuteDataset(ConnString, CommandType.Text, sqlText);

        List <string> listItem = new List <string>();

        foreach (DataRow dr in dsTemp.Tables[0].Rows)
        {
            listItem.Add(dr["code"].ToString());
        }
        //added end

        DetachedCriteria criteria = DetachedCriteria.For <ExpectTransitInventory>();

        criteria.Add(Expression.Eq("EffectiveDate", this.EffDate));
        expectTransitInventories = this.TheCriteriaMgr.FindAll <ExpectTransitInventory>(criteria);

        if (this.rblListFormat.SelectedIndex == 1)
        {
            this.GV_List.EnableViewState   = false;
            this.GV_Detail.EnableViewState = true;
            this.GV_Order.EnableViewState  = false;

            // this.mrpShipPlans = TheMrpShipPlanMgr.GetMrpShipPlans((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, this.EffDate, this.WinDate, this.StartDate);
            this.mrpShipPlans = TheMrpShipPlanMgr.GetMrpShipPlansBB((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, listItem, this.EffDate, this.WinDate, this.StartDate);

            this.GV_Detail_DataBind(mrpShipPlans, expectTransitInventories);
        }
        else
        {
            this.GV_List.EnableViewState   = true;
            this.GV_Detail.EnableViewState = false;
            this.GV_Order.EnableViewState  = false;
            if (button == this.btnSearch)
            {
                //this.mrpShipPlans = TheMrpShipPlanMgr.GetMrpShipPlans((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, this.EffDate, this.WinDate, this.StartDate);
                this.mrpShipPlans = TheMrpShipPlanMgr.GetMrpShipPlansBB((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, listItem, this.EffDate, this.WinDate, this.StartDate);
            }

            // IList<MrpShipPlanView> mrpShipPlanViews = TheMrpShipPlanViewMgr.GetMrpShipPlanViews((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, this.EffDate, this.WinDate, this.StartDate);
            IList <MrpShipPlanView> mrpShipPlanViews = TheMrpShipPlanViewMgr.GetMrpShipPlanViewsBB((isFlow ? this.flowOrLoc : null), (!isFlow ? this.flowOrLoc : null), this.itemCode, listItem, this.EffDate, this.WinDate, this.StartDate);

            criteria = DetachedCriteria.For <ExpectTransitInventoryView>();
            criteria.Add(Expression.Eq("EffectiveDate", this.EffDate));
            IList <ExpectTransitInventoryView> transitInventoryViews = this.TheCriteriaMgr.FindAll <ExpectTransitInventoryView>(criteria);

            ScheduleView scheduleView = TheMrpShipPlanViewMgr.TransferMrpShipPlanViews2ScheduleView(mrpShipPlanViews, transitInventoryViews, this.rblFlowOrLoc.SelectedValue, this.rblDateType.SelectedValue);
            this.GV_List_DataBind(scheduleView);
        }
    }