Ejemplo n.º 1
0
 public void createTreeview()
 {
     InventoryEntities invEntities = new InventoryEntities();
     var grped =
     from it in invEntities.items
     join ct in invEntities.category_item on it.category_item_id equals ct.category_item_id
     group it by new { it.category_item_id, ct.category_item_code } into grp
     select grp;
     treeViewItem.Nodes.Clear();
     foreach (var grouping in grped)
     {
         var nodeFor = treeViewItem.Nodes.Add(grouping.Key.category_item_code.ToString());
         foreach (var item in grouping)
         {
             var subitem = nodeFor.Nodes.Add(item.item_code.ToString());
         }
     }
 }
Ejemplo n.º 2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     using (InventoryEntities invEntities = new InventoryEntities())
     {
         var query = default(IEnumerable<TransactionMasterViewModel>);
         ///get data TransactionMasters
         query = (from t in invEntities.transaction_master
                  where t.transaction_code.Contains(txtTransaction_code.Text)
                                  && DateTime.Compare(t.transaction_date, dtpTransaction_fromdate.Value) >= 0
                                  && DateTime.Compare(t.transaction_date, dtpTransaction_todate.Value) <= 0
                                  && t.transaction_type_id == 2
                  select new TransactionMasterViewModel
                            {
                                transaction_master_id = t.transaction_master_id,
                                transaction_code = t.transaction_code,
                                transaction_date = t.transaction_date,
                                transaction_type_id = t.transaction_type_id,
                                transaction_type_code = t.transaction_type.transaction_type_code,
                                received_warehouse_id = t.received_warehouse_id,
                                received_warehouse_code = t.received_warehouse.warehouse_code,
                                received_warehouse_name = t.received_warehouse.warehouse_name,
                                delivered_warehouse_id = t.delivered_warehouse.warehouse_id,
                                delivered_warehouse_code = t.delivered_warehouse.warehouse_code,
                                delivered_warehouse_name = t.delivered_warehouse.warehouse_name,
                                receiver = t.receiver,
                                deliver = t.deliver,
                                customer_id = t.customer_id,
                                customer_code = t.customer.customer_code,
                                customer_name = t.customer.customer_name,
                                supplier_id = t.supplier_id,
                                supplier_code = t.supplier.supplier_code,
                                supplier_name = t.supplier.supplier_name,
                                description = t.description,
                                create_user = t.create_user,
                                created_date = t.created_date,
                                update_user = t.update_user,
                                update_date = t.update_date
                            });
         dtTransaction_master = Utils.ToDataTable(query);
         dtTransaction_master.AcceptChanges();
         this.grdView.DataSource = dtTransaction_master;
     }
 }
