Exemplo n.º 1
0
        public string DoSaveItemTranferInRemote(DsInventory.ITEMTRANSFERMAINRow drow,DsInventory.ITEMTRANSFERDETAILDataTable itemtransferdetail)
        {
            var dm = new DataManager();
            string retval=string.Empty;
            SqlTransaction tran = null;
            try
            {
                var cn = new SqlConnection(_syncConstr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);

                var ds = new DsInventory();
                var dtdetail = ds.ITEMTRANSFERDETAIL;
                var dt = ds.ITEMTRANSFERMAIN;

                var taPurMain = new ITEMTRANSFERMAINTableAdapter();

                var taPurDetail = new ITEMTRANSFERDETAILTableAdapter();

                taPurMain.Connection.ConnectionString = _syncConstr;

            //   taPurMain.Fill(ds.ITEMTRANSFERMAIN);

                taPurMain.FillByTranid(dt, drow.TRANID);

                // Assaign Transaction
                taPurMain.AssignConnection(cn, tran);
                taPurDetail.AssignConnection(cn, tran);
                
                var dr = dt.FindByTRANID(drow.TRANID);

                if (dr == null)
                {
                    dr = (DsInventory.ITEMTRANSFERMAINRow) dt.NewRow();
                    dr.TRANID = drow.TRANID;
                    dr.COMPANY = drow.COMPANY;
                    if (!drow.IsEDATENull())
                    dr.EDATE = drow.EDATE;
                    if (!drow.IsEUSERIDNull())
                    dr.EUSERID = drow.EUSERID;
                    dr.FRMSTOREID = drow.FRMSTOREID;
                    dr.TOSTOREID = drow.TOSTOREID;
                    dr.TRANDATE = drow.TRANDATE;
                    dr.TOTVALUE = drow.TOTVALUE;
                    dr.TOTITEMS = drow.TOTITEMS;
                    dr.HOLD = drow.HOLD;
                    dr.FRMNAME = drow.FRMNAME;
                    dr.TONAME = drow.TONAME;
                    dr.TTYPE = drow.TTYPE;
                    dr.TOCOMP = drow.TOCOMP;
                    dr.USERID = drow.USERID;
                    dr.DOWNFILENO = drow.DOWNFILENO;
                    dt.Rows.Add(dr);
                    taPurMain.Update(dt);
                    foreach (DsInventory.ITEMTRANSFERDETAILRow  ditemdetarow in itemtransferdetail)
                    {
                        var newdetrow = dtdetail.NewRow();
                        foreach (DataColumn dc in itemtransferdetail.Columns)
                        {
                            if (!dc.ReadOnly)
                            {
                                newdetrow[dc.ColumnName] = ditemdetarow[dc.ColumnName];
                            }
                        }
                        dtdetail.Rows.Add(newdetrow);
                    }
                    taPurDetail.Update(dtdetail);
                    tran.Commit();
                    retval = "1";
                }
                else
                {
                    retval = "1"; 
                }
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                retval = ex.ToString();
            }
            return retval;
        }
