internal static void SetMemory(Manufacturer objectValue) { string entityName = objectValue.GetName(); // chua co thi khoi tao if (!DicMaxKeyEntity.ContainsKey(entityName)) { DicMaxKeyEntity[entityName] = 0; } // co roi thi so sanh roi set max key vao dic if (DicMaxKeyEntity[entityName] < objectValue.Id) { DicMaxKeyEntity[entityName] = objectValue.Id; } DicManufacturer[objectValue.Id] = objectValue; }
public async Task <IHttpActionResult> Post([FromBody] Manufacturer req) { try { string errorMessage = "UnknowError"; string errorCode = ErrorCodeEnum.UnknownError.ToString(); #region token var header = Request.Headers; if (header.Authorization == null) { return(StatusCode(HttpStatusCode.Unauthorized)); } var token = header.Authorization.Parameter; Employee employee; if (string.IsNullOrWhiteSpace(token) || !TokenManager.ValidateToken(token, out employee)) { return(StatusCode(HttpStatusCode.Unauthorized)); } #endregion if (!Operator.IsAdmin(employee)) { return(Ok(new RequestErrorCode(false, ErrorCodeEnum.Error_NotHavePermision.ToString(), "Khong co quyen"))); } #region Validate if (!Validate(req, out errorCode, out errorMessage)) { return(Ok(new RequestErrorCode(false, errorCode, errorMessage))); } #endregion #region Tạo key var oldKey = Memory.Memory.GetMaxKey(req.GetName()); int newKey = oldKey + 1; // set key req.Id = newKey; #endregion #region Process req.CreatedAt = DateTime.Now; req.CreatedBy = employee.Id; req.IsDeleted = 0; UpdateEntitySql updateEntitySql = new UpdateEntitySql(); var lstCommand = new List <EntityCommand>(); lstCommand.Add(new EntityCommand { BaseEntity = new Entity.Entity(req), EntityAction = EntityAction.Insert }); bool isOkDone = updateEntitySql.UpdateDefault(lstCommand); if (!isOkDone) { return(Ok(new RequestErrorCode(false, errorCode, errorMessage))); } #endregion // update memory MemorySet.UpdateAndInsertEntity(req); var result = new RequestErrorCode(true); result.DataResult = req; return(Ok(result)); } catch (Exception ex) { Logger.Write(ex.ToString()); } return(BadRequest("Unknow")); }
private void grdViewSTVDetails_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { decimal invoicedQty; decimal receivedQty; decimal difference = 0; var row = grdViewSTVDetails.GetFocusedDataRow(); string guid = row["GUID"].ToString(); receiveDoc.FindByGUID(guid); if (!receiveDoc.IsColumnNull("InvoicedNoOfPack")) { invoicedQty = receiveDoc.InvoicedNoOfPack; receivedQty = receiveDoc.NoOfPack; difference = invoicedQty - receivedQty; } if (difference > 0) { lcDiscrepancy.Visibility = LayoutVisibility.Always; bool notEntered = true; bool isNewRow = true; if (receiveDocShortage.RowCount > 0) { var noOfDiscrepancyEntries = receiveDocShortage.CountByGUID(guid); if (receiveDocShortage.FindFirstByGUID(guid)) { notEntered = false; for (int i = 0; i < noOfDiscrepancyEntries; i++) { receiveDocShortage.SetColumn("ManufacturerName", Manufacturer.GetName(receiveDoc.ManufacturerId)); receiveDocShortage.SetColumn("UnitName", ItemUnit.GetUnitText(receiveDoc.UnitID)); receiveDocShortage.SetColumn("BatchNo", receiveDoc.GetColumn("BatchNo")); receiveDocShortage.SetColumn("ExpDate", receiveDoc.GetColumn("ExpDate")); receiveDocShortage.SetColumn("FullItemName", receiveDoc.GetColumn("FullItemName")); receiveDocShortage.SetColumn("StockCode", receiveDoc.GetColumn("StockCode")); receiveDocShortage.SetColumn("GUID", receiveDoc.GetColumn("GUID")); if (noOfDiscrepancyEntries > 1) { receiveDocShortage.SetColumnNull("NoOfPacks"); } else { receiveDocShortage.NoOfPacks = difference; } } } } if (receiveDocShortage.RowCount == 0 || notEntered) { //Prepare the columns used for display } if (notEntered) { receiveDocShortage.AddNew(); if (!receiveDocShortage.DefaultView.ToTable().Columns.Contains("FullItemName")) { receiveDocShortage.AddColumn("FullItemName", typeof(string)); receiveDocShortage.AddColumn("UnitName", typeof(string)); receiveDocShortage.AddColumn("ManufacturerName", typeof(string)); receiveDocShortage.AddColumn("StockCode", typeof(string)); receiveDocShortage.AddColumn("ExpDate", typeof(string)); receiveDocShortage.AddColumn("BatchNo", typeof(string)); receiveDocShortage.AddColumn("PalletLocationID", typeof(int)); receiveDocShortage.AddColumn("GUID", typeof(string)); } receiveDocShortage.SetColumn("FullItemName", receiveDoc.GetColumn("FullItemName")); receiveDocShortage.SetColumn("UnitName", receiveDoc.GetColumn("UnitName")); receiveDocShortage.SetColumn("ManufacturerName", receiveDoc.GetColumn("ManufacturerName")); receiveDocShortage.SetColumn("StockCode", receiveDoc.GetColumn("StockCode")); receiveDocShortage.SetColumn("ExpDate", receiveDoc.GetColumn("ExpDate")); receiveDocShortage.SetColumn("BatchNo", receiveDoc.GetColumn("BatchNo")); receiveDocShortage.SetColumn("GUID", receiveDoc.GetColumn("GUID")); receiveDocShortage.NoOfPacks = difference; } } else if (difference == 0 && receiveDocShortage.RowCount != 0) { RemoveFromDiscrepancy(guid); } if (receiveDocShortage.RowCount != 0) { grdDiscrepancy.DataSource = receiveDocShortage.DefaultView; } else { lcDiscrepancy.Visibility = LayoutVisibility.Never; } }
private void EditReceived_Load(object sender, EventArgs e) { BLL.ItemManufacturer im = new BLL.ItemManufacturer(); im.LoadManufacturersFor(rDoc.ItemID); lkManufacturer.Properties.DataSource = im.DefaultView; if (BLL.Settings.UseNewUserManagement && this.HasPermission("Edit-Quantity") && (rDoc.IsColumnNull("Confirmed") || (!rDoc.IsColumnNull("Confirmed") && !rDoc.Confirmed))) { txtQuanitity.Enabled = true; } else if ((!rDoc.IsColumnNull("Confirmed") && !rDoc.Confirmed)) { txtQuanitity.Enabled = true; } else { txtQuanitity.Enabled = false; } Supplier supplier = new Supplier(); supplier.LoadAll(); lkSupplier.Properties.DataSource = supplier.DefaultView; lkAccount.SetupActivityEditor().SetDefaultActivity(); BLL.ItemUnit iu = new ItemUnit(); iu.LoadAllForItem(rDoc.ItemID); lkUnit.Properties.DataSource = iu.DefaultView; // Bind the variables) if (rDoc.RowCount > 0) { this.txtRefNo.Text = rDoc.RefNo; this.txtQuanitity.Text = Convert.ToInt32(Convert.ToDouble(rDoc.Quantity) / rDoc.QtyPerPack).ToString("#,##0"); this.txtManufacturer.Text = Manufacturer.GetName(rDoc.ManufacturerId); this.txtItemName.Text = Item.GetName(rDoc.ItemID); this.txtGrvNo.Text = rDoc.RefNo; this.lkManufacturer.EditValue = rDoc.ManufacturerId; this.lkAccount.EditValue = rDoc.StoreID; this.lkUnit.EditValue = rDoc.UnitID; if (!rDoc.IsColumnNull("SupplierID")) { lkSupplier.EditValue = rDoc.SupplierID; } // Editable controls txtPrice.Text = rDoc.IsColumnNull("Cost") ? "0" : rDoc.Cost.ToString(); if (!rDoc.IsColumnNull("ExpDate")) { dtExpiry.EditValue = rDoc.ExpDate; } if (!rDoc.IsColumnNull("BatchNo")) { txtBatchNo.Text = rDoc.BatchNo; } BLL.Item itm = new Item(); itm.LoadByPrimaryKey(rDoc.ItemID); if (BLL.Settings.UseNewUserManagement && this.HasPermission("Edit-Batch-Expiry")) { } else if (!itm.NeedExpiryBatch && (CurrentContext.LoggedInUser.UserType == UserType.Constants.ADMIN || CurrentContext.LoggedInUser.UserType == UserType.Constants.SUPER_ADMINISTRATOR)) { btnRemoveExpiry.Enabled = true; txtBatchNo.Enabled = true; } } }