Ejemplo n.º 3
0
        public static DataTable reportFinal(Int64 warehouseId, string itemCode, DateTime fromDate, DateTime toDate)
        {
            InventoryEntities invEntities = new InventoryEntities();

            var result = default(IEnumerable<ReportViewModel>);

            var qrf = default(IEnumerable<ReportViewModel>);
            qrf = reportProcess(warehouseId, itemCode, DateTime.MinValue, fromDate != DateTime.MinValue ? fromDate.Date.AddDays(-1) : fromDate);

            var qrc = default(IEnumerable<ReportViewModel>);
            qrc = reportProcess(warehouseId, itemCode, fromDate, toDate);

            var qrl = default(IEnumerable<ReportViewModel>);
            qrl = reportProcess(warehouseId, itemCode, toDate != DateTime.MaxValue ? toDate.Date.AddDays(1) : fromDate, DateTime.MaxValue);

            var union = default(IEnumerable<ReportViewModel>);

            union = qrf.Union(qrc);
            union = union.Union(qrl).Distinct();

            result = from ui in union
                     join qft in qrf on new { ui.item_id, ui.warehouse_id } equals new { qft.item_id, qft.warehouse_id } into qrft
                     from qf in qrft.DefaultIfEmpty()
                     join qct in qrc on new { ui.item_id, ui.warehouse_id } equals new { qct.item_id, qct.warehouse_id } into qrct
                     from qc in qrct.DefaultIfEmpty()
                     join qlt in qrl on new { ui.item_id, ui.warehouse_id } equals new { qlt.item_id, qlt.warehouse_id } into qrlt
                     from ql in qrlt.DefaultIfEmpty()
                     join wh in invEntities.warehouses on ui.warehouse_id equals wh.warehouse_id
                     join it in invEntities.items on ui.item_id equals it.item_id
                     join cte in invEntities.category_item on it.category_item_id equals cte.category_item_id into ctet
                     from ct in ctet.DefaultIfEmpty()
                     join uts in invEntities.units on it.unit_id equals uts.unit_id into utst
                     from ut in utst.DefaultIfEmpty()
                     where ui.warehouse_id != null
                     select new ReportViewModel
                     {
                         warehouse_id = ui.warehouse_id,
                         warehouse_code = wh.warehouse_code,
                         warehouse_name = wh.warehouse_name,
                         item_id = ui.item_id,
                         item_code = it.item_code,
                         item_name = it.item_name,
                         features = it.features,
                         specifications = it.specifications,
                         category_item_id = it.category_item_id,
                         category_item_code = ct.category_item_code,
                         category_item_name = ct.category_item_name,
                         unit_id = it.unit_id,
                         unit_code = ut.unit_code,
                         unit_name = ut.unit_name,
                         baseline = (qf == null || qf.remain == null ? 0 : qf.remain),
                         grow = (qc == null || qc.grow == null ? 0 : qc.grow),
                         decrease = (qc == null || qc.decrease == null ? 0 : qc.decrease),
                         remain = (qc == null || qc.remain == null ? 0 : qc.remain),
                         stock = (ql == null || ql.remain == null ? 0 : ql.remain),
                         balance = (qf == null || qf.remain == null ? 0 : qf.remain) + (qc == null || qc.remain == null ? 0 : qc.remain) + (ql == null || ql.remain == null ? 0 : ql.remain)
                     };

            result = from rst in result
                     group rst by new
                     {
                         rst.warehouse_id,
                         rst.warehouse_code,
                         rst.warehouse_name,
                         rst.item_id,
                         rst.item_code,
                         rst.item_name,
                         rst.features,
                         rst.specifications,
                         rst.category_item_id,
                         rst.category_item_code,
                         rst.category_item_name,
                         rst.unit_id,
                         rst.unit_code,
                         rst.unit_name,
                         rst.baseline,
                         rst.grow,
                         rst.decrease,
                         rst.remain,
                         rst.stock,
                         rst.balance
                     } into rs
                     select new ReportViewModel
                     {
                         warehouse_id = rs.Key.warehouse_id,
                         warehouse_code = rs.Key.warehouse_code,
                         warehouse_name = rs.Key.warehouse_name,
                         item_id = rs.Key.item_id,
                         item_code = rs.Key.item_code,
                         item_name = rs.Key.item_name,
                         features = rs.Key.features,
                         specifications = rs.Key.specifications,
                         category_item_id = rs.Key.category_item_id,
                         category_item_code = rs.Key.category_item_code,
                         category_item_name = rs.Key.category_item_name,
                         unit_id = rs.Key.unit_id,
                         unit_code = rs.Key.unit_code,
                         unit_name = rs.Key.unit_name,
                         baseline = rs.Key.baseline,
                         grow = rs.Key.grow,
                         decrease = rs.Key.decrease,
                         remain = rs.Key.remain,
                         stock = rs.Key.stock,
                         balance = rs.Key.balance
                     };

            DataTable dt = Utils.ToDataTable(result.Distinct());

            return dt;
        }
