Exemplo n.º 1
0
        protected void popupDocUpload_OnWindowCallback(object source, PopupWindowCallbackArgs e)
        {
            if (e.Parameter == "upload")
            {
                string filePath = Session["pl_uploaded_file"] as string;

                PackingListUploader uploader = new PackingListUploader();

                //set username for column createdby and modifiedby
                uploader.Username = PermissionHelper.GetAuthenticatedUserName();

                //parameter
                DateTime value        = (DateTime)dtPM.Value;
                int      packingMonth = value.ToString("yyyyMM", System.Globalization.CultureInfo.InvariantCulture).ToInt32(0);
                int      modelId      = cmbModels.Value.ToInt32(0);
                int      ricType      = cmbRicType.Value.ToInt32(0);

                //make sure RIC is not released yet. If it is already released, can not upload packing list
                RIC ric = RicRepository.GetRIC(modelId, packingMonth, ricType);
                if (ric != null && ric.StatusId == EStatus.Released)
                {
                    lblSuccess.Text = "RIC is already released. Upload file " + Path.GetFileName(filePath) + " failed!";
                    return;
                }

                //parse the file
                string message  = "";
                int    rowCount = uploader.Parse(filePath, packingMonth, modelId, ricType);
                if (rowCount > 0)
                {
                    lblSuccess.Text = "Successfully upload and process data " + Path.GetFileName(filePath) + ", " + rowCount + " rows inserted, " + message;

                    this.masterGrid.DataBindSafe();
                }
                else
                {
                    if (uploader.ErrorMessage.Length > 0)
                    {
                        lblSuccess.Text = uploader.ErrorMessage;
                    }
                    else
                    {
                        lblSuccess.Text = "Upload file " + Path.GetFileName(filePath) + " failed!";
                    }
                    //delete the file
                    File.Delete(filePath);
                }
            }
        }
Exemplo n.º 2
0
        protected void RefreshPage(int modelid, int vpm, int rictype)
        {
            PackingList pl = RicRepository.GetPackingList(modelid, vpm, rictype);

            if (pl != null)
            {
                imgUploadPL.ImageUrl = "/Content/Images/status-green.png";
                imgUploadPL.Visible  = true;
                lblPL.Text           = "Filename: " + pl.FileName + "; Lot: " + pl.LotNos + "; Upload Date: " + pl.CreatedDate;
            }
            else
            {
                imgUploadPL.ImageUrl = "/Content/Images/status-red.png";
                imgUploadPL.Visible  = true;
                lblPL.Text           = "No packing list uploaded.";
            }

            RIC ric = RicRepository.GetRIC(modelid, vpm, rictype);

            if (ric != null && ric.CompareDate != null && ric.CompareDate.Value > pl.CreatedDate)
            {
                imgComparePL.ImageUrl = "/Content/Images/status-green.png";
                imgComparePL.Visible  = true;
                lblComparePL.Text     = "RICNr: " + ric.RICNr + "; Compare Date: " + ric.CompareDate;

                if (ric.StatusId != EStatus.Draft)
                {
                    imgReleaseRic.ImageUrl = "/Content/Images/status-green.png";
                    imgReleaseRic.Visible  = true;
                    lblReleaseRIC.Text     = "RICNr: " + ric.RICNr + "; Released Date: " + ric.IssuedDate;
                }
                else
                {
                    imgReleaseRic.ImageUrl = "/Content/Images/status-red.png";
                    imgReleaseRic.Visible  = true;
                    lblReleaseRIC.Text     = "No RIC";
                }
            }
            else
            {
                imgComparePL.ImageUrl = "/Content/Images/status-red.png";
                imgComparePL.Visible  = true;
                lblComparePL.Text     = "No RIC";

                imgReleaseRic.ImageUrl = "/Content/Images/status-red.png";
                imgReleaseRic.Visible  = true;
                lblReleaseRIC.Text     = "No RIC";
            }

            callback.JSProperties["cpResult"] = "";

            if (ric == null)
            {
                hdField["status"] = 0;
            }
            else
            {
                hdField["status"] = (int)ric.StatusId;
            }

            cmbModels.Enabled      = false;
            dtPackingMonth.Enabled = false;
            cmbRicType.Enabled     = false;
        }