Exemplo n.º 2
0
        public string DoSave(DsInventory xInventory, string tranid, bool allitems = false)
        {
            string retval = "0";
            SqlTransaction tran = null;
            var isnew = false;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new DsInventory();

                //var dt = ds.ITEMTRANSFERMAIN;
                var taTranmain = new ITEMTRANSFERMAINTableAdapter();
                var taTranetail = new ITEMTRANSFERDETAILTableAdapter();
                var taStockMaster = new STOCKMASTERTableAdapter();
                var taSupplier = new SUPPLIERTableAdapter();

                // var taSupplier = new DsMasterTableAdapters.SUPPLIERTableAdapter();
                // var taItem = new DsMasterTableAdapters.ITEMMASTTableAdapter();

                var taItem = new ITEMMAST1TableAdapter();

                // tas
                taTranmain.Connection.ConnectionString = _constr;
                taTranetail.Connection.ConnectionString = _constr;
                taStockMaster.Connection.ConnectionString = _constr;
                taSupplier.Connection.ConnectionString = _constr;
                taItem.Connection.ConnectionString = _constr;

                taTranmain.Fill(ds.ITEMTRANSFERMAIN);
                taTranetail.Fill(ds.ITEMTRANSFERDETAIL);

                taSupplier.Fill(ds.SUPPLIER);
                taItem.Fill(ds.ITEMMAST1);

                //taStockMaster.Fill(ds.STOCKMASTER);

                taTranmain.AssignConnection(cn, tran);
                taTranetail.AssignConnection(cn, tran);
                taItem.AssignConnection(cn, tran);
                taSupplier.AssignConnection(cn, tran);
                taStockMaster.AssignConnection(cn, tran); //tas   bool isnew =false;
                DataTable dtsupplier;
                DataTable dtitems;
                if (!allitems)
                {
                    dtsupplier = xInventory.GetSupplierForRemoteUpdate;
                    dtitems = xInventory.GetItemsForRemoteUpdate;
                }
                else
                {
                    dtsupplier = xInventory.SUPPLIER;
                    dtitems = xInventory.ITEMMAST1;
                }
                var dtitemtrans = xInventory.ITEMTRANSFERMAIN;
                var dtitemtrandetails = xInventory.ITEMTRANSFERDETAIL;
                foreach (DataRow dr in dtsupplier.Rows)
                {
                    isnew = false;
                    var dsup = ds.SUPPLIER.FindBySUPPLIERNO(dr["SUPPLIERNO"].ToString());
                    if (dsup != null)
                    {
                        dsup.BeginEdit();
                    }
                    else
                    {
                        dsup = (DsInventory.SUPPLIERRow) ds.SUPPLIER.NewRow();
                        isnew = true;
                        foreach (DataColumn dc in dtsupplier.Columns)
                        {
                            dsup[dc.ColumnName] = dr[dc.ColumnName];
                        }
                    }
                    bool update = true;
                    if (!isnew)
                    {
                        update = Equals(dr, dsup);
                    }
                    if (!update)
                    {
                        foreach (DataColumn dc in dtsupplier.Columns)
                        {
                            if (!dc.ReadOnly)
                                dsup[dc.ColumnName] = dr[dc.ColumnName];
                        }
                    }
                    if (isnew)
                    {
                        ds.SUPPLIER.Rows.Add(dr.ItemArray);
                        var t = taSupplier.Update(ds.SUPPLIER);
                        if (t == 0)
                            retval += " Supplier master not created";
                    }
                    else
                    {
                        dsup.EndEdit();
                        taSupplier.Update(dsup);
                    }
                }
                foreach (DataRow dr in dtitems.Rows)
                {
                    isnew = false;
                    var dsup = ds.ITEMMAST1.FindByITEMNO(dr["ITEMNO"].ToString());
                    if (dsup != null)
                    {
                        dsup.BeginEdit();
                    }
                    else
                    {
                        dsup = (DsInventory.ITEMMAST1Row) ds.ITEMMAST1.NewRow();
                        isnew = true;
                    }
                    bool update = true;

                    if (!isnew)
                    {
                        update = Equals(dr, dsup);
                    }
                    if (!update)
                    {
                        foreach (DataColumn dc in dtitems.Columns)
                        {
                            if (!dc.ReadOnly)
                                dsup[dc.ColumnName] = dr[dc.ColumnName];
                        }
                    }
                    if (isnew)
                    {

                        ds.ITEMMAST1.Rows.Add(dr.ItemArray);
                        var t = taItem.Update(ds.ITEMMAST1);
                        if (t == 0)
                            retval += "item mast not created";
                    }
                    else
                    {
                        dsup.EndEdit();
                        taItem.Update(dsup);
                    }
                }
// first find the file No and then update
                bool download = false;
                var ItemsToAddStockMaster = new DsInventory.ITEMTRANSFERDETAILDataTable();
                //var dsup = ds.ITEMTRANSFERMAIN.FindByTRANID(ditemrow["TRANID"].ToString());
                var tranmaster = dtitemtrans.Select("tranid= '" + tranid + "'");
                foreach (DataRow ditemrow in tranmaster)
                {
                    var dsup = ds.ITEMTRANSFERMAIN.FindByTRANID(ditemrow["TRANID"].ToString());
                    if (dsup == null)
                    {
                        download = true;
                        var fno = ditemrow["AFILENO"].ToString();
                        ditemrow["ISREC"] = 1;
                        ditemrow["DOWNFILENO"] = fno;
                        ditemrow["AFILENO"] = string.Empty;
                        ds.ITEMTRANSFERMAIN.Rows.Add(ditemrow.ItemArray);
                        var t = ditemrow["TRANID"].ToString();
                        var drdetrows = dtitemtrandetails.Select("tranid= '" + t + "'");
                        foreach (DataRow ditemdetarow in drdetrows)
                        {
                            var newdetrow = ds.ITEMTRANSFERDETAIL.NewRow();
                            var newdettransrow = ItemsToAddStockMaster.NewRow();
                            foreach (DataColumn dc in dtitemtrandetails.Columns)
                            {
                                if (!dc.ReadOnly)
                                {
                                    newdetrow[dc.ColumnName] = ditemdetarow[dc.ColumnName];
                                    newdettransrow[dc.ColumnName] = ditemdetarow[dc.ColumnName];
                                }
                            }
                            ds.ITEMTRANSFERDETAIL.Rows.Add(newdetrow);
                            ItemsToAddStockMaster.Rows.Add(newdettransrow);
                        }
                    }
                }
                var bl = new Masters.StockMaster(); // send to stock only donwloading data only.
                var s = new Masters.StoreManager().GetStoreType(whid);
                string storetype = "S";
                if (s.IndexOf("S") == -1)
                {
                    storetype = "P";
                }
                if (download)
                {
                    bl.CreateStock(ref cn, ref tran, ItemsToAddStockMaster, whid, storetype, false, false);
                }
                taTranmain.Update(ds.ITEMTRANSFERMAIN);
                taTranetail.Update(ds.ITEMTRANSFERDETAIL);
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                retval = ex.ToString();
            }
            return retval;
        }
