Example #1
0
        protected void popupAddPart_WindowCallback(object source, PopupWindowCallbackArgs e)
        {
            if (e.Parameter == "save")
            {
                int processId     = Session["GWISProcessId"].ToInt32(0);
                int assyCatalogId = txtEditorId.Text.ToInt32(0);

                if (processId == 0 || assyCatalogId == 0)
                {
                    popupAddPart.JSProperties["cpResult"] = "Invalid GWISProcessId or AssyCatalogId";
                    return;
                }

                using (AppDb ctx = new AppDb())
                {
                    AssyCatalog cat = ctx.AssyCatalogs.Where(x => x.Id == assyCatalogId).FirstOrDefault();
                    if (cat == null)
                    {
                        return;
                    }

                    GWISPart part = new GWISPart();
                    part.ProcessId = processId;
                    //part.AssyCatalogId = assyCatalogId;
                    part.CatalogPage     = txtEditorPage.Text;
                    part.PartNo          = txtEditorPartNo.Text;
                    part.PartDescription = txtEditorDescription.Text;
                    part.Qty_Actual      = txtEditorQtyActual.Text.ToInt32(0);
                    part.Pos_Actual      = txtEditorPosActual.Text.ToInt32(0);
                    part.Pos2_Actual     = txtEditorPos2Actual.Text.ToInt32(0);

                    part.SA = cat.SA;

                    part.CatalogModelId = cmbCatalogModel.Value.ToInt32(0);

                    part.CreatedDate = DateTime.Now;
                    part.CreatedBy   = PermissionHelper.GetAuthenticatedUserName();

                    ctx.GWISParts.Add(part);

                    try
                    {
                        ctx.SaveChanges();

                        popupAddPart.JSProperties["cpResult"] = "OK";
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.LogError(ex);

                        popupAddPart.JSProperties["cpResult"] = ex.Message;
                    }
                }
            }
        }
        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);
                }
            }
        }
        protected void popupDocUpload_OnWindowCallback(object source, PopupWindowCallbackArgs e)
        {
            if (e.Parameter == "upload")
            {
                string filePath = Session["pl_uploaded_file"] as string;

                AssyCatalogsUploader uploader = new AssyCatalogsUploader();

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

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

                //parse the file
                string message  = "";
                int    rowCount = uploader.Parse(filePath, packingMonth, modelId);
                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);
                }
            }
        }
Example #4
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 = dtPackingMonth.Date.ToString("yyyyMM").ToInt32(0);
                int modelId      = cmbModels.Value.ToInt32(0);
                int ricType      = cmbRicType.Value.ToInt32(0);

                //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;

                    popupDocUpload.JSProperties["cpResult"] = "1";

                    //this.masterGrid.DataBindSafe();

                    //int stepId = Session["StepId"].ToInt32(0);
                    //ChecklistHelper.ReleaseStep(stepId);

                    //string gridName = Session["StepGrid"].ToString();
                    //ASPxGridView grid = this.Page.FindNestedControl2(gridName) as ASPxGridView;
                    //if (grid != null)
                    //{
                    //    grid.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);

                    popupDocUpload.JSProperties["cpResult"] = "-1";

                    //e.CallbackData = lblSuccess.Text;

                    //e.IsValid = false;
                    //e.ErrorText = lblSuccess.Text;
                }
            }
            else
            {
                //string[] arr = e.Parameter.Split(GridViewHelper.SEPARATOR_VALUES);
                //if (arr.Length < 1)
                //    return;

                //int instanceStepId = arr[0].ToInt32(0);
                //string gridName = arr[1];

                //ChecklistInstanceStep step = ChecklistHelper.GetChecklistStep(instanceStepId);
                //if (step == null || step.ChecklistInstance == null)
                //    return;

                //// get parameter
                //DateTime dt = DateTime.Parse(ChecklistHelper.GetChecklistParameterValue(step.ChecklistInstanceId, "PackingMonth"));
                //int packingMonth = dt.ToString("yyyyMM").ToInt32(0);
                //int modelId = ChecklistHelper.GetChecklistParameterValue(step.ChecklistInstanceId, "CatalogModelId").ToInt32(0);

                //Session["PM"] = packingMonth;
                //Session["ModelId"] = modelId;
                //Session["StepId"] = instanceStepId;
                //Session["StepGrid"] = gridName;

                lblSuccess.Text = "";
                //txtPM.Value = packingMonth.ToString();
                //txtModelId.Value = modelId;
                ////cmbRicType.Value = 0;

                popupDocUpload.JSProperties["cpResult"] = "0";
            }
        }
Example #5
0
        protected void popupDocUpload_OnWindowCallback(object source, PopupWindowCallbackArgs e)
        {
            if (e.Parameter == "upload")
            {
                string filePath = Session["pl_uploaded_file"] as string;

                ProductionSequenceUploader uploader = new ProductionSequenceUploader();

                //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);

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

                    this.masterGrid.DataBindSafe();

                    //e.CallbackData = lblSuccess.Text;

                    //e.IsValid = true;
                    //e.ErrorText = "";
                }
                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);

                    //e.CallbackData = lblSuccess.Text;

                    //e.IsValid = false;
                    //e.ErrorText = lblSuccess.Text;
                }
            }

            //try
            //{
            //    string[] parameters = e.Parameter.Split(';');
            //    Session["Id"] = parameters[0];
            //    CheckListInstanceStep oStep =
            //        CheckListInstanceRepository.RetrieveCurrentInstanceStep(Convert.ToInt32(parameters[0]));
            //    DotWeb.Models.CheckListInstanceInfo oInfo =
            //        CheckListInstanceRepository.RetrieveCurrentInstanceInfoById(
            //            oStep.CheckListInstanceInfoId.GetValueOrDefault());
            //    int ass = Convert.ToInt32(Session["assemblyType"]);
            //    int modelId = ModelRepository.RetrieveModelIdByName(oInfo.Model);
            //    int vpm = Convert.ToInt32(oInfo.PackingMonth);
            //    int variantId = ModelRepository.RetrieveVariantIdByModelIdAndVariantName(modelId, oInfo.Variant);
            //    if (oStep != null)
            //    {
            //        string fileTypeName = FileTypeRepository.RetrieveFileTypeNameById(
            //                                                          oStep.FileTypeId);
            //        popupDocUpload.JSProperties["cpHeaderText"] = "File Upload - " + fileTypeName;

            //        UploaderBase uploader = UploaderHelper.GetUploader(oStep.FileTypeId, ass);
            //        if (uploader.HasExistingData(vpm, modelId, variantId) != 0)
            //        {
            //            lblexist.Text = "File Already exist";
            //            lblFile.Text = uploader.FileName;
            //        }

            //        Session["FileTypeName"] = fileTypeName;
            //        Session["FileTypeId"] = oStep.FileTypeId;
            //        Session["ModelName"] = oInfo.Model;
            //        Session["VariantName"] = oInfo.Variant;
            //        Session["PackingMonth"] = oInfo.PackingMonth;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    LoggerHelper.LogError(ex);
            //}
        }