Esempio n. 1
0
        protected void rgPlantActive_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                try
                {
                    GridDataItem item        = (GridDataItem)e.Item;
                    PLANT_ACTIVE plantActive = (PLANT_ACTIVE)e.Item.DataItem;

                    HiddenField hf = (HiddenField)item.FindControl("hPlantID");

                    Label lbl = (Label)item.FindControl("lblModule");
                    lbl.Text = ((TaskRecordType)plantActive.RECORD_TYPE).ToString();

                    RadMonthYearPicker rdp = (RadMonthYearPicker)item.FindControl("rdpStartDate");
                    rdp.SelectedDate = plantActive.EFF_START_DATE.HasValue ? plantActive.EFF_START_DATE : null;

                    rdp = (RadMonthYearPicker)item.FindControl("rdpStopDate");
                    rdp.SelectedDate = plantActive.EFF_END_DATE.HasValue ? plantActive.EFF_END_DATE : null;

                    CheckBox cb = (CheckBox)item.FindControl("cbEnableEmail");
                    cb.Checked = (bool)plantActive.ENABLE_EMAIL;

                    cb         = (CheckBox)item.FindControl("cbViewInactiveHist");
                    cb.Checked = (bool)plantActive.ENABLE_INACTIVE_HIST;
                }
                catch
                {
                }
            }
        }
Esempio n. 2
0
        protected void radDateSelect1Click(Object sender, EventArgs e)
        {
            RadMonthYearPicker dmSelect = (RadMonthYearPicker)sender;

            if (dmSelect.SelectedDate == null)
            {
                return;
            }
            else
            {
                btnCalculate.Enabled = true;
                if (OnProfilePeriodClick != null)
                {
                    OnProfilePeriodClick(new DateTime(dmSelect.SelectedDate.Value.Year, dmSelect.SelectedDate.Value.Month, 1));
                }
            }
        }