Ejemplo n.º 4
0
        public static IEnumerable<ReportViewModel> reportProcess(Int64 warehouseId, string itemCode, DateTime fromDate, DateTime toDate)
        {
            InventoryEntities invEntities = new InventoryEntities();

            fromDate = new DateTime(fromDate.Year, fromDate.Month, fromDate.Day, 0, 0, 1);
            toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day, 23, 59, 59);

            ///get data remain quantity
            var qrr = default(IEnumerable<ReportViewModel>);

            var qrg = default(IEnumerable<ReportViewModel>);
            ///get data grow quantity
            qrg = from m in invEntities.transaction_master
                  join d in invEntities.transaction_detail on m.transaction_master_id equals d.transaction_master_id
                  join i in invEntities.items on d.item_id equals i.item_id
                  where m.transaction_date >= fromDate
                       && m.transaction_date <= toDate
                       && (warehouseId == Int64.MinValue || m.received_warehouse_id == warehouseId)
                       && i.item_code.Contains(itemCode)
                  group d by new { m.received_warehouse_id, d.item_id } into rs
                  select new ReportViewModel
                  {
                      warehouse_id = rs.Key.received_warehouse_id,
                      item_id = rs.Key.item_id,
                      grow = rs.Sum(d => d.quantity)
                  };

            DataTable dtg = Utils.ToDataTable(qrg);
            var qrd = default(IEnumerable<ReportViewModel>);

            ///get data decrease quantity
            qrd = from m in invEntities.transaction_master
                  join d in invEntities.transaction_detail on m.transaction_master_id equals d.transaction_master_id
                  join i in invEntities.items on d.item_id equals i.item_id
                  where m.transaction_date >= fromDate
                        && m.transaction_date <= toDate
                        && (warehouseId == Int64.MinValue || m.delivered_warehouse_id == warehouseId)
                        && i.item_code.Contains(itemCode)
                  group d by new { m.delivered_warehouse_id, d.item_id } into rs
                  select new ReportViewModel
                  {
                      warehouse_id = rs.Key.delivered_warehouse_id,
                      item_id = rs.Key.item_id,
                      decrease = rs.Sum(d => d.quantity)
                  };
            DataTable dtd = Utils.ToDataTable(qrd);

            var union = default(IEnumerable<ReportViewModel>);
            union = qrg.Union(qrd).Distinct();

            ///get data remain quantity
            ///
            qrr = from ui in union
                  join qgt in qrg on new { ui.item_id, ui.warehouse_id } equals new { qgt.item_id, qgt.warehouse_id } into qgtt
                  from qg in qgtt.DefaultIfEmpty()
                  join qdt in qrd on new { ui.item_id, ui.warehouse_id } equals new { qdt.item_id, qdt.warehouse_id } into qdtt
                  from qd in qdtt.DefaultIfEmpty()
                  where ui.warehouse_id != null
                  select new ReportViewModel
                  {
                      warehouse_id = ui.warehouse_id,
                      item_id = ui.item_id,
                      grow = (qg == null || qg.grow == null ? 0 : qg.grow),
                      decrease = (qd == null || qd.decrease == null ? 0 : qd.decrease),
                      remain = (qg == null || qg.grow == null ? 0 : qg.grow) - (qd == null || qd.decrease == null ? 0 : qd.decrease)
                  };

            DataTable dtr = Utils.ToDataTable(qrr);
            return qrr;
        }
Ejemplo n.º 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     using (InventoryEntities invEntities = new InventoryEntities())
     {
         ///
         ///delete transaction master
         ///
         var master = (transaction_master)invEntities.transaction_master.Where(m => m.transaction_master_id == TransactionMasterId).FirstOrDefault();
         if (master != null)
         {
             ///
             /// delete transaction detail
             ///
             var details = from d in invEntities.transaction_detail.Where(m => m.transaction_master_id == TransactionMasterId) select d;
             invEntities.transaction_detail.RemoveRange(details);
             invEntities.SaveChanges();
             invEntities.transaction_master.Remove(master);
             invEntities.SaveChanges();
         }
         ///
         ///reset form value
         ///
         TransactionMasterId = Int64.MinValue;
     }
 }
Ejemplo n.º 6
0
        private void InsertDate()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {
                var new_Master_Id = Int64.MinValue;
                #region insert or update master
                var udm = from m in invEntities.transaction_master
                          where m.transaction_master_id == this.TransactionMasterId
                          select m;
                transaction_master obj = udm.SingleOrDefault();
                if (obj == null)
                    obj = new transaction_master();
                ///set data to object
                obj.transaction_code = txtTransaction_code.Text.Trim();
                obj.transaction_type_id = 1;
                obj.transaction_date = dtpTransaction_date.Value;
                if ((Int64)cboReceived_warehouse.SelectedValue != Int64.MinValue)
                    obj.received_warehouse_id = (Int64)cboReceived_warehouse.SelectedValue;
                obj.enabled = true;
                obj.receiver = txtReceiver.Text.Trim();
                obj.deliver = txtDeliver.Text.Trim();
                if ((Int64)cboSupplier.SelectedValue != Int64.MinValue)
                    obj.supplier_id = (Int64)cboSupplier.SelectedValue;
                obj.created_date = DateTime.Now;
                obj.create_user = txtCreate_user.Text.Trim();
                obj.update_date = DateTime.Now;
                obj.update_user = txtCreate_user.Text.Trim();
                obj.description = txtDescription.Text.Trim();
                if (obj.transaction_master_id == 0)
                    invEntities.transaction_master.Add(obj);
                invEntities.SaveChanges();
                new_Master_Id = obj.transaction_master_id;

                #endregion end insert master;
                #region insert detail and item
                for (int i = 0; i < dtTransaction_detail.Rows.Count; i++)
                {
                    if (dtTransaction_detail.Rows[i].RowState == DataRowState.Added || dtTransaction_detail.Rows[i].RowState == DataRowState.Modified)
                    {
                        ///
                        ///Insert or update item
                        ///
                        var temmId = string.IsNullOrEmpty(dtTransaction_detail.Rows[i][colItemId.ColumnName].ToString()) ? Int64.MinValue : (Int64)dtTransaction_detail.Rows[i][colItemId.ColumnName];
                        var udi = from it in invEntities.items
                                  where it.item_id == temmId
                                  select it;
                        item objItem = udi.SingleOrDefault();
                        if (objItem == null)
                            objItem = new item();
                        objItem.item_code = dtTransaction_detail.Rows[i][colItemCode.ColumnName].ToString();
                        objItem.item_name = dtTransaction_detail.Rows[i][colItemName.ColumnName].ToString();
                        objItem.unit_id = (Int64)dtTransaction_detail.Rows[i][colUnitId.ColumnName];
                        objItem.category_item_id = (Int64)dtTransaction_detail.Rows[i][colCategoryItemId.ColumnName];
                        objItem.specifications = dtTransaction_detail.Rows[i][colSpecifications.ColumnName].ToString();
                        objItem.features = dtTransaction_detail.Rows[i][colFeatures.ColumnName].ToString();
                        objItem.enabled = true;
                        objItem.create_user = obj.create_user;
                        objItem.update_user = obj.create_user;
                        objItem.created_date = DateTime.Now;
                        objItem.update_date = DateTime.Now;
                        if (objItem.item_id == 0)
                            invEntities.items.Add(objItem);
                        invEntities.SaveChanges();

                        ///
                        /// insert or update transaction_detail
                        ///
                        var detailId = string.IsNullOrEmpty(dtTransaction_detail.Rows[i][coltransaction_detail_id.DataPropertyName].ToString()) ? Int64.MinValue : (Int64)dtTransaction_detail.Rows[i][coltransaction_detail_id.DataPropertyName];
                        var udd = from d in invEntities.transaction_detail
                                  where d.transaction_detail_id == detailId
                                  select d;
                        transaction_detail objDetail = udd.SingleOrDefault();
                        if (objDetail == null)
                            objDetail = new transaction_detail();
                        objDetail.transaction_master_id = obj.transaction_master_id;
                        objDetail.category_item_id = (Int64)dtTransaction_detail.Rows[i][colCategoryItemId.ColumnName];
                        objDetail.item_id = objItem.item_id;
                        if (!string.IsNullOrEmpty(dtTransaction_detail.Rows[i][colQuantity.ColumnName].ToString()))
                            objDetail.quantity = (decimal)dtTransaction_detail.Rows[i][colQuantity.ColumnName];
                        if (!string.IsNullOrEmpty(dtTransaction_detail.Rows[i][colUnitId.ColumnName].ToString()))
                            objDetail.unit_id = (Int64)dtTransaction_detail.Rows[i][colUnitId.ColumnName];
                        objDetail.description = dtTransaction_detail.Rows[i][colDescription.ColumnName].ToString();
                        objDetail.create_user = obj.create_user;
                        objDetail.update_user = obj.create_user;
                        objDetail.created_date = DateTime.Now;
                        objDetail.update_date = DateTime.Now;
                        if (objDetail.transaction_detail_id == 0)
                        {
                            invEntities.transaction_detail.Add(objDetail);
                        }
                        invEntities.SaveChanges();
                    }
                    else if (dtTransaction_detail.Rows[i].RowState == DataRowState.Deleted)
                    {

                    }
                }

                #endregion end insert detail and item
                #region reload data
                if (new_Master_Id != TransactionMasterId)
                {
                    this.TransactionMasterId = new_Master_Id;
                }
                else
                {
                    getDataCombo();
                    getDataComboForGridView();
                    GetDataById();
                }

                #endregion end reload data
            }
        }
