Example #1
0
        protected void btnVerify_Click(object sender, EventArgs e)
        {
            ASPxButton btn = (sender as ASPxButton);

            var conditionalBtn = btn.CommandArgument;

            var userauthkey = ProductionRepository.CheckAuth(tbLogin.Text);

            // authkey


            tbLogin.Text = "";

            if (userauthkey == "" || userauthkey == null)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage2", @"alert('Your Auth Key not valid');", true);
                return;
            }
            //string line = _lineId;
            //var jcSerial = txtSerialNumberJC.Text;
            var prodSerial = txtSerialNumberProd.Text;

            try
            {
                if (ProductionRepository.CheckModelInSequence(prodSerial) == null)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Model not found, please check Production Sequence !');", true);
                }

                else if (ProductionRepository.CheckVariantInSequence(prodSerial) == null)
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Variant not found, please check Production Sequence !');", true);
                }

                else if (string.IsNullOrWhiteSpace(ProductionRepository.CheckSerialNumberInSequence(prodSerial)))
                {
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Serial Number/ VIN/ Order No : " + prodSerial + " Not Listed in Production Sequence!');", true);
                }
                else
                {
                    var stationId = ProductionRepository.GetFirstStation(assemblyTypeId);
                    //Check routing exist
                    //var CheckDataInFirstStation = ProductionRepository.GetVehicleCountInStation(stationId, _productionLineId);
                    var notif = ProductionRepository.IsExistProductionRoute(prodSerial, assemblyTypeId);


                    if (notif)
                    {
                        //TODO: Confirm what is the purpose for this
                        //TODO: Is it to make sure that if vehicle count in first station > 0, it will always fail
                        //if (CheckDataInFirstStation == 0)
                        //{

                        var CheckFinNumber = ProductionRepository.GetFinNumber(prodSerial, assemblyTypeId);
                        var prod           = ProductionRepository.GetProductionHistoryInMainLines(CheckFinNumber, assemblyTypeId);

                        if (prod == null)
                        {
                            if (!ProductionRepository.GetCapacityCountInStation(stationId, _productionLineId))
                            {
                                throw new Exception("Next Station Max Capacity");
                            }
                            else
                            {
                                //Insert new productionHistory. if it already exist in subassy, replace it with the current line
                                var histId = ProductionRepository.InsertProductionHistory(_productionLineId, assemblyTypeId, prodSerial, "");
                                var detail = ProductionRepository.InsertProductionHistoryDetail(histId, stationId, false, false, "");
                                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('Check VIN Number data successfully !');window.location ='../Production/ProductionDashboard.aspx'", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('VIN Number is already used !');", true);
                        }

                        //}
                        //else
                        //        ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('" + notif + "!');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Production route is not found!');", true);
                    }
                }
            }
            catch (Exception ex)
            {
                AppLogger.LogError(ex.Message);
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('Failed. " + ex.Message + " !');", true);
            }
        }
Example #2
0
        protected void btnAddSubAssy_Click(object sender, EventArgs e)
        {
            var _finNumber        = tbAddSubAssy.Text;
            var redirectWithError = string.Empty;

            //TODO: check for authkey

            //is exist in main line
            if (string.IsNullOrWhiteSpace(_finNumber))
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('Serial number cannot be empty !');", true);
                return;
            }
            var CheckFinNumber = ProductionRepository.GetFinNumber(_finNumber, assemblyTypeId);

            if (string.IsNullOrWhiteSpace(ProductionRepository.CheckSerialNumberInSequence(CheckFinNumber)))
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Serial number " + _finNumber + " not in Production !');", true);
                return;
            }

            //is exist in material assy production
            if (ProductionRepository.IsExistProductionMaterialHistory(CheckFinNumber, _sectionId, assemblyTypeId))
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Sub Assembly for " + _finNumber + " has already exist !');", true);
                return;
            }

            //NOTE: No need to check for ProductionRoute. It is already checked in VINNumberChecker
            //var notif = ProductionRepository.IsExistProductionRoute(_finNumber, assemblyTypeId);
            //if (notif == "exist")
            //{
            //TODO: confirm LineId for SubAssy is 20 (or is it 0?)
            int histId = 0;

            var prod = ProductionRepository.GetProductionHistoryInMainLines(CheckFinNumber, assemblyTypeId);

            if (prod != null)
            {
                histId = prod.Id;
            }

            if (histId == 0)
            {
                //not exist in main lines, create one
                //Note: if it already exist in SubAssy, it will replace the line to represent the current line
                histId = ProductionRepository.InsertProductionHistory(_lineId, assemblyTypeId, CheckFinNumber, "");
            }

            if (histId == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", "alert('Failed add " + CheckFinNumber + " to this Sub Assy, Production Sequence with Serial Number " + CheckFinNumber + " is not found. !');", true);
                return;
            }

            //add to productionmaterial assembly
            var startStationId = ProductionRepository.GetFirstStationInAssemblySection(_sectionId);
            int prodMatHist    = ProductionRepository.InsertProductionMaterialHistory(CheckFinNumber, startStationId, assemblyTypeId);

            if (prodMatHist > 0)
            {
                //add to details
                if (0 != ProductionRepository.InsertProductionHistoryDetail(histId, startStationId, false, false, ""))
                {
                    //set historyId and _stationid
                    _historyId                  = histId;
                    tbAddSubAssy.Text           = string.Empty;
                    pcAddSubAssy.ShowOnPageLoad = false;
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('" + CheckFinNumber + " add successfully to this Sub Assy !');window.location ='../Production/ProductionDashboardDetail.aspx?Type=" + 0 + "&Hist=" + histId + "&Stat=" + startStationId + "&Sect=" + _sectionId + "'", true);
                }
                else
                {
                    //failed to save detail?then delete material from gravity
                    ProductionRepository.DeleteProductionHistoryMaterial(CheckFinNumber, startStationId);
                    redirectWithError = "Failed add " + CheckFinNumber + " to this Sub Assy !";
                }
            }
            else
            {
                //failed to add new material
                redirectWithError = "Failed add " + CheckFinNumber + " to this Sub Assy !";
            }
            //}
            //}

            if (!string.IsNullOrWhiteSpace(redirectWithError))
            {
                pcAddSubAssy.ShowOnPageLoad = false;
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage", @"alert('" + redirectWithError + "')", true);
            }
        }