Пример #1
0
        private void SaveSalesUnitDt(SqlConnection conn, SqlTransaction trans)
        {
            using (var salesDt = new SalesUnitDt())
            {
                salesDt.ID         = BussinessRules.ID.GenerateIDNumberWithBeginTransaction("SalesUnitDt", "ID", conn, trans, "SU", " Where ID like 'SU%' ");
                salesDt.STxnNo     = txtSTxnNo.Text.Trim();
                salesDt.ItemSeqNo  = txtItemID.Text.Trim();
                salesDt.UserInsert = _loginInfo.UserID;
                salesDt.UserUpdate = _loginInfo.UserID;
                salesDt.ItemUnitID = txtItemUnitID.Text.Trim();
                salesDt.ItemFactor = Convert.ToDecimal(txtItemFactor.Text.Trim());
                salesDt.Qty        = (txtToggleOperator.Text == "-" ? (-1 * Convert.ToDecimal(numQty.Value)) : Convert.ToDecimal(numQty.Value));
                salesDt.Price      = Convert.ToDecimal(lblUnitPrice.Text.Trim());
                salesDt.Disc1Pct   = Convert.ToDecimal(1 == 0 ? 0 : 0);
                salesDt.Disc1Amt   = Convert.ToDecimal(lblUnitDisc1.Text.Trim());
                salesDt.Disc2Pct   = Convert.ToDecimal(0 == 0 ? 0 : 0);
                salesDt.Disc2Amt   = Convert.ToDecimal(lblUnitDisc2.Text.Trim());

                salesDt.Disc3Pct    = Convert.ToDecimal(0 == 0 ? 0 : 0);
                salesDt.Disc3Amt    = Convert.ToDecimal(0 == 0 ? 0 : 0);
                salesDt.Description = "";
                salesDt.Insert(conn, trans);
            }
        }
Пример #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;
                }
            }
        }