Ejemplo n.º 7
0
 private void grdView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (this.grdView.Columns[e.ColumnIndex].DataPropertyName == colItemId.ColumnName)
     {
         using (InventoryEntities invEntities = new InventoryEntities())
         {
             Int64 itemId = (Int64)this.grdView.CurrentCell.Value;
             var result = (from i in invEntities.items where i.item_id == itemId select i).FirstOrDefault();
             this.grdView.CurrentRow.Cells[3].Value = result.item_code;
             this.grdView.CurrentRow.Cells[4].Value = result.item_name;
             this.grdView.CurrentRow.Cells[6].Value = result.category_item_id;
             this.grdView.CurrentRow.Cells[7].Value = result.unit_id;
             this.grdView.CurrentRow.Cells[9].Value = result.features;
             this.grdView.CurrentRow.Cells[10].Value = result.specifications;
         }
     }
 }
Ejemplo n.º 8
0
        private void getDataComboForGridView()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {
                ///get data CategoryItem
                List<category_item> listC = new List<category_item>();
                var resultC = (from c in invEntities.category_item orderby c.category_item_code select c);
                listC.AddRange(new category_item[] { new category_item { category_item_id = Int64.MinValue, category_item_code = "<Select a subject>", category_item_name = "<Select a subject>" } });
                foreach (category_item item in resultC) listC.Add(item);
                DataTable tblResultC = Utils.ConvertToDataTable(listC);
                dtCategory_item.Clear();
                dtCategory_item.Merge(tblResultC);
                dtCategory_item.AcceptChanges();

                ///get data Unit
                List<unit> listU = new List<unit>();
                var resultU = (from u in invEntities.units orderby u.unit_code select u);
                listU.AddRange(new unit[] { new unit { unit_id = Int64.MinValue, unit_code = "<Select a subject>", unit_name = "<Select a subject>" } });
                foreach (unit item in resultU) listU.Add(item);
                DataTable tblResultU = Utils.ConvertToDataTable(listU);
                dtUnit.Clear();
                dtUnit.Merge(tblResultU);
                dtUnit.AcceptChanges();

                ///get data Item
                List<item> listI = new List<item>();
                var resultI = (from i in invEntities.items orderby i.item_code select i);
                listI.AddRange(new item[] { new item { item_id = Int64.MinValue, item_code = "<Select a subject>", item_name = "<Select a subject>" } });
                foreach (item item in resultI) listI.Add(item);
                DataTable tblResultI = Utils.ConvertToDataTable(listI);
                dtItem.Clear();
                dtItem.Merge(tblResultI);
                dtItem.AcceptChanges();
            }
        }
Ejemplo n.º 9
0
        private void getDataCombo()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {
                ///get data Supplier
                List<supplier> listS = new List<supplier>();
                var resultS = (from s in invEntities.suppliers orderby s.supplier_code select s);
                listS.AddRange(new supplier[] { new supplier { supplier_id = Int64.MinValue, supplier_code = "<Select a subject>", supplier_name = "<Select a subject>" } });
                foreach (supplier item in resultS) listS.Add(item);
                cboSupplier.DataSource = listS;
                cboSupplier.ValueMember = "supplier_id";
                cboSupplier.DisplayMember = "supplier_code";

                ///get data Warehouses
                List<warehouse> listW = new List<warehouse>();
                var resultW = (from w in invEntities.warehouses orderby w.warehouse_code select w);
                listW.AddRange(new warehouse[] { new warehouse { warehouse_id = Int64.MinValue, warehouse_code = "<Select a subject>", warehouse_name = "<Select a subject>" } });
                foreach (warehouse item in resultW) listW.Add(item);
                cboReceived_warehouse.DataSource = listW;
                cboReceived_warehouse.ValueMember = "warehouse_id";
                cboReceived_warehouse.DisplayMember = "warehouse_code";
            }
        }