Exemplo n.º 3
0
        protected void callback_Callback(object sender, CallbackEventArgsBase e)
        {
            string[] str = e.Parameter.Split(";");
            if (str.Length < 4)
            {
                return;
            }

            if (str[0] == "release")
            {
                int modelid = str[1].ToInt32(0);
                int vpm     = str[2].ToInt32(0);
                int rictype = str[3].ToInt32(0);

                try
                {
                    RicRepository.ReleaseRIC(modelid, vpm, rictype);
                    callback.JSProperties["cpResult"] = "RIC successfully released";
                }
                catch (Exception ex)
                {
                    callback.JSProperties["cpResult"] = ex.Message;
                }

                PackingList pl = RicRepository.GetPackingList(modelid, vpm, rictype);
                if (pl != null)
                {
                    imgUploadPL.ImageUrl = "/Content/Images/status-green.png";
                    imgUploadPL.Visible  = true;
                    lblPL.Text           = "Filename: " + pl.FileName + "; Lot: " + pl.LotNos + "; Upload Date: " + pl.CreatedDate;
                }
                else
                {
                    imgUploadPL.ImageUrl = "/Content/Images/status-red.png";
                    imgUploadPL.Visible  = true;
                    lblPL.Text           = "No packing list uploaded.";
                }

                RIC ric = RicRepository.GetRIC(modelid, vpm, rictype);
                if (ric != null && ric.CompareDate != null && ric.CompareDate.Value > pl.CreatedDate)
                {
                    imgComparePL.ImageUrl = "/Content/Images/status-green.png";
                    imgComparePL.Visible  = true;
                    lblComparePL.Text     = "RICNr: " + ric.RICNr + "; Compare Date: " + ric.CompareDate;

                    if (ric.StatusId != EStatus.Draft)
                    {
                        imgReleaseRic.ImageUrl = "/Content/Images/status-green.png";
                        imgReleaseRic.Visible  = true;
                        lblReleaseRIC.Text     = "RICNr: " + ric.RICNr + "; Released Date: " + ric.IssuedDate;
                    }
                    else
                    {
                        imgReleaseRic.ImageUrl = "/Content/Images/status-red.png";
                        imgReleaseRic.Visible  = true;
                        lblReleaseRIC.Text     = "No RIC";
                    }
                }
                else
                {
                    imgComparePL.ImageUrl = "/Content/Images/status-red.png";
                    imgComparePL.Visible  = true;
                    lblComparePL.Text     = "No RIC";

                    imgReleaseRic.ImageUrl = "/Content/Images/status-red.png";
                    imgReleaseRic.Visible  = true;
                    lblReleaseRIC.Text     = "No RIC";
                }

                if (ric == null)
                {
                    hdField["status"] = 0;
                }
                else
                {
                    hdField["status"] = (int)ric.StatusId;
                }
            }
            else if (str[0] == "refresh")
            {
                int modelid = str[1].ToInt32(0);
                int vpm     = str[2].ToInt32(0);
                int rictype = str[3].ToInt32(0);
                RefreshPage(modelid, vpm, rictype);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Custom Page_Init function for inherited class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        protected override bool OnInit(object sender, EventArgs e)
        {
            //Dynamic permission
            //TODO

            ////determine if we should use QM/LOG/ENG configuration
            //string org = ControlPlanRepository.GetUserOrganization(assemblyTypeId, user.UserId).ToUpper();
            //if (org == "ENG")
            //{
            //    //engineering > edit mode
            //    tableName = "STAViewSingleENG";
            //}
            //else
            //{
            //    tableName = "STAViewSingle";
            //}

            ////override if mode is specified
            //if (Request.QueryString["mode"] != null)
            //{
            //    int mode = Request.QueryString["mode"].ToInt32(0);
            //    if (mode == 2)
            //    {
            //        //engineering > edit mode
            //        tableName = "STAViewSingleENG";
            //    }
            //    else
            //    {
            //        tableName = "STAViewSingle";
            //    }
            //}

            //since we determine the table dynamically, check for permission explicitly
            permissions = PermissionHelper.GetTablePermissions(tableName, user.UserId, assemblyTypeId);
            if (permissions.Count() == 0)
            {
                //set redirect = 1 to prevent AccessDenied.aspx to try to re-check the permission
                Session["redirect"] = 1;
                //redirect
                Response.Redirect(ConfigurationHelper.PAGE_ACCESSDENIED + "?path=" + HttpContext.Current.Request.RawUrl);
            }

            //get TableMeta from Schema. Schema is loaded during login
            var schemaInfo = Application["SchemaInfo"] as SchemaInfo;

            tableMeta = schemaInfo.Tables.Where(s => s.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            if (tableMeta == null)
            {
                masterPage.MainContent.Controls.Add(new LiteralControl(string.Format("<h2>{0}</h2>", "Invalid Page")));
                return(false);
            }

            //header info
            int vpm     = Request.QueryString["vpm"].ToInt32(0);
            int modelId = Request.QueryString["model"].ToInt32(0);
            int rictype = Request.QueryString["rictype"].ToInt32(0);
            int ricId   = Request.QueryString["id"].ToInt32(0);

            using (AppDb ctx = new AppDb())
            {
                if (ricId > 0)
                {
                    ric = ctx.RICs.Where(x => x.Id == ricId).FirstOrDefault();
                }
                else
                {
                    ric = ctx.RICs.Where(x => x.CatalogModelId == modelId && x.RICTypeId == rictype && x.PackingMonth == vpm.ToString()).FirstOrDefault();
                }
            }

            if (ric == null)
            {
                var panel1 = new System.Web.UI.WebControls.Panel();
                panel1.CssClass = "mainContent";
                panel1.Controls.Clear();
                panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Model/Variant/PackingMonth for RIC</h2>")));

                masterPage.MainContent.Controls.Add(panel1);
                masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption));

                divHeader.Visible = false;

                return(false);
            }

            //set master key
            SetMasterKey("RICId", ric.Id);
            //if (tableMeta.TableType == ETableType.StoredProcedure)
            //{
            //    queryFilter = string.Format("RICId={0}", ric.Id);
            //}
            //else
            //{
            //    queryFilter = string.Format("RICId={0}", ric.Id);
            //}

            //create header
            ShowSTAHeader();

            return(true);
        }