private void linkToolStripMenuItem_Click(object sender, EventArgs e) { if (grvData.SelectedRowsCount == 0) { return; } DataTable dt = LibQLSX.Select("select * from C_ProductGroup"); foreach (int i in grvData.GetSelectedRows()) { DataTable dtLink = LibQLSX.Select("select * from C_CostProductGroupLink where C_CostID = " + TextUtils.ToInt(grvData.GetRowCellValue(i, colID))); if (dtLink.Rows.Count > 0) { MessageBox.Show("Đã được tạo"); continue; } foreach (DataRow row in dt.Rows) { C_CostProductGroupLinkModel m = new C_CostProductGroupLinkModel(); m.C_CostID = TextUtils.ToInt(grvData.GetRowCellValue(i, colID)); m.C_ProductGroupID = TextUtils.ToInt(row["ID"]); C_CostProductGroupLinkBO.Instance.Insert(m); } } MessageBox.Show("OK"); }
void updateCostProductLink() { for (int i = 0; i < grvData.RowCount; i++) { //int costID = TextUtils.ToInt(grvData.GetRowCellValue(i, "F2")); //if (costID == 0) continue; //for (int j = 1; j < 14; j++) //{ // decimal value = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F" + (2 + j))); // ArrayList arr = C_CostProductGroupLinkBO.Instance.FindByExpression(new TPA.Utils.Expression("C_CostID", costID).And(new TPA.Utils.Expression("C_ProductGroupID", j))); // C_CostProductGroupLinkModel m = (C_CostProductGroupLinkModel)arr[0]; // m.ValuePercent = value; // C_CostProductGroupLinkBO.Instance.Update(m); //} int linkID = TextUtils.ToInt(grvData.GetRowCellValue(i, "F1")); if (linkID == 0) { continue; } C_CostProductGroupLinkModel arr = (C_CostProductGroupLinkModel)C_CostProductGroupLinkBO.Instance.FindByPK(linkID); //arr.IsDirectCost = TextUtils.ToInt(grvData.GetRowCellValue(i, "F10")); arr.IsFix = TextUtils.ToInt(grvData.GetRowCellValue(i, "F9")); arr.NumberDay = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F8")); arr.PersonNumber = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F6")); arr.VtuPercent = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F7")); C_CostProductGroupLinkBO.Instance.Update(arr); } MessageBox.Show("OK"); }
void resetAll() { grvLink.FocusedRowHandle = -1; decimal totalNC = 0; string sql = "update C_QuotationDetail set TotalNC = 0 where C_QuotationID = " + C_QuotationID; LibQLSX.ExcuteSQL(sql); using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang xử lý...")) { for (int i = 0; i < grvLink.RowCount; i++) { int id = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID)); if (id == 0) { return; } int costID = TextUtils.ToInt(grvLink.GetRowCellValue(i, colC_CostID)); int quotationDetailID = TextUtils.ToInt(grvLink.GetRowCellValue(i, colC_QuotationDetailID)); C_QuotationDetailModel quotationDetail = (C_QuotationDetailModel)C_QuotationDetailBO.Instance.FindByPK(quotationDetailID); C_CostModel cost = (C_CostModel)C_CostBO.Instance.FindByPK(costID); C_CostProductGroupLinkModel group = (C_CostProductGroupLinkModel)C_CostProductGroupLinkBO.Instance.FindByExpression(new Expression("C_CostID", cost.ID) .And(new Expression("C_ProductGroupID", quotationDetail.C_ProductGroupID)))[0]; decimal pricePerDay = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPricePerDay)); decimal qty = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colQty)); C_CostQuotationItemLinkModel link = (C_CostQuotationItemLinkModel)C_CostQuotationItemLinkBO.Instance.FindByPK(id); link.PersonNumber = group.PersonNumber;// TextUtils.ToDecimal(drs[0]["PersonNumber"]); if (group.IsFix == 1) { link.NumberDay = group.NumberDay;// TextUtils.ToDecimal(drs[0]["NumberDay"]); } else { link.NumberDay = group.VtuPercent * quotationDetail.PriceVT / cost.Price; } link.TotalR = link.NumberDay * link.PersonNumber; if (cost.ID == 61)//phòng thiết kế { link.TotalR *= (1 + 0.3M * (quotationDetail.Qty - 1)) / quotationDetail.Qty; } link.Price = link.TotalR * cost.Price; C_CostQuotationItemLinkBO.Instance.Update(link); quotationDetail.TotalNC += link.Price; C_QuotationDetailBO.Instance.Update(quotationDetail); } IsSaved = true; } MessageBox.Show("Reset thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void resetToolStripMenuItem_Click(object sender, EventArgs e) { int id = TextUtils.ToInt(grvLink.GetFocusedRowCellValue(colID)); if (id == 0) { return; } int costID = TextUtils.ToInt(grvLink.GetFocusedRowCellValue(colC_CostID)); int quotationDetailID = TextUtils.ToInt(grvLink.GetFocusedRowCellValue(colC_QuotationDetailID)); C_QuotationDetailModel quotationDetail = (C_QuotationDetailModel)C_QuotationDetailBO.Instance.FindByPK(quotationDetailID); C_CostModel cost = (C_CostModel)C_CostBO.Instance.FindByPK(costID); C_CostProductGroupLinkModel group = (C_CostProductGroupLinkModel)C_CostProductGroupLinkBO.Instance.FindByExpression(new Expression("C_CostID", cost.ID) .And(new Expression("C_ProductGroupID", quotationDetail.C_ProductGroupID)))[0]; decimal pricePerDay = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colPricePerDay)); decimal qty = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colQty)); C_CostQuotationItemLinkModel link = (C_CostQuotationItemLinkModel)C_CostQuotationItemLinkBO.Instance.FindByPK(id); quotationDetail.TotalNC -= link.Price; link.PersonNumber = group.PersonNumber;// TextUtils.ToDecimal(drs[0]["PersonNumber"]); if (group.IsFix == 1) { link.NumberDay = group.NumberDay;// TextUtils.ToDecimal(drs[0]["NumberDay"]); } else { link.NumberDay = group.VtuPercent * quotationDetail.PriceVT / cost.Price; } link.TotalR = link.NumberDay * link.PersonNumber; if (cost.ID == 61)//phòng thiết kế { link.TotalR *= (1 + 0.3M * (quotationDetail.Qty - 1)) / quotationDetail.Qty; } link.Price = link.TotalR * cost.Price; C_CostQuotationItemLinkBO.Instance.Update(link); quotationDetail.TotalNC += link.Price; C_QuotationDetailBO.Instance.Update(quotationDetail); loadData(); MessageBox.Show("Reset thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); }
protected C_CostProductGroupLinkFacade(C_CostProductGroupLinkModel model) : base(model) { }
void save() { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!ValidateForm()) { return; } CurrentCost.Name = txtName.Text.Trim(); CurrentCost.Code = txtCode.Text.Trim(); CurrentCost.CostType = 0;//cboCostType.SelectedIndex; CurrentCost.C_CostGroupID = TextUtils.ToInt(leParentCat.EditValue); CurrentCost.Unit = txtUnit.Text; CurrentCost.Note = txtNote.Text; CurrentCost.Price = TextUtils.ToDecimal(txtPrice.EditValue); CurrentCost.PercentProfit = TextUtils.ToDecimal(txtPercentProfit.EditValue); CurrentCost.IsProfit = chkIsProfit.Checked ? 1 : 0; //CurrentCost.IsWithProject = chkIsWithProject.Checked ? 1 : 0; //CurrentCost.IsDirectCost = chkIsDirectCost.Checked ? 1 : 0; CurrentCost.IsWithProject = rdoIsWithProject.Checked ? 1 : 0; CurrentCost.IsDeliveryTime = chkIsDeliveryTime.Checked ? 1 : 0; CurrentCost.IsDirectCost = rdoIsDirectCost.Checked ? 1 : 0; if (CurrentCost.ID <= 0) { //CurrentCost.CreatedDate = TextUtils.GetSystemDate(); //CurrentCost.CreatedBy = Global.AppUserName; //CurrentCost.UpdatedDate = CurrentCost.CreatedDate; //CurrentCost.UpdatedBy = Global.AppUserName; CurrentCost.ID = (int)pt.Insert(CurrentCost); } else { //CurrentCost.UpdatedDate = TextUtils.GetSystemDate(); //CurrentCost.UpdatedBy = Global.AppUserName; pt.Update(CurrentCost); } grvLink.FocusedRowHandle = -1; if (_isGroup) { for (int i = 0; i < grvLink.RowCount; i++) { int linkID = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID)); C_CostProductGroupLinkModel m = (C_CostProductGroupLinkModel)C_CostProductGroupLinkBO.Instance.FindByPK(linkID); m.ValuePercentKD = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colValuePercentKD)); m.ValuePercentSX = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colValuePercentSX)); m.NumberDay = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colNumberDay)); m.PersonNumber = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPersonNumber)); m.VtuPercent = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colVtuPercent)); pt.Update(m); } } else { //DataTable dt = (DataTable)grvLink.DataSource; //DataRow[] drs = dt.Select("ValuePercent > 0"); //if (drs.Length > 0) //{ for (int i = 0; i < grvLink.RowCount; i++) { int groupID = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID)); C_CostProductGroupLinkModel m = new C_CostProductGroupLinkModel(); m.ValuePercentKD = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colValuePercentKD)); m.ValuePercentSX = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colValuePercentSX)); m.NumberDay = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colNumberDay)); m.PersonNumber = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPersonNumber)); m.VtuPercent = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colVtuPercent)); m.C_ProductGroupID = groupID; m.C_CostID = CurrentCost.ID; pt.Insert(m); } //} } pt.CommitTransaction(); _isSaved = true; loadProductGroup(); MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pt.CloseConnection(); } if (_isSaved) { if (this.LoadDataChange != null) { this.LoadDataChange(null, null); } } }