Ejemplo n.º 10
0
        private void GetDataById()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {
                ///get data table TransactionMasters
                var result = (from m in invEntities.transaction_master  where m.transaction_master_id == TransactionMasterId select m).FirstOrDefault();
                if (result != null)
                {
                    txtTransaction_code.Text = result.transaction_code;
                    dtpTransaction_date.Value = result.transaction_date;
                    cboReceived_warehouse.SelectedValue = result.received_warehouse_id == null ? Int64.MinValue : result.received_warehouse_id;
                    cboSupplier.SelectedValue = result.supplier_id == null ? Int64.MinValue : result.supplier_id;
                    txtDeliver.Text = result.deliver;
                    txtReceiver.Text = result.receiver;
                    txtCreate_user.Text = result.create_user;
                    txtDescription.Text = result.description;
                }
                else
                {
                    txtTransaction_code.Text =string.Empty;
                    dtpTransaction_date.Value = DateTime.Now;
                    cboReceived_warehouse.SelectedValue = Int64.MinValue;
                    cboSupplier.SelectedValue = Int64.MinValue;
                    txtDescription.Text = string.Empty;
                    txtDeliver.Text = string.Empty;
                    txtReceiver.Text = string.Empty;
                    txtCreate_user.Text = string.Empty;
                }

                ///get data table TransactionDetails
                var query = default(IEnumerable<TransactionDetailViewModel>);

                query = from d in invEntities.transaction_detail
                        where d.transaction_master_id == TransactionMasterId
                        select new TransactionDetailViewModel
                                    {
                                        transaction_master_id = d.transaction_master_id,
                                        transaction_detail_id = d.transaction_detail_id,
                                        category_item_id = d.category_item_id,
                                        category_item_code = d.category_item.category_item_code,
                                        category_item_name = d.category_item.category_item_name,
                                        item_id = d.item_id,
                                        item_code = d.item.item_code,
                                        item_name = d.item.item_name,
                                        price = d.price,
                                        unit_id = d.unit_id,
                                        unit_code = d.unit.unit_code,
                                        unit_name = d.unit.unit_name,
                                        quantity = d.quantity,
                                        total_price = d.total_price,
                                        percent_charges = d.total_price,
                                        total_charges = d.total_charges,
                                        total_amount = d.total_amount,
                                        description = d.description,
                                        create_user = d.create_user,
                                        created_date = d.created_date,
                                        features = d.item.features,
                                        specifications = d.item.specifications
                                    };

                dtTransaction_detail.Rows.Clear();
                dtTransaction_detail = Utils.ToDataTable(query);
                dtTransaction_detail.AcceptChanges();
                if (dtTransaction_detail != null && dtTransaction_detail.Rows.Count > 0)
                    this.grdView.DataSource = dtTransaction_detail;
            }
        }