Exemplo n.º 3
0
 public void DeleteItemMove(string tranid)
 {
     var ta = new ITEMTRANSFERMAINTableAdapter();
     var tadel = new ITEMTRANSFERDETAILTableAdapter();
     ta.Connection.ConnectionString = _constr;
     tadel.Connection.ConnectionString = _constr;
     tadel.DeleteQuery(tranid);
     ta.DeleteQuery(tranid);
 }
Exemplo n.º 4
0
 public DsInventory CreateDataSetForXmlFile(string tranids)
 {
     var dsxml = new DsInventory();
     var ta = new ITEMTRANSFERMAINTableAdapter {Connection = {ConnectionString = _constr}};
     ta.FillByTranid(dsxml.ITEMTRANSFERMAIN, tranids);
     var tadet = new ITEMTRANSFERDETAILTableAdapter {Connection = {ConnectionString = _constr}};
     ;
     tadet.FillByTranid(dsxml.ITEMTRANSFERDETAIL, tranids);
     var taItems = new GetItemsForRemoteUpdateTableAdapter {Connection = {ConnectionString = _constr}};
     ;
     taItems.Fill(dsxml.GetItemsForRemoteUpdate, tranids);
     var taSuppliers = new GetSupplierForRemoteUpdateTableAdapter {Connection = {ConnectionString = _constr}};
     ;
     taSuppliers.Fill(dsxml.GetSupplierForRemoteUpdate, tranids);
     return dsxml;
 }
