Exemple #1
0
        private void btnEvet_Click(object sender, EventArgs e)
        {
            if (this.MaterialListItems.Where(p => p.PozOBFUnitePrice == 0).Count() != 0)
            {
                MessageBox.Show("Birim Fiyatı 0 olan malzeme bıraktınız. Lütfen Birim Fiyat belirtiniz?");
                grdMaterialList.DataSource = null;
                grdMaterialList.DataSource = this.MaterialListItems.OrderBy(p => p.PozOBFUnitePrice).ToList();
                return;
            }
            this.Enabled = false;
            LoadingManager.Instance.Show(this);
            foreach (var item in this.MaterialListItems)
            {
                MaterialListProvider.Instance.Save(item);
                if (UICurrentManager.Instance.CurrentTender.MaterialList.Where(p => p.Id == item.Id).Count() == 0)
                {
                    UICurrentManager.Instance.CurrentTender.MaterialList.Add(item);
                }

                IhalematikProBL.Entity.OBF currentOBF = OBFProvider.Instance.GetItem(item.PozOBFId);
                if (currentOBF != null)
                {
                    currentOBF.UnitPrice = item.PozOBFUnitePrice;
                    OBFProvider.Instance.UpdateOBFPrice(currentOBF.Id, currentOBF.UnitPrice);
                }
            }
            LoadingManager.Instance.Hide();
            this.Enabled = true;
            this._owner.LoadTenderGroupGrid();
            UIPopupManager.Instance.ShowPopup();
            this.Close();
        }
 private void btnChangeName_Click(object sender, EventArgs e)
 {
     if (txtdescriptionForSupplier.Text != null)
     {
         if (this.IsPoz)
         {
             Poz poz = PozProvider.Instance.GetItem(this.currentPozOBFId);
             poz.DescriptionForSupplier = txtdescriptionForSupplier.Text.Trim();
             PozProvider.Instance.Save(poz);
         }
         else
         {
             IhalematikProBL.Entity.OBF obf = OBFProvider.Instance.GetItem(this.currentPozOBFId);
             obf.DescriptionForSupplier = txtdescriptionForSupplier.Text.Trim();
             OBFProvider.Instance.Save(obf);
         }
         this.PozOBF.DescriptionForSupplier = txtdescriptionForSupplier.Text.Trim();
         this._owner.LoadMaterialGrid();
         UIPopupManager.Instance.ShowPopup();
         this.Close();
     }
     //else
     //{
     //    MessageBox.Show("Lütfen Malzeme Adını Belirtiniz...");
     //    txtNewMeterialName.Focus();
     //}
 }
        public Material CreateMaterial(EntityBase Entity)
        {
            Material material = new Material();

            if (Entity is Poz)
            {
                Poz item = Entity as Poz;
                material.Number                 = item.Number;
                material.Unit                   = item.Unit;
                material.UnitPrice              = item.UnitPrice;
                material.Description            = item.Description;
                material.DescriptionForSupplier = item.DescriptionForSupplier;
                material.Year                   = item.Year;
                material.Id = item.Id;
            }
            else if (Entity is OBF)
            {
                OBF item = Entity as OBF;
                material.Number                 = item.StokNumber;
                material.Unit                   = item.Unit;
                material.UnitPrice              = item.UnitPrice;
                material.Description            = item.Description;
                material.Id                     = item.Id;
                material.DescriptionForSupplier = item.DescriptionForSupplier;
            }

            return(material);
        }
Exemple #4
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;
        }