Ejemplo n.º 11
0
        private void grdView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (FormEvents == 1 || FormEvents == 2)
            {
                if (this.grdView.Columns[e.ColumnIndex].DataPropertyName == colItemId.ColumnName)
                {
                    using (InventoryEntities invEntities = new InventoryEntities())
                    {
                        Int64 itemId = (Int64)this.grdView.CurrentCell.Value;
                        var result = (from i in invEntities.items where i.item_id == itemId select i).FirstOrDefault();
                        this.grdView.CurrentRow.Cells[3].Value = result.item_code;
                        this.grdView.CurrentRow.Cells[4].Value = result.item_name;
                        this.grdView.CurrentRow.Cells[6].Value = result.category_item_id;
                        this.grdView.CurrentRow.Cells[7].Value = result.unit_id;
                        this.grdView.CurrentRow.Cells[9].Value = result.features;
                        this.grdView.CurrentRow.Cells[10].Value = result.specifications;
                        for (int i = 0; i < dtItem.Rows.Count; i++)
                        {
                            if ((Int64)dtItem.Rows[i][colItemId.ColumnName] == itemId && dtItem.Rows[i]["balance"] != null)
                            {
                                this.grdView.CurrentRow.Cells[8].Value = dtItem.Rows[i]["balance"];
                                break;
                            }
                        }

                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void getDataComboForGridView()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {
                ///get data CategoryItem
                List<category_item> listC = new List<category_item>();
                var resultC = (from c in invEntities.category_item orderby c.category_item_code select c);
                listC.AddRange(new category_item[] { new category_item { category_item_id = Int64.MinValue, category_item_code = "<Select a subject>", category_item_name = "<Select a subject>" } });
                foreach (category_item item in resultC) listC.Add(item);
                DataTable tblResultC = Utils.ConvertToDataTable(listC);
                dtCategory_item.Clear();
                dtCategory_item.Merge(tblResultC);
                dtCategory_item.AcceptChanges();

                ///get data Unit
                List<unit> listU = new List<unit>();
                var resultU = (from u in invEntities.units orderby u.unit_code select u);
                listU.AddRange(new unit[] { new unit { unit_id = Int64.MinValue, unit_code = "<Select a subject>", unit_name = "<Select a subject>" } });
                foreach (unit item in resultU) listU.Add(item);
                DataTable tblResultU = Utils.ConvertToDataTable(listU);
                dtUnit.Clear();
                dtUnit.Merge(tblResultU);
                dtUnit.AcceptChanges();

                ///
                ///get data Item
                ///
                if (FormEvents == 1 || FormEvents == 2)
                {
                    Int64 warehouseId = -1;
                    if (cboDelivered_warehouse.SelectedValue != null && (Int64)cboDelivered_warehouse.SelectedValue != Int64.MinValue)
                        warehouseId = (Int64)cboDelivered_warehouse.SelectedValue;
                    var dtReport = ReportView.reportFinal(warehouseId, string.Empty, DateTime.MinValue, DateTime.MinValue);
                    dtItem.Clear();
                    dtItem.Merge(dtReport);
                    dtItem.AcceptChanges();
                }
                else
                {
                    List<item> listI = new List<item>();
                    var resultI = (from i in invEntities.items orderby i.item_code select i);
                    listI.AddRange(new item[] { new item { item_id = Int64.MinValue, item_code = "<Select a subject>", item_name = "<Select a subject>" } });
                    foreach (item item in resultI) listI.Add(item);
                    DataTable tblResultI = Utils.ConvertToDataTable(listI);
                    dtItem.Clear();
                    dtItem.Merge(tblResultI);
                    dtItem.AcceptChanges();
                }
            }
        }
Ejemplo n.º 13
0
        private void getDataCombo()
        {
            using (InventoryEntities invEntities = new InventoryEntities())
            {

                ///get data Warehouses
                List<warehouse> listR = new List<warehouse>();
                listR.AddRange(new warehouse[] { new warehouse { warehouse_id = Int64.MinValue, warehouse_code = "<Select a subject>", warehouse_name = "<Select a subject>" } });
                ///get data Warehouses
                List<warehouse> listD = new List<warehouse>();
                listD.AddRange(new warehouse[] { new warehouse { warehouse_id = Int64.MinValue, warehouse_code = "<Select a subject>", warehouse_name = "<Select a subject>" } });

                var resultW = (from w in invEntities.warehouses orderby w.warehouse_code select w);
                foreach (warehouse item in resultW)
                {
                    listR.Add(item);
                    listD.Add(item);
                }
                cboReceived_warehouse.DataSource = listR;
                cboReceived_warehouse.ValueMember = "warehouse_id";
                cboReceived_warehouse.DisplayMember = "warehouse_code";

                cboDelivered_warehouse.DataSource = listD;
                cboDelivered_warehouse.ValueMember = "warehouse_id";
                cboDelivered_warehouse.DisplayMember = "warehouse_code";
            }
        }
Ejemplo n.º 14
0
 private void cboDelivered_warehouse_SelectedValueChanged(object sender, EventArgs e)
 {
     if (FormEvents == 1 || FormEvents == 2)
     {
         Int64 warehouseId = -1;
         if (cboDelivered_warehouse.SelectedValue != null && (Int64)cboDelivered_warehouse.SelectedValue != Int64.MinValue)
             warehouseId = (Int64)cboDelivered_warehouse.SelectedValue;
         var dtReport = ReportView.reportFinal(warehouseId, string.Empty, DateTime.MinValue, DateTime.MinValue);
         dtItem.Clear();
         dtItem.Merge(dtReport);
         dtItem.AcceptChanges();
     }
     else
     {
         InventoryEntities invEntities = new InventoryEntities();
         List<item> listI = new List<item>();
         var resultI = (from i in invEntities.items orderby i.item_code select i);
         listI.AddRange(new item[] { new item { item_id = Int64.MinValue, item_code = "<Select a subject>", item_name = "<Select a subject>" } });
         foreach (item item in resultI) listI.Add(item);
         DataTable tblResultI = Utils.ConvertToDataTable(listI);
         dtItem.Clear();
         dtItem.Merge(tblResultI);
         dtItem.AcceptChanges();
     }
 }