Exemplo n.º 5
0
        public string DoSave(DsInventory.ITEMTRANSFERMAINRow drow,
            DsInventory.ITEMTRANSFERDETAILDataTable itemtransferdetail, string Stype)
        {
            var dm = new DataManager();
            string retval = "0";
            SqlTransaction tran = null;
            var isnew = false;
            try
            {
                var cn = new SqlConnection(_constr);
                cn.Open();
                tran = cn.BeginTransaction(IsolationLevel.ReadUncommitted);
                var ds = new DsInventory();
                var dt = ds.ITEMTRANSFERMAIN;
                var taItemTransMain = new ITEMTRANSFERMAINTableAdapter();
                var taItremTransDetail = new ITEMTRANSFERDETAILTableAdapter();
                var taStockMaster = new STOCKMASTERTableAdapter {Connection = {ConnectionString = _constr}};
                taItemTransMain.Connection.ConnectionString = _constr;
                taStockMaster.Fill(ds.STOCKMASTER);
                taItemTransMain.FillByTranid(dt, drow.TRANID);
                // Assaign Transaction
                taItemTransMain.AssignConnection(cn, tran);
                taItremTransDetail.AssignConnection(cn, tran);
                taStockMaster.AssignConnection(cn, tran);
                var dr = dt.FindByTRANID(drow.TRANID);

                if (dr != null)
                {
                    dr.BeginEdit();
                }
                else
                {
                    dr = (DsInventory.ITEMTRANSFERMAINRow) dt.NewRow();
                    isnew = true;
                }
                if (isnew)
                {
                    var autoid = dm.GetAutoId(3);
                    autoid++;
                    Utils.Tranid = dm.CreateFormatedAutoNo(autoid);
                    dr.TRANID = Utils.Tranid;
                    dr.COMPANY = Utils.Company;
                }
                else
                {
                    Utils.Tranid = drow.TRANID;
                    dr.EDATE = DateTime.Now;
                    dr.EUSERID = Utils.Userid;
                }
                dr.FRMSTOREID = drow.FRMSTOREID;
                dr.TOSTOREID = drow.TOSTOREID;
                dr.TRANDATE = drow.TRANDATE;
                dr.TOTVALUE = drow.TOTVALUE;
                dr.TOTITEMS = itemtransferdetail.Count;
                dr.HOLD = drow.HOLD;
                dr.FRMNAME = drow.FRMNAME;
                dr.TONAME = drow.TONAME;
                dr.TTYPE = drow.TTYPE;
                dr.TOCOMP = drow.TOCOMP;
                dr.USERID = drow.USERID;
                var taa = new DataManager();
                dr.DOWNFILENO = drow.DOWNFILENO;
                if (isnew)
                {
                    dt.Rows.Add(dr);
                    taItemTransMain.Update(dt);
                    if (dr.TTYPE == 3)
                    {
                        dr.AFILENO = Utils.Tranid; // taa.CreateFormatedAutoNo(taa.GetAutoId(5));
                        dr.FLAGFILE = true;
                    }
                }
                else
                {
                    dr.EndEdit();
                    taItemTransMain.Update(dr);
                }
                foreach (DataRow purd in itemtransferdetail.Rows)
                {
                    if ((purd.RowState != DataRowState.Deleted))
                    {
                        purd["TRANID"] = Utils.Tranid;
                        purd["TOSTORE"] = drow.TOSTOREID;
                    }
                }
                taItremTransDetail.Update(itemtransferdetail);
                if (!dr.HOLD)
                {
                    Masters.StockMaster.UpdateQtyInStockDataSet(ref cn, ref tran, itemtransferdetail, false);
                    if (dr.TTYPE == 3)
                    {
                        new Masters.StockMaster().CreateStock(ref cn, ref tran, itemtransferdetail, drow.TOSTOREID,
                            Stype, false, false);
                    }
                    dm.UpdateAutoNum(3);
                }
                tran.Commit();
                retval = "1";
            }
            catch (Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                if (isnew)
                    Utils.Tranid = string.Empty;
                retval = ex.ToString();
            }
            return retval;
        }
Exemplo n.º 6
0
 public DsInventory.ITEMTRANSFERDETAILDataTable GetItemTransferDetailById(string tranid, bool othercomp = false,
     string concomp = "")
 {
     var ta = new ITEMTRANSFERDETAILTableAdapter
     {
         Connection = {ConnectionString = othercomp ? concomp : _constr}
     };
     var ds = new DsInventory.ITEMTRANSFERDETAILDataTable();
     ta.FillByTranid(ds, tranid);
     return ds;
 }