Beispiel #1
0
        private void btnReload_Click(object sender, EventArgs e)
        {
            if (CurrentQuotation.ID == 0)
            {
                return;
            }
            C_CostQuotationLinkBO.Instance.DeleteByAttribute("C_QuotationID", CurrentQuotation.ID);
            //DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1 or CostType = 1");
            DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1 or CostType = 1");

            foreach (DataRow row in dtLink.Rows)
            {
                C_CostQuotationLinkModel link = new C_CostQuotationLinkModel();
                link.C_CostID      = TextUtils.ToInt(row["ID"]);
                link.C_QuotationID = CurrentQuotation.ID;
                link.Price         = TextUtils.ToDecimal(row["Price"]);
                link.Qty           = 0;
                link.Total         = link.Qty * link.Price;
                C_CostQuotationLinkBO.Instance.Insert(link);
            }
            loadCost();
        }
Beispiel #2
0
        void save()
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvLink.FocusedRowHandle = -1;

                CurrentQuotation.Code           = txtCode.Text.Trim();
                CurrentQuotation.CustomerCode   = txtCustomerCode.Text.Trim();
                CurrentQuotation.CustomerName   = txtCustomerName.Text.Trim();
                CurrentQuotation.DeliveryTime   = TextUtils.ToDecimal(txtDeliveryTime.EditValue);
                CurrentQuotation.DepartmentName = txtDepartmentName.Text.Trim();
                CurrentQuotation.CustomerCodeF  = txtFinishCustomerCode.Text.Trim();
                CurrentQuotation.CustomerNameF  = txtFinishCustomerName.Text.Trim();
                CurrentQuotation.POnumber       = txtPOnumber.Text.Trim();
                CurrentQuotation.ProjectCode    = txtProjectCode.Text.Trim();
                CurrentQuotation.ProjectName    = txtProjectName.Text.Trim();
                CurrentQuotation.Tax            = TextUtils.ToDecimal(txtTax.EditValue);

                CurrentQuotation.TotalCustomer = TextUtils.ToDecimal(colTotal.SummaryItem.SummaryValue);

                //CurrentQuotation.TotalBX = TextUtils.ToDecimal(txtTotalBX.EditValue);
                //CurrentQuotation.TotalHD = TextUtils.ToDecimal(txtTotalHD.EditValue);
                //CurrentQuotation.TotalNC = TextUtils.ToDecimal(txtTotalNC.EditValue);
                //CurrentQuotation.TotalPB = TextUtils.ToDecimal(txtTotalPB.EditValue);
                //CurrentQuotation.TotalProfit = TextUtils.ToDecimal(txtTotalProfit.EditValue);
                //CurrentQuotation.TotalReal = TextUtils.ToDecimal(txtTotalReal.EditValue);
                //CurrentQuotation.TotalTPA = TextUtils.ToDecimal(txtTotalTPA.EditValue);
                //CurrentQuotation.TotalVT = TextUtils.ToDecimal(txtTotalVT.EditValue);

                CurrentQuotation.Status       = cboStatus.SelectedIndex;
                CurrentQuotation.DepartmentId = TextUtils.ToInt(cboDepartment.SelectedValue);

                CurrentQuotation.CustomerPercent = TextUtils.ToDecimal(txtCustomerPercent.EditValue);
                CurrentQuotation.CustomerCash    = TextUtils.ToDecimal(txtCustomerCash.EditValue);
                //CurrentQuotation.IsCustomerVAT = chkIsCustomerVAT.Checked;
                CurrentQuotation.IsVAT = cboIsVAT.SelectedIndex;

                CurrentQuotation.UpdatedDate = DateTime.Now;
                CurrentQuotation.UpdatedBy   = Global.AppUserName;
                if (CurrentQuotation.ID <= 0)
                {
                    CurrentQuotation.CreatedDate = DateTime.Now;
                    CurrentQuotation.CreatedBy   = Global.AppUserName;
                    CurrentQuotation.ID          = (int)pt.Insert(CurrentQuotation);
                }
                else
                {
                    pt.Update(CurrentQuotation);
                }
                if (grvLink.RowCount > 0)
                {
                    for (int i = 0; i < grvLink.RowCount; i++)
                    {
                        int id = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID));
                        C_CostQuotationLinkModel link = (C_CostQuotationLinkModel)C_CostQuotationLinkBO.Instance.FindByPK(id);
                        link.Qty   = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colQty));
                        link.Price = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPrice));
                        link.Total = link.Qty * link.Price;
                        pt.Update(link);
                    }
                }
                else
                {
                    DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1");
                    //DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1 or CostType = 1");
                    foreach (DataRow row in dtLink.Rows)
                    {
                        C_CostQuotationLinkModel link = new C_CostQuotationLinkModel();
                        link.C_CostID      = TextUtils.ToInt(row["ID"]);
                        link.C_QuotationID = CurrentQuotation.ID;
                        link.Price         = TextUtils.ToDecimal(row["Price"]);
                        link.Qty           = 0;
                        link.Total         = link.Qty * link.Price;
                        pt.Insert(link);
                    }
                }

                pt.CommitTransaction();
                _isSaved = true;
                loadCost();
                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);
                }
            }
        }
 protected C_CostQuotationLinkFacade(C_CostQuotationLinkModel model) : base(model)
 {
 }