protected void IdBtndelete_Click(object sender, EventArgs e) { ASPxButton btn = sender as ASPxButton; GridViewDataItemTemplateContainer container = btn.NamingContainer as GridViewDataItemTemplateContainer; var Rowindex = container.VisibleIndex; int ValueRowId = int.Parse(GVDataAttachment.GetRowValues(Rowindex, "Id").ToString()); //var Data = Session["DataDetail"]; var oldattachImage = Session["dtAttachment"] as List <ProductionFaultReleaseAttachmentModel>; DataTable Datax = Session["dtAttachment"] as DataTable; //List<DocumentAttachment> ListAttachFile = new List<DocumentAttachment>(); //List<DataRow> list = Datax.AsEnumerable().ToList(); //int Id = int.Parse(Datax.Rows[0].ItemArray[0].ToString()); for (int i = 0; i < Datax.Rows.Count; i++) { int Id = int.Parse(Datax.Rows[i].ItemArray[0].ToString()); if (Id == ValueRowId) { DataRow dr = Datax.Rows[i]; dr.Delete(); // dr.AcceptChanges(); } } DataTable DataNew = new DataTable(); DataNew = Datax; GVDataAttachment.DataSource = DataNew; Session["dtAttachment"] = DataNew; GVDataAttachment.DataBind(); }
public ProductionReleaseFaultModel faultRecord() { var finnumber = ""; if (CSTypeValue.Text.ToString() != "-Select-") { int csType = CSTypeValue.Text.ToString() == "" ? 0 : int.Parse(CSTypeValue.SelectedItem.Value.ToString()); } else { FaultRecord FaultInput = new FaultRecord(); //FaultInput.CSType = CSTypeValue.Text == "" ? 0 : int.Parse(CSTypeValue.SelectedItem.Value.ToString()); FaultInput.Remarks = "MandatoryEmpty"; ProductionReleaseFaultModel InsertFaultRecordFault = new ProductionReleaseFaultModel(); { InsertFaultRecordFault.FaultRecordModels = FaultInput; }; return(InsertFaultRecordFault); } var ncp = tbNCP.Text; // int productionHistoriesId = cbFINNumber.Value == null ? 0 : Convert.ToInt32(cbFINNumber.SelectedItem.Text); int productionHistoriesId = 0; var faultNumber = "32054"; int QGate = Convert.ToInt32(cbQG.Value); int station = Convert.ToInt32(cbStation.Value); ListEditItem selectedItem = cbFINNumber.SelectedItem; if (cbFINNumber.Text.ToString() == "-Select-") { FaultRecord FaultInputfailed = new FaultRecord(); FaultInputfailed.CSType = CSTypeValue.Text == "" ? 0 : int.Parse(CSTypeValue.SelectedItem.Value.ToString()); FaultInputfailed.Remarks = "MandatoryEmpty2"; ProductionReleaseFaultModel InsertFaultRecordFaultfailed = new ProductionReleaseFaultModel(); { InsertFaultRecordFaultfailed.FaultRecordModels = FaultInputfailed; }; return(InsertFaultRecordFaultfailed); } else { // finnumber = cbFINNumber.Text == "1" ? Session["FINNumber"].ToString() : cbFINNumber.Text; finnumber = selectedItem.GetValue("FINNumber").ToString(); } var tempAssemblySection = ProductionRepository.GetAssemblySection(station); int assemblySectionId = tempAssemblySection.Id; var tempProductionLine = ProductionRepository.GetLineByProductionId(productionHistoriesId); int productionLineId = tempProductionLine.Id; var cgisId = Convert.ToInt32(cbCGIS.Value); int priority = Convert.ToInt32(cbPriority.Value); int partProces = Convert.ToInt32(cbPartProces.Value); int faultRelated = Convert.ToInt32(cbFaultRelated.Value); int faultDescId; if (int.TryParse(cbFaultDesc.Value.ToString(), out faultDescId)) { faultDescId = Convert.ToInt32(cbFaultDesc.Value); } else { faultDescId = ProductionRepository.InputNonStandard(cbFaultDesc.Value.ToString()); } var faultDescText = cbFaultDesc.Text; int inspectorId = Convert.ToInt32(cbInspector.Value); var inspectorName = cbInspector.SelectedItem; int stampId = Convert.ToInt32(cbStamp.Value); // var stampName = cbStamp.SelectedItem; var stampName = ""; var remark = tbRemark.Text; bool recti = Convert.ToBoolean(cbRecti.Value.ToInt32()); FaultRecord DataFault = new FaultRecord(); DataFault.CSType = CSTypeValue.Text == "-Select-" ? 0 : int.Parse(CSTypeValue.SelectedItem.Value.ToString()); DataFault.NCP = ncp; DataFault.ProductionHistoriesId = productionHistoriesId; DataFault.FaultNumber = faultNumber; DataFault.QualityGateId = QGate; DataFault.AssemblySectionId = assemblySectionId; DataFault.ProductionLinesId = productionLineId; DataFault.StationId = station; DataFault.FINNumber = finnumber.ToString(); DataFault.CGISId = cgisId; DataFault.Priority = priority; DataFault.FaultPartProcessId = partProces; DataFault.FaultRelatedTypeId = faultRelated; DataFault.FaultDescriptionId = faultDescId; DataFault.FaultDescriptionText = faultDescText; DataFault.InspectorUserId = inspectorId == null ? 0 : inspectorId; DataFault.InspectorName = inspectorName.ToString(); DataFault.StamperUserID = stampId; DataFault.StamperName = stampName.ToString(); DataFault.Remarks = remark; DataFault.IsSentToRectification = recti; DataFault.UserAuth = ""; var SumRowData = GVDataAttachment.VisibleRowCount; List <DocumentAttachment> ListAttachFile = new List <DocumentAttachment>(); for (int i = 0; i < SumRowData; i++) { DocumentAttachment AttachFile = new DocumentAttachment(); AttachFile.FileName = GVDataAttachment.GetRowValues(i, "FileName").ToString(); AttachFile.FilePath = GVDataAttachment.GetRowValues(i, "FileLocation").ToString(); ListAttachFile.Add(AttachFile); } ProductionReleaseFaultModel InsertFaultRecord = new ProductionReleaseFaultModel(); { InsertFaultRecord.FaultRecordModels = DataFault; InsertFaultRecord.AttachmentModels = ListAttachFile; }; return(InsertFaultRecord); }
protected void btnSaveClose_Click(object sender, EventArgs e) { if (HiddenText["Edit"].ToString() == "0") { var fault = faultRecord(); if (fault.FaultRecordModels.Remarks != "MandatoryEmpty") { if (fault.FaultRecordModels.Remarks != "MandatoryEmpty2") { var GetIdFault = FaultRepository.InsertFaultRecordReleaseDynamic(fault.FaultRecordModels); for (int x = 0; x < fault.AttachmentModels.Count(); x++) { var id = cbFINNumber.Text.Split('/')[1].Trim(); FaultRepository.InsertAttachMent(fault.AttachmentModels[x].FileName, fault.AttachmentModels[x].FilePath, id, GetIdFault); } //add to fault record //close popUpControl Fault pcInteruptFault.ShowOnPageLoad = false; //binding again grid Fault gridFault.DataBind(); // detailCondition.ImageUrl = FaultRepository.IsHaveFault(_historyId) ? urlImgNotifRed : urlImgNotifGreen; //} } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage2", @"alert('Please Fill FinNumber');", true); } } else { ScriptManager.RegisterClientScriptBlock(this, GetType(), "alertMessage4", @"alert('Please Fill CSType');", true); } Response.Redirect("../Production/ProductionReleaseFault.aspx"); } else { var model = new FaultRecord(); int IdFault = int.Parse(HiddenText["IdFault"].ToString()); model.FaultRecordId = IdFault; model.FaultStatus = faultStatus.Text == "" ? 0 : int.Parse(faultStatus.SelectedItem.Value.ToString()); model.Remarks = tbRemark.Text.ToString(); model.Priority = cbPriority.SelectedItem == null ? 0 : int.Parse(cbPriority.Value.ToString()); model.FaultDescriptionId = cbFaultDesc.SelectedItem == null ? 0 : int.Parse(cbFaultDesc.Value.ToString()); model.FaultRelatedTypeId = cbFaultRelated.SelectedItem == null ? 0 : int.Parse(cbFaultRelated.Value.ToString()); FaultRepository.UpdateFaultRecord(model); FaultRepository.Delete(IdFault); var SumRowData = GVDataAttachment.VisibleRowCount; List <DocumentAttachment> ListAttachFile = new List <DocumentAttachment>(); for (int i = 0; i < SumRowData; i++) { DocumentAttachment AttachFile = new DocumentAttachment(); AttachFile.FileName = GVDataAttachment.GetRowValues(i, "FileName").ToString(); AttachFile.FilePath = GVDataAttachment.GetRowValues(i, "FileLocation").ToString(); ListAttachFile.Add(AttachFile); } for (int x = 0; x < ListAttachFile.Count(); x++) { var Fin = cbFINNumber.Text; FaultRepository.InsertAttachMent(ListAttachFile[x].FileName, ListAttachFile[x].FilePath, Fin, IdFault); } pcInteruptFault.ShowOnPageLoad = false; pcInteruptFaultx.ShowOnPageLoad = false; Response.Redirect("../Production/ProductionReleaseFault.aspx"); } }