Esempio n. 3
0
        protected void lbPlantSave_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            PLANT   plant   = (PLANT)LocalOrg().EditObject;
            ADDRESS address = null;

            TextBox tbPlantName    = (TextBox)hfBase.FindControl("tbPlantName");
            TextBox tbPlantDesc    = (TextBox)hfBase.FindControl("tbPlantDesc");
            TextBox tbOrgLocCode   = (TextBox)hfBase.FindControl("tbOrgLocCode");
            TextBox tbPlantLocCode = (TextBox)hfBase.FindControl("tbPlantLocCode");

            DropDownList ddlParentBusOrg      = (DropDownList)hfBase.FindControl("ddlParentBusOrg");
            DropDownList ddlPlantCurrecyCodes = (DropDownList)hfBase.FindControl("ddlPlantCurrencyCodes");
            DropDownList ddlPlantTimeZone     = (DropDownList)hfBase.FindControl("ddlPlantTimezone");
            DropDownList ddlStatus            = (DropDownList)hfBase.FindControl("ddlPlantStatus");

            if (btn.CommandArgument == "edit")
            {
                if (plant == null)
                {
                    plant            = new PLANT();
                    plant.COMPANY_ID = SessionManager.EffLocation.Company.COMPANY_ID;
                    entities.AddToPLANT(plant);
                }
                else
                {
                    plant = SQMModelMgr.LookupPlant(entities, (decimal)plant.COMPANY_ID, 0, plant.PLANT_ID, "", false);
                }

                if (string.IsNullOrEmpty(tbPlantName.Text)) // || string.IsNullOrEmpty(tbPlantLocCode.Text))
                {
                    ErrorAlert("RequiredInputs");
                    return;
                }

                plant.PLANT_NAME      = tbPlantName.Text.Trim();
                plant.DISP_PLANT_NAME = tbPlantDesc.Text.Trim();
                plant.DUNS_CODE       = tbPlantLocCode.Text.Trim();
                plant.ALT_DUNS_CODE   = tbAltPlantCode.Text.Trim();
                plant.LOCATION_CODE   = ddlCountryCode.SelectedValue;
                if (plant.LOCATION_CODE == "US")
                {
                    plant.COMP_INT_ID = ddlPowerSourcedRegion.SelectedValue;
                }
                else
                {
                    plant.COMP_INT_ID = "";
                }

                if (!string.IsNullOrEmpty(ddlLocalLanguage.SelectedValue))
                {
                    plant.LOCAL_LANGUAGE = Convert.ToInt32(ddlLocalLanguage.SelectedValue);
                }
                else
                {
                    plant.LOCAL_LANGUAGE = null;
                }

                plant.LOCATION_TYPE  = ddlLocationType.SelectedValue;
                plant.TRACK_FIN_DATA = cbTrackFinData.Checked;
                plant.TRACK_EW_DATA  = cbTrackEWData.Checked;
                plant.BUS_ORG_ID     = Int32.Parse(ddlParentBusOrg.SelectedValue);
                plant.CURRENCY_CODE  = ddlPlantCurrecyCodes.SelectedValue;
                plant.LOCAL_TIMEZONE = ddlPlantTimeZone.SelectedValue;
                // plant.LOCAL_LANGUAGE = Convert.ToInt32(ddlPlantLanguage.SelectedValue);
                plant.STATUS = ddlStatus.SelectedValue;

                if (plant.ADDRESS == null || plant.ADDRESS.Count == 0)
                {
                    address              = new ADDRESS();
                    address.COMPANY_ID   = plant.COMPANY_ID;
                    address.PLANT_ID     = plant.PLANT_ID;
                    address.ADDRESS_TYPE = "S";
                    plant.ADDRESS.Add(address);
                }
                else
                {
                    address = plant.ADDRESS.FirstOrDefault();
                }

                address.STREET1     = tbAddress1.Text;
                address.STREET2     = tbAddress2.Text;
                address.CITY        = tbCity.Text;
                address.STATE_PROV  = tbState.Text;
                address.POSTAL_CODE = tbPostal.Text;
                address.COUNTRY     = ddlCountryCode.SelectedValue;

                foreach (GridItem item in rgPlantActive.Items)
                {
                    PLANT_ACTIVE plantActive = null;
                    PLANT_ACTIVE pa          = null;

                    HiddenField        hfRecType = (HiddenField)item.FindControl("hfRecordType");
                    RadMonthYearPicker rdp1      = (RadMonthYearPicker)item.FindControl("rdpStartDate");
                    RadMonthYearPicker rdp2      = (RadMonthYearPicker)item.FindControl("rdpStopDate");
                    CheckBox           cb1       = (CheckBox)item.FindControl("cbEnableEmail");
                    CheckBox           cb2       = (CheckBox)item.FindControl("cbViewInactiveHist");

                    try
                    {
                        if ((pa = plant.PLANT_ACTIVE.Where(p => p.RECORD_TYPE == Convert.ToInt32(hfRecType.Value)).FirstOrDefault()) != null)
                        {
                            pa.EFF_START_DATE       = rdp1.SelectedDate;
                            pa.EFF_END_DATE         = rdp2.SelectedDate;
                            pa.ENABLE_EMAIL         = cb1.Checked;
                            pa.ENABLE_INACTIVE_HIST = cb2.Checked;
                        }
                        else
                        {
                            plantActive                      = new PLANT_ACTIVE();
                            plantActive.PLANT_ID             = plant.PLANT_ID;
                            plantActive.RECORD_TYPE          = Convert.ToInt32(hfRecType.Value);
                            plantActive.EFF_START_DATE       = rdp1.SelectedDate;
                            plantActive.EFF_END_DATE         = rdp2.SelectedDate;
                            plantActive.ENABLE_EMAIL         = cb1.Checked;
                            plantActive.ENABLE_INACTIVE_HIST = cb2.Checked;
                            plant.PLANT_ACTIVE.Add(plantActive);
                            //entities.AddToPLANT_ACTIVE(plantActive);
                        }
                    }
                    catch { }
                }

                if (SQMModelMgr.UpdatePlant(entities, plant, SessionManager.UserContext.UserName()) != null)
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
                    lbPlantSave_Click(lbPlantCancel1, null);
                }
                else
                {
                    ErrorAlert("SaveError");
                    return;
                }
            }
            else
            {
                uclSearchBar_OnReturnClick();
            }

            SessionManager.EffLocation.Plant = plant;
            LocalOrg().EditObject            = null;
            SetupPage();
        }