private int DeleteTblIssueJournalHeader(TblIssueJournalHeader row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblIssueJournalHeaders where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
public void SaveMainRow() { if (AllowAdd != true) { MessageBox.Show(strings.AllowAddMsg); return; } var detailsl = new ObservableCollection <TblIssueJournalDetail>(); if (SelectedMainRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); foreach (var variable in SelectedMainRow.DetailList) { var valiationCollectiondetail = new List <ValidationResult>(); var isvalidDetails = Validator.TryValidateObject(variable, new ValidationContext(variable, null, null), valiationCollectiondetail, true); if (isvalidDetails) { variable.RemQty = variable.Qty; detailsl.Add(new TblIssueJournalDetail().InjectFrom(variable) as TblIssueJournalDetail); } else { return; } } if (isvalid) { var save = SelectedMainRow.Iserial == 0; var saveRow = new TblIssueJournalHeader(); saveRow.InjectFrom(SelectedMainRow); saveRow.TblIssueJournalDetails = detailsl; Loading = true; Client.UpdateOrInsertTblIssueJournalHeaderAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.Iserial); } } }
private TblIssueJournalHeader UpdateOrInsertTblIssueJournalHeader(TblIssueJournalHeader newRow, bool save, int index, int userIserial, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { if (save) { context.TblIssueJournalHeaders.AddObject(newRow); } else { var oldRow = (from e in context.TblIssueJournalHeaders where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } } context.SaveChanges(); // PostIssueHeader(newRow.Iserial, userIserial); return(newRow); } }
private void IssueJournalTransfer(TblIssueJournalHeader row, int userIserial) { using (var entities = new WorkFlowManagerDBEntities()) { if (SharedOperation.UseAx()) { var transactionGuid = Guid.NewGuid().ToString(); var vendorWmsLocation = entities.GetWmsLocations.SingleOrDefault(x => x.VENDID == row.Vendor); const string tableName = "PRODCONNECTION"; var vendorLoc = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == vendorWmsLocation.INVENTLOCATIONID); var axapta = new Axapta(); var credential = new NetworkCredential("bcproxy", "around1"); var detail = entities.TblIssueJournalDetails.Where(w => w.TblIssueJournalHeader == row.Iserial).ToList(); var userToLogin = entities.TblAuthUsers.SingleOrDefault(x => x.Iserial == userIserial); axapta.LogonAs(userToLogin.User_Win_Login, userToLogin.User_Domain, credential, "Ccm", null, null, null); axapta.CallStaticClassMethod("SysFlushAOD", "doFlush"); foreach (var item in detail) { var locationLoc = entities.GetLocations.SingleOrDefault(x => x.INVENTLOCATIONID == item.Location); AxaptaRecord AxaptaRecord = axapta.CreateAxaptaRecord(tableName); AxaptaRecord.Clear(); AxaptaRecord.InitValue(); //Transfer To Vendor's Location var fabriccode = entities.Fabric_UnitID.FirstOrDefault(w => w.Iserial == item.ItemCode); AxaptaRecord.set_Field("TRANSID", row.Iserial); AxaptaRecord.set_Field("RAWID", fabriccode.Fabric_Code); AxaptaRecord.set_Field("RAWQTY", item.Qty); AxaptaRecord.set_Field("UNITID", fabriccode.UnitID); if (locationLoc != null) { AxaptaRecord.set_Field("FROMSITE", locationLoc.INVENTSITEID); } AxaptaRecord.set_Field("FROMLOCATION", item.Location); AxaptaRecord.set_Field("FROMWAREHOUSE", item.Location); AxaptaRecord.set_Field("FROMBATCH", item.Size ?? "Free"); AxaptaRecord.set_Field("FROMCONFIG", entities.TblColors.FirstOrDefault(x => x.Iserial == item.TblColor).Code); if (vendorLoc != null) { AxaptaRecord.set_Field("TOSITE", vendorLoc.INVENTSITEID); } if (vendorWmsLocation != null) { AxaptaRecord.set_Field("TOLOCATION", vendorWmsLocation.WMSLOCATIONID); AxaptaRecord.set_Field("TOWAREHOUSE", vendorWmsLocation.INVENTLOCATIONID); } AxaptaRecord.set_Field("TOBATCH", item.Size ?? item.BatchNo ?? "Free"); AxaptaRecord.set_Field("TOCONFIG", entities.TblColors.FirstOrDefault(x => x.Iserial == item.TblColor).Code); AxaptaRecord.set_Field("TRANSTYPE", Convert.ToInt64(0)); AxaptaRecord.set_Field("JOURNALLINKID", row.Iserial); AxaptaRecord.set_Field("TransactionGuid", transactionGuid); AxaptaRecord.Insert(); } var import = axapta.CreateAxaptaObject("CLEDyeProcesse"); try { var transfer = import.Call("run", row.Iserial, row.Iserial, 0, "Name", 1, DateTime.UtcNow.ToUniversalTime()); row.AxTransaction = transfer.ToString(); row.IsPosted = true; entities.SaveChanges(); } catch (Exception) { throw; } SharedOperation.ClearAxTable("PRODCONNECTION", axapta, transactionGuid); axapta.Logoff(); } else { row.AxTransaction = "1111"; row.IsPosted = true; entities.SaveChanges(); } } }