private void LuuKCCK() { #region kết chuyển loại hình Thương Mại, Sản Xuất int checkSuccess = 0; //insert vouchers và voucherDetail foreach (KetChuyenValue item in KetChuyenData) { if (item.Amount == 0) { continue; } #region set value to Insert Voucher Voucher voucher = new Voucher { VoucherAmount = item.Amount, VoucherDescription = this.KetChuyenContent_textEdit.EditValue.ToString(), VouchersTypeID = "KC", VoucherDate = this.KetChuyen_bsFromToDateEdit.ToDate.Date, CompanyID = CommonInfo.CompanyInfo.CompanyID, Status = ModifyMode.Insert }; #endregion set value to Insert Voucher List <VoucherDetail> VoucherDetailData = new List <VoucherDetail>(); VoucherDetail voucherDetail = new VoucherDetail { CompanyID = CommonInfo.CompanyInfo.CompanyID, AccountID = item.KetChuyenCreditAccountID, AccountDetailID = item.KetChuyenCreditAccountDetailID, Amount = item.Amount }; string result = ""; if (item.KetChuyenCreditAccountID != "911") { //voucherDetail.CustomerID = item.CustomerID; voucherDetail.CustomerID = item.CustomerID?.ToString(); voucherDetail.QLID = item.QLID?.ToString(); string CustomerID = ""; if (!string.IsNullOrEmpty(item.CustomerID)) { CustomerID = item.CustomerID; } result = CheckDKInsertKC(false, true, item.KetChuyenCreditAccountID, item.KetChuyenCreditAccountDetailID, CustomerID, this.KetChuyen_bsFromToDateEdit.ToDate.Date, item.Amount); } else { result = CheckDKInsertKC(false, true, item.KetChuyenCreditAccountID, item.KetChuyenCreditAccountDetailID, item.CustomerID, this.KetChuyen_bsFromToDateEdit.ToDate.Date, item.Amount); } voucherDetail.NV = "C"; voucherDetail.Status = ModifyMode.Insert; VoucherDetailData.Add(voucherDetail); int checkbreak = 0;; if (result != "1") { MessageBoxHelper.ShowInfoMessage(result); checkbreak = 1; } voucherDetail = new VoucherDetail { CompanyID = CommonInfo.CompanyInfo.CompanyID, AccountID = item.KetChuyenDebitAccountID, AccountDetailID = item.KetChuyenDebitAccountDetailID, Amount = item.Amount }; if (item.KetChuyenDebitAccountID != "911") { //voucherDetail.CustomerID = item.CustomerID; voucherDetail.CustomerID = item.CustomerID?.ToString(); voucherDetail.QLID = item.QLID?.ToString(); string CustomerID = ""; if (!string.IsNullOrEmpty(item.CustomerID)) { CustomerID = item.CustomerID; } result = CheckDKInsertKC(true, false, item.KetChuyenDebitAccountID, item.KetChuyenDebitAccountDetailID, CustomerID, this.KetChuyen_bsFromToDateEdit.ToDate.Date, item.Amount); } else { result = CheckDKInsertKC(true, false, item.KetChuyenDebitAccountID, item.KetChuyenDebitAccountDetailID, item.CustomerID, this.KetChuyen_bsFromToDateEdit.ToDate.Date, item.Amount); } voucherDetail.NV = "N"; voucherDetail.Status = ModifyMode.Insert; VoucherDetailData.Add(voucherDetail); if (result != "1") { MessageBoxHelper.ShowInfoMessage(result); checkbreak = 1; } if (checkbreak == 1) { continue; } List <VoucherDetail> saveData = VoucherDetailData; if (saveData?.Count > 0) { VoucherDetailController controller = new VoucherDetailController(); if (controller.SaveVoucher_Detail(saveData, voucher)) { // MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); } else { checkSuccess = 1; MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000002); } } } Load_KetChuyen_GridView(KetChuyen_bsFromToDateEdit.FromDate.Date, this.KetChuyen_bsFromToDateEdit.ToDate.Date, CommonInfo.CompanyInfo.CompanyID); if (checkSuccess == 0) { MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); } #endregion kết chuyển loại hình Thương Mại, Sản Xuất }
private void KetChuyenSumit_simpleButton_Click(object sender, EventArgs e) { #region kiểm tra dữ liệu có đang bị khóa sổ if (VoucherControl.CheckLockDBCompany(KetChuyen_bsFromToDateEdit.ToDate.Date, CommonInfo.CompanyInfo.CompanyID)) { //Dữ liệu đang nằm trong vùng khóa sổ MessageBoxHelper.ShowErrorMessage("Dữ liệu đang bị khóa sổ!\n"); return; } #endregion kiểm tra dữ liệu có đang bị khóa sổ //Thực hiện cho loại hình không phải tour, công trình if (CommonInfo.CompareCompanyType("DL") || CommonInfo.CompareCompanyType("XD") || CommonInfo.CompareCompanyType("SX")) { #region Kết chuyển loại hình Du lịch, Xây dựng // Load_KetChuyen_GridView(KetChuyen_bsFromToDateEdit.FromDate.Date, this.KetChuyen_bsFromToDateEdit.ToDate.Date, CommonInfo.CompanyInfo.CompanyID); string value = KetChuyenType_radioGroup.EditValue.ToString(); switch (value) { case "CK": //Lấy dữ liệu cuối kỳ LuuKCCK(); break; default: //Lưu kết chuyển Dang Dở, Thành Phẩm, Giá Vốn int statusKC = 0; #region Kết chuyển loại hình Du lịch, Xây dựng foreach (KetChuyenValue item in KetChuyenData) { if (item.Amount == 0) { continue; } #region set value to Insert Voucher Voucher voucher = new Voucher { VoucherAmount = item.Amount, VoucherDescription = this.KetChuyenContent_textEdit.EditValue.ToString(), VouchersTypeID = "KC", VoucherDate = this.KetChuyen_bsFromToDateEdit.ToDate.Date, CompanyID = CommonInfo.CompanyInfo.CompanyID, Status = ModifyMode.Insert }; #endregion set value to Insert Voucher //Setup value to voucherdetail List <VoucherDetail> VoucherDetailData = new List <VoucherDetail>(); VoucherDetail voucherDetail = new VoucherDetail { CompanyID = CommonInfo.CompanyInfo.CompanyID, AccountID = item.KetChuyenCreditAccountID, AccountDetailID = item.KetChuyenCreditAccountDetailID, CustomerID = item.CustomerID?.ToString(), QLID = item.QLID?.ToString(), Amount = item.Amount, NV = "C", Status = ModifyMode.Insert }; VoucherDetailData.Add(voucherDetail); voucherDetail = new VoucherDetail { CompanyID = CommonInfo.CompanyInfo.CompanyID, AccountID = item.KetChuyenDebitAccountID, AccountDetailID = item.KetChuyenDebitAccountDetailID, CustomerID = item.CustomerID?.ToString(), QLID = item.QLID?.ToString(), Amount = item.Amount, NV = "N", Status = ModifyMode.Insert }; VoucherDetailData.Add(voucherDetail); List <VoucherDetail> saveData = VoucherDetailData; if (saveData?.Count > 0) { VoucherDetailController controller = new VoucherDetailController(); if (controller.SaveVoucher_Detail(saveData, voucher)) { // MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); } else { MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000002); statusKC = 1; } } } Load_KetChuyen_GridView(KetChuyen_bsFromToDateEdit.FromDate.Date, this.KetChuyen_bsFromToDateEdit.ToDate.Date, CommonInfo.CompanyInfo.CompanyID); if (statusKC == 0) { MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); } #endregion Kết chuyển loại hình Du lịch, Xây dựng break; } #endregion Kết chuyển loại hình Du lịch, Xây dựng } else { LuuKCCK(); } }