private void btnGuncelle_Click(object sender, EventArgs e)
        {
            IsEmptyKontrol();
            if (this.CurrentOBF != null)
            {
                OBFModel model = new OBFModel(this.currentOBF);
                model.Description = txtDescription.Text;
                model.StokNumber  = txtNumber.Text;
                model.Unit        = txtUnit.Text;
                double newUnitPrice = double.Parse(txtUnitPrice.Text.Replace("TL", string.Empty));
                model.DescriptionForSupplier = txtDescriptionForSupplier.Text;

                //List<OBFModel> existingOBFs = UIOBFManager.Instance.GetOBFs(model.Description);
                //if (existingOBFs != null && existingOBFs.Count != 0 && existingOBFs.First().Id !+model.Id)
                //{
                //    frm_MesajFormu mf = new frm_MesajFormu();
                //    mf.lblMesaj.Text = "Bu OBF açıklaması ile kayit bulunmaktadir";
                //    mf.ShowDialog();
                //    this.txtNumber.Text = "";
                //    this.txtNumber.Focus();
                //}
                //else
                //{
                model.Save();
                if (!this.CurrentOBF.UnitPrice.Equals(newUnitPrice))
                {
                    //OBFModel newObf = new OBFModel();
                    //newObf.IsActive = true;
                    if (model.ParentId == 0)
                    {
                        model.ParentId = model.Id.Value;
                    }
                    model.UnitPrice    = newUnitPrice;
                    model.CurrencyType = SimpleApplicationBase.Toolkit.Helpers.GetValueFromObject <CurrencyTypesEnum>(ddlCurrencyType.SelectedIndex);
                    model.Id           = 0;
                    model.Save();
                }

                //frm_MesajFormu mf = new frm_MesajFormu();
                //mf.lblMesaj.Text = "Kayıt Güncellendi...";
                //mf.ShowDialog();
                UIPopupManager.Instance.ShowPopup();
                this._owner.LoadGrid();
                this.Close();
                //}
            }
        }
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            bool isEmpty = IsEmptyKontrol();

            if (isEmpty)
            {
                return;
            }
            OBFModel model = new OBFModel();

            model.Description = txtDescription.Text;
            int lastTenderNumber = UIOBFManager.Instance.GetLastOBFNumber();

            model.Number     = (lastTenderNumber + 1).ToString();
            model.IsActive   = true;
            model.StokNumber = txtNumber.Text;
            model.Unit       = txtUnit.Text;
            //model.UnitPrice = double.Parse(txtUnitPrice.Text.Replace("TL", string.Empty), CultureInfo.InvariantCulture);
            model.UnitPrice              = model.UnitPrice = double.Parse(txtUnitPrice.Text.Replace("TL", string.Empty));
            model.CurrencyType           = SimpleApplicationBase.Toolkit.Helpers.GetValueFromObject <CurrencyTypesEnum>(ddlCurrencyType.SelectedIndex);
            model.DescriptionForSupplier = txtDescriptionForSupplier.Text;

            List <OBFModel> existingOBFs = UIOBFManager.Instance.GetOBFs(model.Description);

            if (existingOBFs != null && existingOBFs.Count != 0)
            {
                frm_MesajFormu mf = new frm_MesajFormu();
                mf.lblMesaj.Text = "Bu OBF açıklaması ile kayit bulunmaktadir";
                mf.ShowDialog();
                this.txtNumber.Text = "";
                this.txtNumber.Focus();
            }
            else
            {
                model.Save();
                //frm_MesajFormu mf = new frm_MesajFormu();
                //mf.lblMesaj.Text = "Kayıt Yapıldı...";
                //mf.ShowDialog();
                UIPopupManager.Instance.ShowPopup();
                FormClear();
                LoadGrid();
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Tender currentTender = UICurrentManager.Instance.CurrentTender;

            int[] selectedRows = gridView1.GetSelectedRows();

            List <OBFModel> dataSource = grdOBFList.DataSource as List <OBFModel>;

            if (dataSource == null)
            {
                return;
            }

            OBFModel[] selectedRowsItems = dataSource.ToArray();

            foreach (int item in selectedRows)
            {
                OBFModel     obfModel     = selectedRowsItems[item];
                MaterialList materialList = new MaterialList();
                materialList.IsPoz         = false;
                materialList.PozOBFId      = obfModel.Id.Value;
                materialList.Tender        = currentTender;
                materialList.TenderGroupId = this.SelectedGroupId;
                materialList.OfferPrice    = obfModel.OfferPrice;
                List <MaterialList> items = currentTender.MaterialList.Where(p => p.PozOBFId == materialList.PozOBFId && !p.IsPoz).ToList();

                if (items.Count == 0)
                {
                    currentTender.MaterialList.Add(materialList);
                    int index = oBFModels.FindIndex(p => p.Id == obfModel.Id);
                    oBFModels.RemoveAt(index);
                }
            }

            List <MaterialListModel> models = IhalematikModelBase.GetModels <MaterialListModel, MaterialList>(currentTender.MaterialList.Where(p => !p.IsPoz && p.TenderGroupId == this.SelectedGroupId).ToList());

            grdAddedOBF.DataSource = null;
            grdAddedOBF.DataSource = models;
            grdOBFList.DataSource  = null;
            grdOBFList.DataSource  = oBFModels;
        }
