Example #1
0
        private void btedit_Click(object sender, EventArgs e)
        {
            if (gvunit.SelectedRows.Count == 0)
            {
                MessageBox.Show("Tidak ada kemasan yang akan diubah");
            }
            else
            {
                var selectedRowId = (int)gvunit.SelectedRows[0].Cells["id"].Value;
                var selectedUnit  = ListUnits.FirstOrDefault(x => x.unitid == selectedRowId);

                if (selectedRowId == 1)
                {
                    MessageBox.Show("Anda tidak dibenarkan mengubah kemasan Lain-Lain");
                }
                else if (selectedUnit != null)
                {
                    var form = new ManageUnit();
                    form.userdata = userdata;
                    form.Editmode = true;
                    form.UnitData = selectedUnit;
                    form.ShowDialog();
                    LoadData();

                    foreach (DataGridViewRow row in gvunit.Rows)
                    {
                        if (((int)row.Cells["id"].Value) == selectedRowId)
                        {
                            gvunit.Rows[row.Index].Selected = true;
                            break;
                        }
                    }
                }
            }
        }
Example #2
0
        public void UpdateUnitPointLists(ClusterConditions CC)
        {
            if (ListUnits.Count == 0)
            {
                return;
            }

            List <int> RemovalIndexList = new List <int>();
            bool       changeOccured    = false;

            foreach (var item in ListUnits)
            {
                if (!item.IsStillValid() || (!CC.IgnoreNonTargetable || !item.IsTargetable.Value))
                {
                    RemovalIndexList.Add(ListUnits.IndexOf(item));
                    RAGUIDS.Remove(item.RAGUID);
                    changeOccured = true;
                }
            }


            if (changeOccured)
            {
                RemovalIndexList.Sort();
                RemovalIndexList.Reverse();
                foreach (var item in RemovalIndexList)
                {
                    //ListCacheObjects.RemoveAt(item);
                    ListUnits.RemoveAt(item);
                    ListPoints.RemoveAt(item);
                }

                if (ListUnits.Count > 1)
                {
                    //Logger.DBLog.InfoFormat("Updating Cluster");

                    //Reset Vars
                    Info = new ClusterInfo();

                    NearestMonsterDistance = -1f;

                    //Set default using First Unit
                    CacheUnit firstUnit = ListUnits[0];
                    MidPoint = firstUnit.PointPosition;
                    RAGUIDS.Add(firstUnit.RAGUID);
                    NearestMonsterDistance = firstUnit.CentreDistance;
                    Info.Update(ref firstUnit);


                    //Iterate thru the remaining
                    for (int i = 1; i < ListUnits.Count - 1; i++)
                    {
                        this.UpdateProperties(ListUnits[i]);
                    }
                }
            }
        }
Example #3
0
        private void LoadData()
        {
            ListUnits = unitRepository.GetAll();
            gvunit.Rows.Clear();


            foreach (var item in ListUnits.OrderBy(x => x.unitcode).ThenBy(x => x.name))
            {
                gvunit.Rows.Add(
                    item.unitid,
                    item.unitcode,
                    item.name,
                    item.remark);
            }
        }
Example #4
0
        }          // of AddPoint()

        /// <summary>
        /// Incorporates all points from given cluster to this cluster
        /// </summary>
        /// <param name="p_Cluster"></param>
        /// <returns>true always</returns>
        public override bool AnnexCluster(cluster p_Cluster)
        {
            base.AnnexCluster(p_Cluster);

            //Unit specific
            UnitCluster u_Cluster = (UnitCluster)p_Cluster;

            ListUnits.AddRange(u_Cluster.ListUnits);
            if (this.NearestMonsterDistance > u_Cluster.NearestMonsterDistance)
            {
                this.NearestMonsterDistance = u_Cluster.NearestMonsterDistance;
            }
            Info.Merge(u_Cluster.Info);


            return(true);
        }          // of AnnexCluster()
