private void btnPreview_Click(object sender, EventArgs e) { if (IsSelValid()) { RT2020.Controls.Reporting.Viewer viewer = new RT2020.Controls.Reporting.Viewer(); string[,] param = { { "FromToTxNumber", this.cboFrom.Text.Trim() }, { "ToTxNumber", this.cboTo.Text.Trim() }, { "FromTxDate", this.dtpTxDateFrom.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "ToTxDate", this.dtpTxDateTo.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "PrintedBy", StaffEx.GetStaffNameById(ConfigHelper.CurrentUserId) }, { "PrintedOn", DateTime.Now.ToString(DateTimeHelper.GetDateFormat()) }, { "DateFormat", DateTimeHelper.GetDateFormat() }, { "CompanyName", SystemInfoEx.CurrentInfo.Default.CompanyName }, { "StockCode", SystemInfoHelper.Settings.GetSystemLabelByKey("STKCODE") }, { "Appendix1", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX1") }, { "Appendix2", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX2") }, { "Appendix3", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX3") } }; viewer.Datasource = BindData(); viewer.ReportDatasourceName = "RT2020_Controls_Reporting_DataSource_vwRptBatchTXF"; viewer.ReportName = "RT2020.Inventory.Transfer.Reports.WorksheetRdl.rdlc"; viewer.Parameters = param; viewer.Show(); } }
private bool IsValid() { bool result = true; errorProvider.SetError(txtStaffNumber, string.Empty); #region Staff Number 唔可以吉 errorProvider.SetError(txtStaffNumber, string.Empty); if (txtStaffNumber.Text.Trim() == string.Empty) { errorProvider.SetError(txtStaffNumber, "Cannot be blank!"); return(false); } #endregion #region 新增,要 check Staff Number 係咪 in use if (_EditMode == EnumHelper.EditMode.Add && txtStaffNumber.Text.Trim() != string.Empty) { if (StaffEx.IsStaffNumberInUse(txtStaffNumber.Text.Trim())) { errorProvider.SetError(txtStaffNumber, "Staff Number in use"); return(false); } } #endregion return(result); }
private void cmdPreview_Click(object sender, EventArgs e) { if (IsSelValid()) { string[,] param = { { "FromTxNumber", this._TxNumberFrom }, { "ToTxNumber", this._TxNumberTo }, { "FromTxDate", this.dtpTxDateFrom.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "ToTxDate", this.dtpTxDateTo.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "PrintedOn", DateTime.Now.ToString(DateTimeHelper.GetDateTimeFormat()) }, { "PrintedBy", StaffEx.GetStaffNameById(ConfigHelper.CurrentUserId) }, { "DateFormat", DateTimeHelper.GetDateFormat() }, { "CompanyName", SystemInfoEx.CurrentInfo.Default.CompanyName }, { "StockCode", SystemInfoHelper.Settings.GetSystemLabelByKey("STKCODE") }, { "Appendix1", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX1") }, { "Appendix2", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX2") }, { "Appendix3", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX3") } }; RT2020.Controls.Reporting.Viewer oViewer = new RT2020.Controls.Reporting.Viewer(); oViewer.Datasource = BindData(); oViewer.ReportName = "RT2020.Inventory.Adjustment.Reports.HistoryRdl.rdlc"; oViewer.ReportDatasourceName = "RT2020_Controls_Reporting_DataSource_vwRptSubLedgerADJ"; oViewer.Parameters = param; oViewer.Show(); } }
private void LoadHeaderInfo() { if (this.HHTHeaderId != null) { using (var ctx = new EF6.RT2020Entities()) { var hhtHeader = ctx.StocktakeHeader_HHT.Where(x => x.HeaderId == this.HHTHeaderId).AsNoTracking().FirstOrDefault(); if (hhtHeader != null) { txtTxNumber.Text = hhtHeader.TxNumber; txtWorkplace.Text = WorkplaceEx.GetWorkplaceCodeById(hhtHeader.WorkplaceId.Value); txtHHTId.Text = hhtHeader.HHTId; txtUploadedOn.Text = hhtHeader.UploadedOn.Value.ToString("dd MMM yyyy HH:mm:ss"); txtCreatedOn.Text = hhtHeader.CreatedOn.ToString("dd MMM yyyy HH:mm:ss"); txtCreatedBy.Text = StaffEx.GetStaffNumberById(hhtHeader.CreatedBy); txtTotalLine_HHTData.Text = hhtHeader.TotalRows.Value.ToString("n0"); txtTotalLine_StockTake.Text = hhtHeader.TotalRows.Value.ToString("n0"); txtTotalLine_MissingBarcode.Text = hhtHeader.MissingRows.Value.ToString("n0"); txtTotalQty_HHTData.Text = hhtHeader.TOTALQTY.Value.ToString("n0"); txtTotalQty_StockTake.Text = hhtHeader.TOTALQTY.Value.ToString("n0"); txtTotalQty_MissingBarcode.Text = hhtHeader.MissingQty.Value.ToString("n0"); LoadDetailsInfo(hhtHeader.HeaderId); } } } }
private void LoadRplInfo() { var oHeader = InvtBatchRPL_HeaderEx.Get(this.RplId); if (oHeader != null) { txtTxNumber.Text = oHeader.TxNumber; cboFromLocation.Text = oHeader.FromLocation; cboToLocation.Text = oHeader.ToLocation; cboOperatorCode.SelectedValue = oHeader.StaffId; cboStatus.Text = (oHeader.Status == 0) ? "HOLD" : "POST"; dtpTxDate.Value = oHeader.TxDate.Value; dtpTxferDate.Value = oHeader.TXFOn.Value; dtpCompDate.Value = oHeader.CompletedOn.Value; txtRemarks.Text = oHeader.Remarks; txtLastUpdateOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn, false); txtLastUpdateBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy); txtTxConfirmed.Text = oHeader.Confirmed ? "Y" : "N"; txtConfirmedBy.Text = StaffEx.GetStaffNumberById(oHeader.ConfirmedBy.Value); txtConfirmedOn.Text = DateTimeHelper.DateTimeToString(oHeader.ConfirmedOn.Value, false); txtSpecialRequest.Text = oHeader.SpecialRequest ? "Y" : "N"; this.tbWizardAction.Buttons[0].Enabled = !oHeader.Confirmed; this.tbWizardAction.Buttons[2].Enabled = !oHeader.Confirmed; this.tbWizardAction.Buttons[4].Enabled = !oHeader.Confirmed; BindRplDetailsInfo(); } }
private void cmdPreview_Click() { string[,] param = { { "FromTxNumber", this.txtTxNumber.Text.Trim() }, { "ToTxNumber", this.txtTxNumber.Text.Trim() }, { "FromTxDate", this.dtpRecvDate.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "ToTxDate", this.dtpRecvDate.Value.ToString(DateTimeHelper.GetDateFormat()) }, { "PrintedOn", DateTime.Now.ToString(DateTimeHelper.GetDateTimeFormat()) }, { "PrintedBy", StaffEx.GetStaffNameById(ConfigHelper.CurrentUserId) }, { "StockCode", SystemInfoHelper.Settings.GetSystemLabelByKey("STKCODE") }, { "Appendix1", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX1") }, { "Appendix2", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX2") }, { "Appendix3", SystemInfoHelper.Settings.GetSystemLabelByKey("APPENDIX3") }, { "DateFormat", DateTimeHelper.GetDateFormat() }, { "CompanyName", SystemInfoEx.CurrentInfo.Default.CompanyName } }; RT2020.Controls.Reporting.Viewer oViewer = new RT2020.Controls.Reporting.Viewer(); oViewer.Datasource = BindData(); oViewer.ReportName = "RT2020.Inventory.GoodsReturn.Reports.WorksheetRdl.rdlc"; oViewer.ReportDatasourceName = "RT2020_Controls_Reporting_DataSource_vwRptBatchCAP"; oViewer.Parameters = param; oViewer.Show(); }
private void CreateADJTx(Guid headerId) { using (var ctx = new EF6.RT2020Entities()) { var oBatchHeader = ctx.StockTakeHeader.Find(headerId); if (oBatchHeader != null) { oBatchHeader.PostedOn = DateTime.Now; ctx.SaveChanges(); this.UpdateProduct(oBatchHeader.HeaderId, oBatchHeader.WorkplaceId.Value); // Create Ledger for TxType 'STK' string txNumber_Ledger = SystemInfoHelper.Settings.QueuingTxNumber(EnumHelper.TxType.ADJ); Guid ledgerHeaderId = CreateLedgerHeader(txNumber_Ledger, oBatchHeader); CreateLedgerDetails( txNumber_Ledger, ledgerHeaderId, oBatchHeader.HeaderId, StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId), WorkplaceEx.GetWorkplaceCodeById(oBatchHeader.WorkplaceId.Value) ); oBatchHeader.ADJNUM = txNumber_Ledger; ctx.SaveChanges(); } } }
/** * private void UpdateHeaderInfo() * { * InvtBatchCAP_Header oHeader = InvtBatchCAP_Header.Load(this.REJId); * if (oHeader != null) * { * oHeader.TotalAmount = Convert.ToDecimal(Common.Utility.IsNumeric(txtTotalAmount.Text) ? txtTotalAmount.Text : "0"); * oHeader.Save(); * * // log activity (Update) * RT2020.Controls.Log4net.LogInfo(RT2020.Controls.Log4net.LogAction.Update, oHeader.ToString()); * } * } */ #endregion #region Load REJ Header Info private void LoadREJInfo() { var oHeader = InvtBatchCAP_HeaderEx.Get(this.REJId); if (oHeader != null) { txtTxNumber.Text = oHeader.TxNumber; txtTxType.Text = oHeader.TxType; cboWorkplace.SelectedValue = oHeader.WorkplaceId; cboOperatorCode.SelectedValue = oHeader.StaffId; cboStatus.Text = (oHeader.Status == 0) ? "HOLD" : "POST"; dtpRecvDate.Value = oHeader.TxDate.Value; cboSupplierList.SelectedValue = oHeader.SupplierId; txtSupplierInvoice.Text = oHeader.SupplierRefernce; txtRemarks.Text = oHeader.Remarks; txtRefNumber.Text = oHeader.Reference; txtLastUpdateOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn, false); txtLastUpdateBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy); txtAmendmentRetrict.Text = oHeader.ReadOnly ? "Y" : "N"; chkAPLink.Checked = oHeader.LinkToAP; txtTotalQty.Text = InvtBatchCAP_DetailsEx.GetTotalQty(this.REJId).ToString("n0"); txtTotalAmount.Text = InvtBatchCAP_DetailsEx.GetTotalAmount(this.REJId).ToString("n2"); this.Text += oHeader.ReadOnly ? " (ReadOnly)" : ""; BindREJDetailsInfo(); } }
/// <summary> /// Fills the staff list. /// </summary> private void FillStaffList() { string[] textField = new string[] { "StaffNumber", "FullName" }; string pattern = "{0} - {1}"; string[] orderBy = new string[] { "StaffNumber" }; StaffEx.LoadCombo(ref cboStaffList, textField, pattern, true, true, WestwindHelper.GetWord("glossary.all", "General"), "Retired = 0", orderBy); }
private void FillComboBox() { StaffEx.LoadCombo(ref cmbFrmStaffCode, "StaffNumber", false); StaffEx.LoadCombo(ref cmbToStaffCode, "StaffNumber", false); cmbToStaffCode.SelectedIndex = cmbToStaffCode.Items.Count - 1; }
/// <summary> /// Authes the logon. /// </summary> /// <returns></returns> private bool AuthLogon() { if (Verify()) { var oUser = UserProfileEx.GetLoginUser(txtStaffNumber.Text.Trim().Replace("'", ""), txtPassword.Text.Trim().Replace("'", "")); if (oUser != null) { var oStaff = StaffEx.GetByStaffId(oUser.UserSid); if (oStaff != null) { if (oStaff.Status > Convert.ToInt32(EnumHelper.Status.Inactive.ToString("d"))) { if (!oStaff.Retired) { this.Context.Session.IsLoggedOn = true; ConfigHelper.CurrentUserId = oStaff.StaffId; ConfigHelper.CurrentZoneId = new Guid(cboZone.SelectedValue.ToString()); ConfigHelper.CurrentUserType = oUser.UserType.Value; // The below code will logout the loggedin user when idle for the time specified if (ConfigurationManager.AppSettings["sessionTimeout"] != null) { this.Context.HttpContext.Session.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings["sessionTimeout"]); } RT2020.Controls.Log4net.LogInfo(RT2020.Controls.Log4net.LogAction.Login, this.ToString()); } else { this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("msg_retired_staff"); this.Context.Session.IsLoggedOn = false; } } else { this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("msg_inactive_staff"); this.Context.Session.IsLoggedOn = false; } } } else { // When user inputs incorrect staff number or password, prompt user the error message. // To Do: We can try to limited the times of attempt to 5 or less. this.lblErrorMessage.Text = RT2020.Controls.Utility.Dictionary.GetWord("err_incorrect_staff"); this.Context.Session.IsLoggedOn = false; } } else { this.Context.Session.IsLoggedOn = false; } return(this.Context.Session.IsLoggedOn); }
/// <summary> /// the Allowed permission. /// According to PermissionLevel: /// 1, 2, 3 - Can Read /// 4, 5, 6 - Can Write /// 7, 8 - Can Modify /// 9 - All /// </summary> /// <returns></returns> private static EnumHelper.Permission AllowedPermission() { bool canRead = true, canWrite = false, canDelete = false, canPost = false; EnumHelper.Permission allowedPermission = EnumHelper.Permission.Read; //string query = "StaffId = '" + ConfigHelper.CurrentUserId.ToString() + "' AND GradeCode = '" + PermissionLevel() + "'"; var oSecurity = StaffSecurityEx.GetByStaffId(ConfigHelper.CurrentUserId, PermissionLevel()); if (oSecurity != null) { canRead = oSecurity.CanRead.Value; canWrite = oSecurity.CanWrite.Value; canDelete = oSecurity.CanDelete.Value; canPost = oSecurity.CanPost.Value; } else { var oStaff = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (oStaff != null) { var oGroup = StaffGroupEx.GetById(oStaff.GroupId.Value); if (oGroup != null) { canRead = oGroup.CanRead.Value; canWrite = oGroup.CanWrite.Value; canDelete = oGroup.CanDelete.Value; canPost = oGroup.CanPost.Value; } } } if (canRead) { allowedPermission = EnumHelper.Permission.Read; } if (canWrite) { allowedPermission = allowedPermission | EnumHelper.Permission.Write; } if (canDelete) { allowedPermission = allowedPermission | EnumHelper.Permission.Delete; } if (canPost) { allowedPermission = allowedPermission | EnumHelper.Permission.Posting; } return(allowedPermission); }
public static String SecurityLevel() { String result = String.Empty; var staff = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (staff != null) { result = StaffGroupEx.GetGradeCodeById(staff.GroupId.Value); } return(result); }
private void LoadCoreData() { using (var ctx = new EF6.RT2020Entities()) { var staff = ctx.Staff.Find(_StaffId); if (staff != null) { txtInitial.Text = staff.StaffCode; txtFirstName.Text = staff.FirstName; txtLastName.Text = staff.LastName; txtName.Text = staff.FullName; txtNameChs.Text = staff.FullName_Chs; txtNameCht.Text = staff.FullName_Cht; txtPassword.Text = staff.Password; txtCreationDate.Text = DateTimeHelper.DateTimeToString(staff.CreatedOn, false); txtLastUpdate.Text = DateTimeHelper.DateTimeToString(staff.ModifiedOn, false); txtModified.Text = StaffEx.GetStaffNumberById(staff.ModifiedBy); txtStateOffice.Text = ""; txtStateCounter.Text = ""; cboPosition.SelectedValue = staff.JobTitleId.HasValue ? staff.JobTitleId.Value : Guid.Empty; cmbStaffGrade.SelectedValue = staff.GroupId.HasValue ? staff.GroupId.Value : Guid.Empty; cboDeptCode.SelectedValue = staff.DeptId.HasValue ? staff.DeptId.Value : Guid.Empty; #region txtStateOffice.Text if (staff.DownloadToPOS) { if (staff.CreatedOn.Date.Equals(staff.ModifiedOn.Date)) { txtStateOffice.Text = "A"; } else { txtStateOffice.Text = "M"; } } #endregion #region txtStateCounter.Text if (staff.DownloadToCounter) { if (staff.CreatedOn.Date.Equals(staff.ModifiedOn.Date)) { txtStateCounter.Text = "A"; } else { txtStateCounter.Text = "M"; } } #endregion } } }
private void FillAssistants() { var textFields = new string[] { "StaffNumber", "StaffCode" }; var pattern = "{0} - {1}"; var sql = string.Format("StaffId NOT IN ('{0}') AND Status > 0", _StaffId.ToString()); var orderBy = new string[] { "StaffNumber" }; StaffEx.LoadCombo(ref cboSmartTag5, textFields, pattern, true, true, string.Empty, sql, orderBy); //if (cboSmartTag6.Items.Count > 0) cboSmartTag6.SelectedIndex = 0; StaffEx.LoadCombo(ref cboSmartTag6, textFields, pattern, true, true, string.Empty, sql, orderBy); //if (cboSmartTag7.Items.Count > 0) cboSmartTag7.SelectedIndex = 0; }
public static string PermissionLevel() { string result = "1"; // Guest var user = StaffEx.GetByStaffId(ConfigHelper.CurrentUserId); if (user != null) { result = StaffGroupEx.GetGradeCodeById(user.GroupId.Value); } return(result); }
private string BuildLog() { StringBuilder log = new StringBuilder(); log.Append("COMPANY: ").Append(SystemInfoEx.CurrentInfo.Default.CompanyName).AppendLine(); log.Append("MONTH: ").Append(SystemInfoEx.CurrentInfo.Default.CurrentSystemDate.ToString("MMMM yyyy")).AppendLine(); log.Append("Reset Service Item's CDQty = 0: ").Append(ResetSerivceItemsCDQty ? "YES" : "NO").AppendLine(); log.Append("USER: "******"START TIME: ").Append(StartOn.ToString("dd/MM/yyyy HH:mm:ss")).AppendLine(); log.Append("STOP TIME: ").Append(EndOn.ToString("dd/MM/yyyy HH:mm:ss")).AppendLine(); log.Append("RESULT: ").Append(PostedErrorMsg).AppendLine(); return(log.ToString()); }
private void ChangePassword_Load(object sender, EventArgs e) { SetCaptions(); if (_StaffId != Guid.Empty) { var Staff = StaffEx.GetByStaffId(_StaffId); if (Staff != null) { this.Password = Staff.Password; } } txtOldPwd.Focus(); }
public static bool IsSuperUser(Guid userId) { bool result = false; var staff = StaffEx.GetByStaffId(userId); if (staff != null) { if (staff.CreatedBy == Guid.Empty) { result = true; } } return(result); }
/// <summary> /// Loads this instance. /// </summary> private void LoadHeader() { using (var ctx = new EF6.RT2020Entities()) { var oHeader = ctx.PriceManagementBatchHeader.Find(this.HeaderId); if (oHeader != null) { txtTxNumber.Text = oHeader.TxNumber; dtpEffectiveDate.Value = oHeader.EffectDate.Value; cboReasonCode.SelectedValue = oHeader.ReasonId; txtRemarks.Text = oHeader.Remarks; txtModifiedOn.Text = DateTimeHelper.DateTimeToString(oHeader.ModifiedOn.Value, true); txtModifiedBy.Text = StaffEx.GetStaffNumberById(oHeader.ModifiedBy); txtCreatedOn.Text = DateTimeHelper.DateTimeToString(oHeader.CreatedOn.Value, true); } } }
private void LoadData() { using (var ctx = new EF6.RT2020Entities()) { var item = ctx.PromotionPaymentFactor.Find(_CampaignId); if (item != null) { cboWorkplace.SelectedValue = item.WorkplaceId.HasValue ? item.WorkplaceId : Guid.Empty; cboTender.SelectedValue = item.TypeId.HasValue ? item.TypeId : Guid.Empty; txtEventCode.Text = item.EventCode; txtFactorRate.Text = item.FactorRate.ToString("n2"); dtpStartDate.Value = item.StartOn.HasValue ? item.StartOn.Value : DateTimeHelper.DateZero(); dtpEndDate.Value = item.EndOn.HasValue ? item.EndOn.Value : DateTimeHelper.DateZero(); txtCreatedOn.Text = DateTimeHelper.DateTimeToString(item.CreatedOn, false); txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy); txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false); } } }
private void LoadDetail() { var oStaff = StaffEx.GetByStaffId(_StaffId); if (oStaff != null) { txtStaffNumber.Text = oStaff.StaffNumber; txtFullName.Text = oStaff.FullName; cboGrade.SelectedValue = oStaff.GroupId; } var oSecurity = StaffSecurityEx.GetById(_SecurityId); if (oSecurity != null) { chkCanRead.Checked = oSecurity.CanRead.Value; chkCanWrite.Checked = oSecurity.CanWrite.Value; chkCanPost.Checked = oSecurity.CanPost.Value; chkCanDelete.Checked = oSecurity.CanDelete.Value; } }
private void LoadCoreData() { using (var ctx = new EF6.RT2020Entities()) { var item = ctx.Supplier.Find(_SupplierId); if (item != null) { //txtSupplierCode.Text = oSupplier.SupplierCode; txtInitial.Text = item.SupplierInitial; txtName.Text = item.SupplierName; txtNameChs.Text = item.SupplierName_Chs; txtNameCht.Text = item.SupplierName_Cht; txtRemarks.Text = item.Remarks; cboMarketSector.SelectedValue = item.MarketSectorId.HasValue ? item.MarketSectorId : Guid.Empty; txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy); txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false); txtCreatedon.Text = DateTimeHelper.DateTimeToString(item.CreatedOn, false); } } }
/// <summary> /// Creates the ledger details. /// </summary> /// <param name="headerId">The header id.</param> /// <param name="subLedgerHeaderId">The sub ledger header id.</param> private void CreateLedgerDetails(Guid headerId, Guid subLedgerHeaderId, DateTime txDate, Guid workplaceId) { string query = "HeaderId = '" + subLedgerHeaderId.ToString() + "'"; using (var ctx = new EF6.RT2020Entities()) { var detailList = ctx.InvtSubLedgerADJ_Details.Where(x => x.HeaderId == subLedgerHeaderId); foreach (var detail in detailList) { //InvtSubLedgerADJ_Details detail = detailList[i]; //if (detail != null) //{ query = "HeaderId = '" + headerId.ToString() + "' AND ProductId = '" + detail.ProductId.ToString() + "'"; var objDetail = ctx.InvtLedgerDetails.Where(x => x.HeaderId == headerId && x.ProductId == detail.ProductId).FirstOrDefault(); if (objDetail == null) { objDetail = new EF6.InvtLedgerDetails(); objDetail.DetailsId = Guid.NewGuid(); objDetail.HeaderId = headerId; objDetail.TxType = detail.TxType; objDetail.TxNumber = detail.TxNumber; objDetail.LineNumber = 0; objDetail.ProductId = detail.ProductId; objDetail.SHOP = WorkplaceEx.GetWorkplaceCodeById(workplaceId); objDetail.TxDate = txDate; objDetail.OPERATOR = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId); objDetail.Qty = detail.Qty; objDetail.AverageCost = detail.AverageCost; objDetail.UnitAmount = detail.AverageCost; objDetail.Amount = detail.AverageCost * detail.Qty; ctx.InvtLedgerDetails.Add(objDetail); } //} } } }
private void LoadAppendix3() { using (var ctx = new EF6.RT2020Entities()) { var item = ctx.ProductAppendix3.Where(x => x.Appendix3Id == _AppendixId).AsNoTracking().FirstOrDefault(); if (item != null) { FillParentAppendixList(); txtCode.Text = item.Appendix3Code; txtInitial.Text = item.Appendix3Initial; txtName.Text = item.Appendix3Name; txtNameChs.Text = item.Appendix3Name_Chs; txtNameCht.Text = item.Appendix3Name_Cht; cboParentAppendix.SelectedValue = item.ParentAppendix.HasValue ? item.ParentAppendix : Guid.Empty; txtLastUpdatedOn.Text = DateTimeHelper.DateTimeToString(item.ModifiedOn, false); txtCreatedOn.Text = DateTimeHelper.DateTimeToString(item.CreatedOn, false); txtLastUpdatedBy.Text = StaffEx.GetStaffNumberById(item.ModifiedBy); SetCtrlEditable(); } } }
/** * private void UpdateTXFSubLedger(string txnumber_Batch) * { * using (var ctx = new EF6.RT2020Entities()) * { * var oSubTXF = ctx.InvtSubLedgerTXF_Header.Find(this.TxferId); * if (oSubTXF != null) * { * UpdateTXFSubLedgerDetail(oSubTXF.HeaderId); * * oSubTXF.CONFIRM_TRF = this.IsConfirmedTransaction; * oSubTXF.CONFIRM_TRF_LASTUPDATE = DateTime.Now; * oSubTXF.CONFIRM_TRF_LASTUSER = ConfigHelper.CurrentUserId; * * oSubTXF.ModifiedBy = ConfigHelper.CurrentUserId; * oSubTXF.ModifiedOn = DateTime.Now; * * ctx.SaveChanges(); * } * } * } * * private void UpdateTXFSubLedgerDetail(Guid subledgerHeaderId) * { * foreach (ListViewItem listItem in lvDetailsList.Items) * { * if (Common.Utility.IsGUID(listItem.SubItems[10].Text)) * { * string sql = "HeaderId = '" + subledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'"; * InvtSubLedgerTXF_Details oSubLedgerDetail = InvtSubLedgerTXF_Details.LoadWhere(sql); * if (oSubLedgerDetail != null) * { * if (Common.Utility.IsNumeric(listItem.SubItems[9].Text)) * { * oSubLedgerDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text); * * oSubLedgerDetail.Save(); * } * } * } * } * } */ #endregion #region Ledger /** * private void UpdateLedger(string txnumber_Batch) * { * InvtLedgerHeader oLedgerHeader = InvtLedgerHeader.Load(this.TxferId); * if (oLedgerHeader != null) * { * UpdateLedgerDetails(oLedgerHeader.HeaderId); * * oLedgerHeader.CONFIRM_TRF = this.IsConfirmedTransaction; * oLedgerHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now; * oLedgerHeader.CONFIRM_TRF_LASTUSER = ModelEx.StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId); * * oLedgerHeader.ModifiedBy = ConfigHelper.CurrentUserId; * oLedgerHeader.ModifiedOn = DateTime.Now; * oLedgerHeader.Save(); * } * } * * private void UpdateLedgerDetails(Guid ledgerHeaderId) * { * foreach (ListViewItem listItem in lvDetailsList.Items) * { * if (Common.Utility.IsGUID(listItem.SubItems[10].Text)) * { * string sql = "HeaderId = '" + ledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'"; * InvtLedgerDetails oLedgerDetail = InvtLedgerDetails.LoadWhere(sql); * if (oLedgerDetail != null) * { * if (Common.Utility.IsNumeric(listItem.SubItems[9].Text)) * { * oLedgerDetail.Qty = Convert.ToDecimal(listItem.SubItems[9].Text); * * oLedgerDetail.Save(); * } * } * } * } * } */ #endregion #region FEP /** * private void UpdateFEP() * { * FepBatchHeader oFepHeader = FepBatchHeader.Load(this.TxferId); * if (oFepHeader != null) * { * UpdateLedgerDetails(oFepHeader.HeaderId); * * oFepHeader.CONFIRM_TRF = this.IsConfirmedTransaction; * oFepHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now; * oFepHeader.CONFIRM_TRF_LASTUSER = ModelEx.StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId); * * oFepHeader.ModifiedBy = ConfigHelper.CurrentUserId; * oFepHeader.ModifiedOn = DateTime.Now; * oFepHeader.Save(); * } * } * * private void UpdateFepDetails(Guid fepHeaderId) * { * foreach (ListViewItem listItem in lvDetailsList.Items) * { * if (Common.Utility.IsGUID(listItem.SubItems[10].Text)) * { * string sql = "HeaderId = '" + fepHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'"; * FepBatchDetail oFepDetail = FepBatchDetail.LoadWhere(sql); * if (oFepDetail != null) * { * if (Common.Utility.IsNumeric(listItem.SubItems[9].Text)) * { * oFepDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text); * * oFepDetail.Save(); * } * } * } * } * } */ #endregion #region Product /** * private void UpdateProduct(InvtBatchTXF_Header oBatchHeader) * { * string sql = "HeaderId = '" + oBatchHeader.HeaderId.ToString() + "'"; * InvtBatchTXF_DetailsCollection detailsList = InvtBatchTXF_Details.LoadCollection(sql); * for (int i = 0; i < detailsList.Count; i++) * { * InvtBatchTXF_Details detail = detailsList[i]; * //Out * UpdateProductQty(detail.ProductId, oBatchHeader.FromLocation, detail.QtyConfirmed * (-1)); * //In * UpdateProductQty(detail.ProductId, oBatchHeader.ToLocation, detail.QtyConfirmed); * } * } * * private void UpdateProductQty(Guid productId, Guid workplaceId, decimal qty) * { * using (var ctx = new EF6.RT2020Entities()) * { * //string sql = "ProductId = '" + productId.ToString() + "' AND WorkplaceId = '" + workplaceId.ToString() + "'"; * var item = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == workplaceId).FirstOrDefault(); * if (item == null) * { * item = new EF6.ProductWorkplace(); * item.ProductWorkplaceId = Guid.NewGuid(); * item.ProductId = productId; * item.WorkplaceId = workplaceId; * ctx.ProductWorkplace.Add(item); * } * item.CDQTY += qty; * if (qty > 0) * { * item.RECQTY += qty; * } * ctx.SaveChanges(); * } * } */ #endregion #endregion #region Load Txfer Header Info private void LoadTxferInfo() { using (var ctx = new EF6.RT2020Entities()) { var oBatchHeader = ctx.InvtBatchTXF_Header.Find(this.TxferId); if (oBatchHeader != null) { txtTxNumber.Text = oBatchHeader.TxNumber; txtTxType.Text = oBatchHeader.TxType; cboFromLocation.SelectedValue = oBatchHeader.FromLocation; cboToLocation.SelectedValue = oBatchHeader.ToLocation; dtpTxDate.Value = oBatchHeader.TxDate.Value; txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oBatchHeader.CONFIRM_TRF_LASTUPDATE.Value, false); txtLatestConfirmedBy.Text = StaffEx.GetStaffNumberById(oBatchHeader.CONFIRM_TRF_LASTUSER.Value); txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oBatchHeader.TxType); txtConfirmationStatus.Text = oBatchHeader.CONFIRM_TRF == "Y" ? "Completed" : (oBatchHeader.CONFIRM_TRF.Trim() == "" ? "Unprocessed" : "Incompleted"); } else { #region LoadTxferLedgerInfo(); var oLedgerHeader = ctx.InvtLedgerHeader.Find(this.TxferId); if (oLedgerHeader != null) { txtTxNumber.Text = oLedgerHeader.TxNumber; txtTxType.Text = oLedgerHeader.TxType; cboFromLocation.SelectedValue = oLedgerHeader.WorkplaceId; cboToLocation.SelectedValue = oLedgerHeader.VsLocationId; dtpTxDate.Value = oLedgerHeader.TxDate.Value; txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oLedgerHeader.CONFIRM_TRF_LASTUPDATE.Value, false); txtLatestConfirmedBy.Text = oLedgerHeader.CONFIRM_TRF_LASTUSER; txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oLedgerHeader.TxType); } #endregion #region LoadTxferFepInfo(); var oFepHeader = ctx.FepBatchHeader.Find(this.TxferId); if (oFepHeader != null) { txtTxNumber.Text = oFepHeader.TxNumber; txtTxType.Text = oFepHeader.TxType; cboFromLocation.SelectedValue = WorkplaceEx.GetWorkplaceIdByCode(oFepHeader.SHOP); cboToLocation.SelectedValue = WorkplaceEx.GetWorkplaceIdByCode(oFepHeader.FTSHOP); dtpTxDate.Value = oFepHeader.TxDate.Value; txtLatestConfirmedOn.Text = DateTimeHelper.DateTimeToString(oFepHeader.CONFIRM_TRF_LASTUPDATE.Value, false); txtLatestConfirmedBy.Text = oFepHeader.CONFIRM_TRF_LASTUSER; txtRecordStatus.Text = string.Format(txtRecordStatus.Text, oFepHeader.TxType); } #endregion } } BindTxferDetailsInfo(); CalcTotal(); }
private void Confirmation() { using (var ctx = new EF6.RT2020Entities()) { using (var scope = ctx.Database.BeginTransaction()) { try { var oHeader = ctx.InvtBatchTXF_Header.Find(this.TxferId); if (oHeader != null) { var txnumber_Batch = oHeader.TxNumber; #region SaveTxferDetail(); foreach (ListViewItem listItem in lvDetailsList.Items) { Guid detailId = Guid.Empty; Guid productId = Guid.Empty; if (Guid.TryParse(listItem.Text.Trim(), out detailId) && Guid.TryParse(listItem.SubItems[10].Text.Trim(), out productId)) { //Guid detailId = new Guid(listItem.Text.Trim()); var oDetail = ctx.InvtBatchTXF_Details.Find(detailId); if (oDetail != null) { oDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text); ctx.SaveChanges(); } var oLedgerDetail = ctx.InvtLedgerDetails.Find(detailId); if (oLedgerDetail != null) { oLedgerDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text); var oSubLedgerDetail = ctx.InvtSubLedgerTXF_Details.Find(oLedgerDetail.SubLedgerDetailsId); if (oSubLedgerDetail != null) { oSubLedgerDetail.QtyConfirmed = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text); } ctx.SaveChanges(); } var oFepDetail = ctx.FepBatchDetail.Find(detailId); if (oFepDetail != null) { oFepDetail.CONFIRM_TRF_QTY = Convert.ToDecimal(listItem.SubItems[9].Text.Length == 0 ? "0" : listItem.SubItems[9].Text); ctx.SaveChanges(); } if (listItem.SubItems[9].Text.Trim().CompareTo(listItem.SubItems[8].Text.Trim()) == 0) { this.IsConfirmedTransaction = "Y"; } else { this.IsConfirmedTransaction = "N"; } } } #endregion // Update TXF SubLedger #region UpdateTXFSubLedger(oHeader.TxNumber); var oSubTXF = ctx.InvtSubLedgerTXF_Header.Find(this.TxferId); if (oSubTXF != null) { #region UpdateTXFSubLedgerDetail(oSubTXF.HeaderId); var subLedgerHeaderId = oSubTXF.HeaderId; foreach (ListViewItem listItem in lvDetailsList.Items) { Guid productId = Guid.Empty; decimal qty = 0; if (Guid.TryParse(listItem.SubItems[10].Text, out productId)) { //string sql = "HeaderId = '" + subledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'"; var oSubLedgerDetail = ctx.InvtSubLedgerTXF_Details.Where(x => x.HeaderId == subLedgerHeaderId && x.ProductId == productId).FirstOrDefault(); if (oSubLedgerDetail != null) { if (decimal.TryParse(listItem.SubItems[9].Text, out qty)) { oSubLedgerDetail.QtyConfirmed = qty; ctx.SaveChanges(); } } } } #endregion oSubTXF.CONFIRM_TRF = this.IsConfirmedTransaction; oSubTXF.CONFIRM_TRF_LASTUPDATE = DateTime.Now; oSubTXF.CONFIRM_TRF_LASTUSER = ConfigHelper.CurrentUserId; oSubTXF.ModifiedBy = ConfigHelper.CurrentUserId; oSubTXF.ModifiedOn = DateTime.Now; ctx.SaveChanges(); } #endregion // Update Ledger #region UpdateLedger(oHeader.TxNumber); var oLedgerHeader = ctx.InvtLedgerHeader.Find(this.TxferId); if (oLedgerHeader != null) { #region UpdateLedgerDetails(oLedgerHeader.HeaderId); var ledgerHeaderId = oLedgerHeader.HeaderId; foreach (ListViewItem listItem in lvDetailsList.Items) { Guid productId = Guid.Empty; decimal qty = 0; if (Guid.TryParse(listItem.SubItems[10].Text, out productId)) { //string sql = "HeaderId = '" + ledgerHeaderId.ToString() + "' AND ProductId = '" + listItem.SubItems[10].Text + "'"; var oLedgerDetail = ctx.InvtLedgerDetails.Where(x => x.HeaderId == ledgerHeaderId && x.ProductId == productId).FirstOrDefault(); if (oLedgerDetail != null) { if (decimal.TryParse(listItem.SubItems[9].Text, out qty)) { oLedgerDetail.Qty = qty; ctx.SaveChanges(); } } } } #endregion oLedgerHeader.CONFIRM_TRF = this.IsConfirmedTransaction; oLedgerHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now; oLedgerHeader.CONFIRM_TRF_LASTUSER = StaffEx.GetStaffNumberById(ConfigHelper.CurrentUserId); oLedgerHeader.ModifiedBy = ConfigHelper.CurrentUserId; oLedgerHeader.ModifiedOn = DateTime.Now; ctx.SaveChanges(); } #endregion // Update Product Info #region UpdateProduct(oHeader); var headerId = oHeader.HeaderId; var fromId = oHeader.FromLocation.Value; var toId = oHeader.ToLocation.Value; //string sql = "HeaderId = '" + oBatchHeader.HeaderId.ToString() + "'"; var detailsList = ctx.InvtBatchTXF_Details.Where(x => x.HeaderId == headerId); foreach (var detail in detailsList) { //InvtBatchTXF_Details detail = detailsList[i]; Guid productId = detail.ProductId.Value; decimal qty = 0; //Out #region UpdateProductQty(detail.ProductId.Value, fromId, detail.QtyConfirmed.Value * (-1)); qty = detail.QtyConfirmed.Value * (-1); var outPorductWorkplace = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == fromId).FirstOrDefault(); if (outPorductWorkplace == null) { outPorductWorkplace = new EF6.ProductWorkplace(); outPorductWorkplace.ProductWorkplaceId = Guid.NewGuid(); outPorductWorkplace.ProductId = productId; outPorductWorkplace.WorkplaceId = fromId; ctx.ProductWorkplace.Add(outPorductWorkplace); } outPorductWorkplace.CDQTY += qty; if (qty > 0) { outPorductWorkplace.RECQTY += qty; } ctx.SaveChanges(); #endregion //In #region UpdateProductQty(detail.ProductId.Value, toId, detail.QtyConfirmed.Value); qty = detail.QtyConfirmed.Value; var inPorductWorkplace = ctx.ProductWorkplace.Where(x => x.ProductId == productId && x.WorkplaceId == toId).FirstOrDefault(); if (inPorductWorkplace == null) { inPorductWorkplace = new EF6.ProductWorkplace(); inPorductWorkplace.ProductWorkplaceId = Guid.NewGuid(); inPorductWorkplace.ProductId = productId; inPorductWorkplace.WorkplaceId = fromId; ctx.ProductWorkplace.Add(inPorductWorkplace); } inPorductWorkplace.CDQTY += qty; if (qty > 0) { inPorductWorkplace.RECQTY += qty; } ctx.SaveChanges(); #endregion } #endregion oHeader.CONFIRM_TRF = this.IsConfirmedTransaction; oHeader.CONFIRM_TRF_LASTUPDATE = DateTime.Now; oHeader.CONFIRM_TRF_LASTUSER = ConfigHelper.CurrentUserId; oHeader.ModifiedBy = ConfigHelper.CurrentUserId; oHeader.ModifiedOn = DateTime.Now; ctx.SaveChanges(); this.TxferId = oHeader.HeaderId; } scope.Commit(); } catch (Exception ex) { scope.Rollback(); } } } }
private void FillStaffList() { StaffEx.LoadCombo(ref cboOperator, "StaffNumber", false); }
private void BindingHoldingList() { lvPostTxList.Items.Clear(); int iCount = 1; string sql = BuildSqlQueryString(EnumHelper.Status.Active.ToString("d"), true); SqlCommand cmd = new SqlCommand(); cmd.CommandText = sql; cmd.CommandTimeout = ConfigHelper.CommandTimeout; cmd.CommandType = System.Data.CommandType.Text; using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(cmd)) { while (reader.Read()) { ListViewItem objItem = this.lvPostTxList.Items.Add(reader.GetGuid(0).ToString()); // TxId objItem.SubItems.Add(string.Empty); objItem.SubItems.Add(iCount.ToString()); // Line Number objItem.SubItems.Add(reader.GetString(1)); // TxNumber objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(2), false)); // TxDate objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(2), false)); // TxferDate objItem.SubItems.Add(string.Empty); // CompletedDate objItem.SubItems.Add(reader.GetString(4)); // From Location objItem.SubItems.Add(reader.GetString(5)); // To Location objItem.SubItems.Add(DateTimeHelper.DateTimeToString(reader.GetDateTime(13), false) + " " + StaffEx.GetStaffNumberById(reader.GetGuid(14))); // Last Update iCount++; } } }
private int Import() { int result = 0; using (var ctx = new EF6.RT2020Entities()) { using (var scope = ctx.Database.BeginTransaction()) { try { for (int i = 0; i < md.Length; i++) { string txNumber = SystemInfoHelper.Settings.QueuingTxNumber(EnumHelper.TxType.TXF); #region Guid headerId = ImportTxferHeader(md[i].Master as TxferTxtIEMaster, txNumber); var master = md[i].Master as TxferTxtIEMaster; var oHeader = new EF6.InvtBatchTXF_Header(); oHeader.HeaderId = Guid.NewGuid(); oHeader.TxType = EnumHelper.TxType.TXF.ToString(); oHeader.TxNumber = txNumber; oHeader.TxDate = master.TxDate; oHeader.TransferredOn = master.TxferDate; oHeader.CompletedOn = master.CompletionDate; oHeader.FromLocation = WorkplaceEx.GetWorkplaceIdByCode(master.FromLocation); oHeader.ToLocation = WorkplaceEx.GetWorkplaceIdByCode(master.ToLocation); oHeader.StaffId = StaffEx.GetStaffIdByStaffNumber(master.Operator); oHeader.Status = Convert.ToInt32(EnumHelper.Status.Draft.ToString("d")); oHeader.Reference = master.RefNumber; oHeader.Remarks = master.Remarks; oHeader.CreatedBy = ConfigHelper.CurrentUserId; oHeader.CreatedOn = DateTime.Now; oHeader.ModifiedBy = ConfigHelper.CurrentUserId; oHeader.ModifiedOn = DateTime.Now; ctx.InvtBatchTXF_Header.Add(oHeader); ctx.SaveChanges(); Guid headerId = oHeader.HeaderId; #endregion if (headerId != Guid.Empty) { lvImportedList.Items[i].Text = txNumber; #region ImportTxferDetails(md[i].Details, headerId, txNumber); object[] details = md[i].Details; if (details != null) { for (int j = 0; j < details.Length; j++) { TxferTxtIEDetails detail = details[j] as TxferTxtIEDetails; Guid prodId = GetProductId(detail); if (prodId != Guid.Empty) { var oDetail = new EF6.InvtBatchTXF_Details(); oDetail.DetailsId = Guid.NewGuid(); oDetail.ProductId = prodId; oDetail.HeaderId = headerId; oDetail.LineNumber = j + 1; oDetail.TxNumber = txNumber; oDetail.TxType = EnumHelper.TxType.TXF.ToString(); oDetail.QtyConfirmed = 0; oDetail.QtyHHT = 0; oDetail.QtyManualInput = 0; oDetail.QtyReceived = detail.TxferQty; oDetail.QtyRequested = detail.RequiredQty; oDetail.Remarks = detail.Remarks; ctx.InvtBatchTXF_Details.Add(oDetail); ctx.SaveChanges(); result++; } } } #endregion result++; } } scope.Commit(); } catch (Exception ex) { scope.Rollback(); } } } return(result); }