Beispiel #4
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            Offer currentOffer = UICurrentManager.Instance.CurrentOffer;

            int[] selectedRows = gridView1.GetSelectedRows();

            List <OBFModel> dataSource = grdOBFList.DataSource as List <OBFModel>;

            if (dataSource == null)
            {
                return;
            }
            OBFModel[] selectedRowsItems = dataSource.ToArray();

            foreach (int item in selectedRows)
            {
                OBFModel          pozModel     = selectedRowsItems[item];
                OfferMaterialList materialList = new OfferMaterialList();
                materialList.IsPoz    = false;
                materialList.PozOBFId = pozModel.Id.Value;
                materialList.Offer    = currentOffer;

                List <OfferMaterialList> items = currentOffer.MaterialList.Where(p => p.PozOBFId == materialList.PozOBFId && !p.IsPoz).ToList();

                if (items.Count == 0)
                {
                    currentOffer.MaterialList.Add(materialList);
                }
            }

            List <OfferMaterialListModel> models = IhalematikModelBase.GetModels <OfferMaterialListModel, OfferMaterialList>(currentOffer.MaterialList.Where(p => !p.IsPoz).ToList());

            grdAddedOBF.DataSource = null;
            grdAddedOBF.DataSource = models;
            this.LoadMaterialList();
        }
Beispiel #5
0
        private void LoadMaterialList()
        {
            string obfNo          = txtNumber.Text;
            string obfDescription = txtDescription.Text;

            oBFModels = UIOBFManager.Instance.GetOBFs(obfNo, obfDescription);
            oBFModels = oBFModels.Where(p => p.IsActive).ToList();
            List <OfferMaterialList> selectedMaterialLists = UICurrentManager.Instance.CurrentOffer.MaterialList.Where(p => !p.IsPoz).ToList();

            if (selectedMaterialLists != null)
            {
                foreach (OfferMaterialList item in selectedMaterialLists)
                {
                    bool     isExistingPozModel = false;
                    OBFModel selectedOBFModel   = null;
                    foreach (var pozModel in oBFModels)
                    {
                        IhalematikProBL.Entity.OBF PozObf = OBFProvider.Instance.GetItem(item.PozOBFId);

                        if (PozObf.Id == pozModel.Id || PozObf.ParentId == pozModel.ParentId || PozObf.ParentId == pozModel.Id)
                        {
                            isExistingPozModel = true;
                            selectedOBFModel   = pozModel;
                            break;
                        }
                    }

                    if (isExistingPozModel)
                    {
                        oBFModels.Remove(selectedOBFModel);
                    }
                }
            }

            grdOBFList.DataSource = oBFModels;
        }
        private void LoadMaterialListGrid()
        {
            string obfNumber      = txtNumber.Text;
            string obfDescription = txtDescription.Text;

            oBFModels = new List <OBFModel>();
            Offer offer = UICurrentManager.Instance.CurrentTender.Offer;
            List <MaterialList> selectedMaterialLists = UICurrentManager.Instance.CurrentTender.MaterialList.Where(p => !p.IsPoz).ToList();

            if (offer == null)
            {
                oBFModels = UIOBFManager.Instance.GetOBFs(obfNumber, obfDescription).Where(p => p.IsActive).ToList();
                if (selectedMaterialLists != null)
                {
                    foreach (MaterialList item in selectedMaterialLists)
                    {
                        bool     isExistingPozModel = false;
                        OBFModel selectedOBFModel   = null;
                        foreach (var obfModel in oBFModels)
                        {
                            OBF PozObf = OBFProvider.Instance.GetItem(item.PozOBFId);

                            if (obfModel.Id == PozObf.Id || PozObf.ParentId == obfModel.ParentId || PozObf.ParentId == obfModel.Id)
                            {
                                isExistingPozModel = true;
                                selectedOBFModel   = obfModel;
                                break;
                            }
                        }

                        if (isExistingPozModel)
                        {
                            oBFModels.Remove(selectedOBFModel);
                        }
                    }
                }
            }

            else
            {
                List <OfferMaterialList> items = offer.MaterialList.Where(p => !p.IsPoz).ToList();
                if (items != null && items.Count != 0)
                {
                    foreach (var item in items)
                    {
                        bool isExist = false;

                        foreach (var selectedMaterialList in selectedMaterialLists)
                        {
                            if (selectedMaterialList.PozOBFId == item.PozOBFId)
                            {
                                isExist = true;
                                break;
                            }
                        }

                        if (!isExist)
                        {
                            OBFModel model = new OBFModel();
                            model.Description = item.PozOBF.Description;
                            model.Number      = item.PozOBF.Number.Trim();
                            model.StokNumber  = item.PozOBF.Number;
                            model.Unit        = item.PozOBF.Unit;
                            model.UnitPrice   = item.PozOBF.UnitPrice;
                            model.Id          = item.PozOBFId;
                            double offerPrice = 0;
                            if (item.IsSelected)
                            {
                                // Malzeme tedarikciye gonderilmisse fiyatini offerMatetialdan ceksin.
                                offerPrice       = OfferManager.Instance.GetOfferMaterialListPrice(item.Id).PriceWithRisk;
                                model.OfferPrice = offerPrice;
                            }
                            else
                            {
                                offerPrice       = item.PozOBF.UnitPrice; // Malzeme tedarikciye gonderilmemisse fiyatini obf den ceksin.
                                model.OfferPrice = offerPrice;
                            }

                            if (!string.IsNullOrEmpty(obfNumber))
                            {
                                if (item.PozOBF.Number.ToLower().Contains(obfNumber.ToLower()))
                                {
                                    oBFModels.Add(model);
                                }
                            }
                            else if (!string.IsNullOrEmpty(obfDescription))
                            {
                                if (item.PozOBF.Description.ToLower().Contains(obfDescription.ToLower()))
                                {
                                    oBFModels.Add(model);
                                }
                            }
                            else
                            {
                                oBFModels.Add(model);
                            }
                        }
                    }
                }
            }
            grdOBFList.DataSource = null;
            grdOBFList.DataSource = oBFModels;
        }