Example #5
0
        /// <summary>
        /// Adds point to this cluster only if it is "reachable"
        /// (if point is inside a circle of radius Dist of any cluster's points )
        /// </summary>
        /// <param name="p_Point">The point to be added to this cluster</param>
        /// <returns>false if point can't be added (that is either already in cluster
        /// or it is unreachable from any of the cluster's points)</returns>
        internal override bool AddObject(CacheObject obj)
        {
            bool l_bSuccess = base.AddObject(obj);

            if (l_bSuccess)            //&&Bot.Targeting.Environment.UnitRAGUIDs.Contains(unit.RAGUID))
            {
                CacheUnit unitobj = (CacheUnit)obj;
                ListUnits.Add(unitobj);
                UpdateProperties(unitobj);
            }
            else
            {
                return(l_bSuccess = false);
            }

            return(true);
        }          // of AddPoint()
Example #6
0
        private void LoadData()
        {
            //if (userdata.user_role == "kasir")
            //{
            //    btadditem.Visible = false;
            //    btedititem.Visible = false;
            //    btdeleteitem.Visible = false;
            //    btunitmanage.Visible = false;
            //    btmanagebrand.Visible = false;
            //}

            try
            {
                ListBrands     = brandRepository.GetAll().ToList();
                ListProducts   = productRepository.GetAll().ToList();
                ListCategories = categoryRepository.GetAll().ToList();
                ListUnits      = unitRepository.GetAll().ToList();
                var tempproductlist = new List <TempProdColumns>();

                if (ListProducts != null)
                {
                    foreach (var item in ListProducts)
                    {
                        var prodbrand = ListBrands.FirstOrDefault(x => x.brandid == item.brandid);
                        var prodcat   = ListCategories.FirstOrDefault(x => x.catid == item.prodcat);
                        var produnit  = ListUnits.FirstOrDefault(x => x.unitid == item.produnit);

                        var itemDetail = new TempProdColumns();
                        itemDetail.prodid        = item.prodid;
                        itemDetail.brandid       = item.brandid;
                        itemDetail.brand_name    = prodbrand != null ? prodbrand.name : " - ";
                        itemDetail.name          = item.name;
                        itemDetail.prodcat       = item.prodcat;
                        itemDetail.prodcat_name  = prodcat != null ? prodcat.name : " - ";
                        itemDetail.prodcode      = item.prodcode;
                        itemDetail.produnit      = item.produnit;
                        itemDetail.produnit_code = produnit != null ? produnit.unitcode : " - ";
                        itemDetail.purchaseprice = item.purchaseprice;
                        itemDetail.stocks        = item.stocks;
                        itemDetail.barcodeno     = item.barcodeno;
                        tempproductlist.Add(itemDetail);
                    }

                    gvproducts.Rows.Clear();


                    foreach (var item in tempproductlist.OrderBy(x => x.prodcat_name).ThenBy(x => x.brand_name).ThenBy(x => x.name))
                    {
                        gvproducts.Rows.Add(
                            item.prodid,
                            item.prodcat_name,
                            item.brand_name,
                            item.prodcode,
                            item.name,
                            item.produnit_code,
                            Utils.ToRupiah(item.purchaseprice),
                            item.barcodeno,
                            item.stocks
                            );
                    }
                }



                var cbData = ListBrands;
                cbData.Insert(0, new BrandColumns {
                    brandid = -1, name = "--- Pilih Merek ---"
                });

                cbbrand.DataSource    = new BindingSource(ListBrands, null);
                cbbrand.DisplayMember = "name";
                cbbrand.ValueMember   = "brandid";

                var cbcatdata = ListCategories;
                cbcatdata.Insert(0, new CategoryColumns {
                    catid = -1, name = "--- Pilih Kategori ---"
                });

                cbcategory.DataSource    = new BindingSource(ListCategories, null);
                cbcategory.DisplayMember = "name";
                cbcategory.ValueMember   = "catid";
            }
            catch (Exception ex)
            {
                var errMsg = "Details : " + ex.Message + Environment.NewLine + "Stacktrace : " + ex.StackTrace;
                MessageBox.Show(errMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            tbprodname.Focus();
        }