Пример #1
0
 public DsMaster.PRINTERSDataTable GetPrinters()
 {
     var ds = new DsMaster().PRINTERS;
     var ta = new DsMasterTableAdapters.PRINTERSTableAdapter {Connection = {ConnectionString = _constr}};
     ta.Fill(ds);
     return ds;
 }
Пример #2
0
        public string DoSave(DsMaster.PRINTERSRow printersRow)
        {
            try
            {
                var dt = new DsMaster().PRINTERS;
                var ta = new DsMasterTableAdapters.PRINTERSTableAdapter() {Connection = {ConnectionString = _constr}};
                bool isnew = false;
                ta.Fill(dt);
                var drnew = dt.FindByTID(printersRow.TID);
                if (drnew != null)
                {
                    drnew.BeginEdit();
                }
                else
                {
                    drnew = (DsMaster.PRINTERSRow) dt.NewRow();
                    isnew = true;
                }
                drnew.BarcodePrinter = printersRow.BarcodePrinter;
                drnew.Invoiceprinter = printersRow.Invoiceprinter;
                drnew.Drugprinter = printersRow.Drugprinter;
                drnew.Computer = printersRow.Computer;
                drnew.Defaultprinter = printersRow.Defaultprinter;
                drnew.ISDEFAULT = printersRow.ISDEFAULT;
                if (isnew)
                {
                    dt.Rows.Add(drnew);
                    ta.Update(dt);
                }
                else
                {
                    drnew.EndEdit();

                    ta.Update(drnew);
                }
                return "1";
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }