Пример #1
0
        private void PopulateGrid(string FilterValue)
        {
            grdItem.SuspendLayout();
            grdItem.AutoGenerateColumns = false;

            var oSalesUnitDt = new SalesUnitDt();
            var tmpDVSalesdt = new DataView(oSalesUnitDt.SelectByNoForCancelItem(_STxnNo.Trim()));

            tmpDVSalesdt.Sort      = "ItemID, ItemFactor, Qty";
            tmpDVSalesdt.RowFilter = "ItemID Like '%" + FilterValue.Trim() + "%' Or ItemName Like '%" + FilterValue.Trim() + "%' ";
            grdItem.DataSource     = tmpDVSalesdt;
            grdItem.ResumeLayout();

            oSalesUnitDt.Dispose();
            oSalesUnitDt = null;
        }
Пример #2
0
        private void SelectItem()
        {
            if (grdItem.RowCount > 0)
            {
                if (Program.MsgBox_Show("Are you sure want to cancel this Item ? ", "Confirmation", "YesNo"))
                {
                    var oSalesUnitDt = new SalesUnitDt();
                    oSalesUnitDt.ID = grdItem.SelectedRows[0].Cells["SalesDtID"].Value.ToString();
                    if (oSalesUnitDt.SelectOne().Rows.Count > 0)
                    {
                        var            conn  = new SqlConnection(HisConfiguration.ConnectionString);
                        SqlTransaction trans = null;
                        try
                        {
                            conn.Open();
                            trans                   = conn.BeginTransaction();
                            oSalesUnitDt.ID         = BussinessRules.ID.GenerateIDNumberWithBeginTransaction("SalesUnitDt", "ID", conn, trans, "SU");
                            oSalesUnitDt.ItemSeqNo  = grdItem.SelectedRows[0].Cells["ItemID"].Value.ToString();
                            oSalesUnitDt.Qty        = -(oSalesUnitDt.Qty);
                            oSalesUnitDt.UserInsert = _UserID;
                            oSalesUnitDt.UserUpdate = _UserID;
                            oSalesUnitDt.Insert(conn, trans);
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            if (trans != null)
                            {
                                trans.Rollback();
                                trans.Dispose();
                            }
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            if (trans != null)
                            {
                                trans.Dispose();
                            }
                            conn.Close();
                            conn.Dispose();
                        }

                        _retval = true;
                        Close();

                        //oSalesUnitDt.ID = BussinessRules.ID.GenerateIDNumber("SalesUnitDt", "ID", "SU");
                        //oSalesUnitDt.ItemSeqNo = grdItem.SelectedRows[0].Cells["ItemID"].Value.ToString();
                        //oSalesUnitDt.Qty = -(oSalesUnitDt.Qty);
                        //oSalesUnitDt.UserInsert = _UserID;
                        //oSalesUnitDt.UserUpdate = _UserID;
                        //oSalesUnitDt.Insert();
                        //_retval = true;
                        //Close();
                    }
                    else
                    {
                        Program.MsgBox_Show("Item is not found, please select another item");
                        PopulateGrid(txtSearch.Text.Trim());
                    }
                    oSalesUnitDt.Dispose();
                    oSalesUnitDt = null;
                }
            }
        }