Exemple #5
0
        private void ReadExcel(string path)
        {
            materialListItems = new List <MaterialList>();
            // obfItems = new List<IhalematikProBL.Entity.OBF>();
            try
            {
                FileStream       stream      = System.IO.File.Open(@"" + path + "", FileMode.Open, FileAccess.Read);
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                int i = 0;
                while (excelReader.Read())
                {
                    try
                    {
                        if (i > 0)
                        {
                            int    obfId    = 0;
                            string stokKodu = string.Empty;
                            try
                            {
                                stokKodu = excelReader.GetString(0);
                            }
                            catch (Exception ex)
                            {
                                double stokKodudouble = excelReader.GetDouble(0);
                                stokKodu = stokKodudouble.ToString();
                            }
                            string description = excelReader.GetString(1);
                            if (!string.IsNullOrEmpty(stokKodu) && !string.IsNullOrEmpty(description))
                            {
                                string unit = excelReader.GetString(2);

                                IhalematikProBL.Entity.OBF existingObf = OBFProvider.Instance.GetOne("Description", description);
                                if (existingObf != null)
                                {
                                    obfId = existingObf.Id;

                                    lblPosSayisi.Text = i.ToString();
                                    listBox1.Items.Add(existingObf.Number);
                                    listBox1.Items.Add(existingObf.Description);
                                    listBox1.Items.Add(existingObf.Unit);
                                    //OBFProvider.Instance.Save(existingObf);
                                }
                                else
                                {
                                    IhalematikProBL.Entity.OBF obf = new IhalematikProBL.Entity.OBF();
                                    int lastTenderNumber           = UIOBFManager.Instance.GetLastOBFNumber();
                                    obf.Number      = string.Format("{0}", (lastTenderNumber + 1).ToString().PadLeft(8, '0'));
                                    obf.StokNumber  = stokKodu;
                                    obf.Description = description;
                                    obf.Unit        = unit;
                                    obf.UnitPrice   = 0;
                                    obf.IsActive    = true;
                                    OBFProvider.Instance.Save(obf);
                                    obfId             = obf.Id;
                                    lblPosSayisi.Text = i.ToString();
                                    listBox1.Items.Add(obf.Number);
                                    listBox1.Items.Add(obf.Description);
                                    listBox1.Items.Add(obf.Unit);
                                }

                                double quantity = 0;
                                try
                                {
                                    quantity = excelReader.GetDouble(3);
                                }
                                catch (Exception ex)
                                {
                                }
                                listBox1.Items.Add(quantity.ToString());
                                listBox1.Items.Add("-------------------------------------------------------------");
                                listBox1.TopIndex = listBox1.Items.Count - 1;
                                if (obfId != 0)
                                {
                                    MaterialList materialList = new MaterialList();
                                    materialList.IsPoz         = false;
                                    materialList.PozOBFId      = obfId;
                                    materialList.Quantity      = (float)quantity;
                                    materialList.KDVPercentage = 18;
                                    materialList.Tender        = UICurrentManager.Instance.CurrentTender;
                                    materialList.TenderGroupId = this._owner.SelectedGroupId;
                                    materialListItems.Add(materialList);
                                }
                            }
                        }
                        i++;
                    }
                    catch (Exception ex)
                    {
                        pnlYukle.Visible = true;
                        MessageBox.Show("Yuklediğiniz excel in formatını kontrol ediniz.");
                        LoggingManager.Instance.SaveErrorLog(ex);
                        this.Close();
                        break;
                    }
                }
                stream.Close();
                this.Hide();

                if (this.materialListItems == null || this.materialListItems.Count == 0)
                {
                    pnlYukle.Visible = false;
                    MessageBox.Show("Yüklenecek OBF bulunamadı.");
                    this.Close();
                    return;
                }

                frm_TopluObfYukleIhaleTemp pozTemp = new frm_TopluObfYukleIhaleTemp(this._owner);
                pozTemp.MaterialListItems = materialListItems;
                pozTemp.ShowDialog();
                frm_MesajFormu mesaj = new frm_MesajFormu();
                mesaj.lblMesaj.Text = "OBFler başarıyla yüklendi...";
                mesaj.Close();
            }
            catch (Exception)
            {
                pnlYukle.Visible = true;
                MessageBox.Show("Yuklediğiniz excel in formatını kontrol ediniz.\n Yuklemeye calistiginiz excel dosyasi en az office 2010 ile olusturulmus olmasi gerekmektedir.\n Excel in kapali oldugundan emin olunuz");
            }
        }