Ejemplo n.º 1
0
        public void FillTheTable(SoItems item)
        {
            this.soItem = item;
            this.soItemsControl1.FillItems(item);
            SetComboxItem();

            if (!isNewCreateSo)
            {
                if (soItemOrderStateList.GetSoStateAccordingToValue(item.soItemState).WhoCanUpdate().Contains(UserInfo.Job))
                {
                    this.tsbOp.Enabled = true;
                }
                else
                {
                    this.tsbOp.Enabled = false;
                }

                if (UserCombine.GetUserCanBeBuyers().Contains((int)UserInfo.Job))
                {
                    if (soItem.soItemState == new SoItemNew().GetStateValue())
                    {
                        this.tsbGeneratePo.Enabled = false;
                    }
                    else
                    {
                        this.tsbGeneratePo.Enabled = true;
                    }
                }
                else
                {
                    this.tsbGeneratePo.Enabled = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void GenerateGui()
        {
            po poMain = poList[tabControl1.SelectedIndex];

            if (poMain.poStates != (int)PoStatesEnum.New && UserCombine.GetUserCanBeBuyerMananger().Contains((int)UserInfo.Job))
            {
                tsbUpdate.Enabled = true;
            }
            else if (poMain.poStates == (int)PoStatesEnum.New && UserCombine.GetUserCanBeBuyers().Contains((int)UserInfo.Job))
            {
                tsbUpdate.Enabled = true;
            }
            else
            {
                tsbUpdate.Enabled = false;
            }


            //for approve and rejected.
            if (poMain.poStates == (int)PoStatesEnum.New)
            {
                tsbApprove.Enabled = true;
                tsbReject.Enabled  = true;
            }
            else
            {
                tsbApprove.Enabled = false;
                tsbReject.Enabled  = false;
            }
            //for cancel

            if (poMain.poStates == (int)PoStatesEnum.Approved)
            {
                tsbCancel.Enabled = true;
            }
            else
            {
                tsbCancel.Enabled = false;
            }

            if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss)
            {
                tsbForceClose.Enabled = true;
            }
            else
            {
                tsbForceClose.Enabled = false;
            }

            if (!UserCombine.GetUserCanBeBuyerMananger().Contains((int)UserInfo.Job))
            {
                tsbApprove.Enabled    = false;
                tsbReject.Enabled     = false;
                tsbCancel.Enabled     = false;
                tsbForceClose.Enabled = false;
            }
        }
Ejemplo n.º 3
0
        private void FillThePACombo()
        {
            AmbleClient.Admin.AccountMgr.AccountMgr accountMgr = new Admin.AccountMgr.AccountMgr();
            mysubs = accountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeBuyers());

            buyerIdsAndNames = accountMgr.GetIdsAndNames(mysubs);

            foreach (string buyerName in buyerIdsAndNames.Values)
            {
                cbPa.Items.Add(buyerName);
            }
        }
Ejemplo n.º 4
0
        public static List <So> BuyerGetSoAccordingToFilter(int userId, bool includedSubs, string filterColumn, string filterString, List <int> states)

        {
            List <So> soList = new List <So>();

            if (states.Count == 0)
            {
                return(soList);
            }

            List <int> buyersIds = new List <int>();

            if (includedSubs)
            {
                var accountMgr = new AmbleClient.Admin.AccountMgr.AccountMgr();
                buyersIds.AddRange(accountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                buyersIds.Add(userId);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("select soId from So s,rfq r where(s.rfqId=r.rfqNo) and ( (r.firstPA={0} or r.secondPa={0})", buyersIds[0]));
            for (int i = 1; i < buyersIds.Count; i++)
            {
                sb.Append(string.Format(" or (firstPA={0} or secondPA={0}) ", buyersIds[i]));
            }
            sb.Append(" ) ");

            //append the filter
            if ((!string.IsNullOrWhiteSpace(filterColumn)) && (!string.IsNullOrWhiteSpace(filterString)))
            {
                sb.Append(string.Format(" and {0} like '%{1}%' ", filterColumn, filterString));
            }

            sb.Append(" and (soStates=" + states[0]);
            for (int i = 1; i < states.Count; i++)
            {
                sb.Append(" or soStates=" + states[i]);
            }
            sb.Append(" )");

            DataTable dt = db.GetDataTable(sb.ToString(), "soId");

            foreach (DataRow dr in dt.Rows)
            {
                soList.Add(GetSoAccordingToSoId(Convert.ToInt32(dr["soId"])));
            }
            return(soList);
        }
Ejemplo n.º 5
0
        public List <Offer> GetOfferAccordingToFilter(int userId, bool includeSubs, string filterColumn, string filterString, List <int> intStateList)
        {
            List <Offer> offerList = new List <Offer>();

            if (intStateList.Count == 0)
            {
                return(offerList);
            }
            List <int> buyerId = new List <int>();

            if (includeSubs)
            {
                var accountMgr = new AmbleClient.Admin.AccountMgr.AccountMgr();
                buyerId.AddRange(accountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                buyerId.Add(userId);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("select * from offer where ( buyerId=" + buyerId[0]);
            for (int i = 1; i < buyerId.Count; i++)
            {
                sb.Append(" or buyerId=" + buyerId[i]);
            }
            sb.Append(" ) ");

            //append the filter
            if ((!string.IsNullOrWhiteSpace(filterColumn)) && (!string.IsNullOrWhiteSpace(filterString)))
            {
                sb.Append(string.Format(" and {0} like '%{1}%' ", filterColumn, filterString));
            }

            sb.Append(" and ( offerStates=" + intStateList[0]);
            for (int i = 1; i < intStateList.Count; i++)
            {
                sb.Append(" or offerStates=" + intStateList[i]);
            }
            sb.Append(" )");

            DataTable dt = db.GetDataTable(sb.ToString(), "offers");

            foreach (DataRow dr in dt.Rows)
            {
                offerList.Add(GetOfferFromDataRow(dr));
            }
            return(offerList);
        }
Ejemplo n.º 6
0
        public static List <po> GetPoAccordingToFilter(int userId, bool includedSubs, string filterColumn, string filterString, List <int> stateList)
        {
            //get the sub;
            List <po> poList = new List <po>();

            if (stateList.Count == 0)
            {
                return(poList);
            }

            List <int> userIds = new List <int>();

            if (includedSubs)
            {
                var accountMgr = new AmbleClient.Admin.AccountMgr.AccountMgr();
                userIds.AddRange(accountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                userIds.Add(userId);
            }

            if (filterColumn.Trim().Length == 0 || filterString.Trim().Length == 0)
            {
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates))
                                   select poItem;

                poList.AddRange(poListFromDb);
            }

            if (filterColumn.Trim() == "vendorName" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates) &&
                                                                                (poItem.vendorName.Contains(filterString.Trim())))
                                   select poItem;

                poList.AddRange(poListFromDb);
            }
            return(poList);
        }
Ejemplo n.º 7
0
        public override void FillTheTable(AmbleClient.RfqGui.RfqManager.Rfq rfq)
        {
            base.FillTheTable(rfq);
            tbCustomer.Text = rfq.customerName;

            AmbleClient.Admin.AccountMgr.AccountMgr accountMgr = new Admin.AccountMgr.AccountMgr();

            this.tbContact.Text = string.Empty; //can not be seen by sales Manager
            this.tbPhone.Text   = string.Empty; //can not be seen by sales Manager.


            //Fill the sales
            List <int> sales = new List <int>();

            sales.Add(rfq.salesId);

            cbSales.Items.Add(accountMgr.GetIdsAndNames(sales)[rfq.salesId]);
            cbSales.SelectedIndex = 0;
            // cbSales.Text = (GlobalRemotingClient.GetAccountMgr().GetIdsAndNames(sales))[rfq.salesId];

            //Fill the PA
            mySubs = accountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeBuyers());
            Dictionary <int, string> mySubsIdAndName = accountMgr.GetIdsAndNames(mySubs);

            //确认里面的buyer是不是我的下属,如果不是,不能更改。
            if (rfq.firstPA.HasValue == false || mySubs.Contains(rfq.firstPA.Value))
            {
                foreach (string name in mySubsIdAndName.Values)
                {
                    cbPrimaryPA.Items.Add(name);
                }
                if (rfq.firstPA.HasValue == false)
                {
                    cbPrimaryPA.SelectedIndex = -1;
                }
                else
                {
                    cbPrimaryPA.SelectedIndex = mySubs.IndexOf(rfq.firstPA.Value);
                }
            }
            else
            {
                List <int> buyer = new List <int>();
                buyer.Add(rfq.firstPA.Value);
                cbPrimaryPA.Items.Add(accountMgr.GetIdsAndNames(buyer)[rfq.firstPA.Value]);
                cbPrimaryPA.SelectedIndex = 0;
            }
            if (rfq.secondPA.HasValue == false || mySubs.Contains(rfq.secondPA.Value))
            {
                foreach (string name in mySubsIdAndName.Values)
                {
                    cbAltPA.Items.Add(name);
                }

                if (rfq.secondPA.HasValue == false)
                {
                    cbAltPA.SelectedIndex = -1;
                }
                else
                {
                    cbAltPA.SelectedIndex = mySubs.IndexOf(rfq.secondPA.Value);
                }
            }
            else
            {
                List <int> buyer = new List <int>();
                buyer.Add(rfq.secondPA.Value);
                cbAltPA.Items.Add(accountMgr.GetIdsAndNames(buyer)[rfq.secondPA.Value]);
                cbAltPA.SelectedIndex = 0;
            }
        }
Ejemplo n.º 8
0
        public static custvendorinfo GetUniqueCustVenInfo(int cvtype, string cvName, int ownerId)
        {
            List <int> subIds;

            if (cvtype == 0)
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeSales());
            }
            else
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeBuyers());
            }

            var cvs = from cv in custVenEntity.custvendorinfo
                      where cv.cvtype == (sbyte)cvtype && subIds.Contains(cv.ownerName) && cv.cvname == cvName
                      select cv;

            if (cvs.Count() == 0)
            {
                return(null);
            }
            return(cvs.First());
        }
Ejemplo n.º 9
0
        public static Dictionary <string, string> GetContactInfo(int cvtype, int ownerId, string cvname)
        {
            Dictionary <string, string> contactInfo = new Dictionary <string, string>();
            List <int> subIds;

            if (cvtype == 0)
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeSales());
            }
            else
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeBuyers());
            }


            var cvs = from cv in custVenEntity.custvendorinfo
                      where cv.cvtype == (sbyte)cvtype && subIds.Contains(cv.ownerName) && cv.cvname == cvname
                      select new
            {
                Contact1  = cv.contact1,
                Contact2  = cv.contact2,
                Phone1    = cv.phone1,
                Phone2    = cv.phone2,
                CellPhone = cv.cellphone,
                Fax       = cv.fax,
                Email1    = cv.email1,
                Email2    = cv.email2
            };

            if (cvs.Count() == 0)
            {
                return(contactInfo);
            }
            var cvContactInfo = cvs.First();

            if (cvContactInfo.Contact1.Length != 0)
            {
                contactInfo.Add("contact1", cvContactInfo.Contact1);
            }
            if (cvContactInfo.Contact2.Length != 0)
            {
                contactInfo.Add("contact2", cvContactInfo.Contact2);
            }
            if (cvContactInfo.Phone1.Length != 0)
            {
                contactInfo.Add("phone1", cvContactInfo.Phone1);
            }
            if (cvContactInfo.Phone2.Length != 0)
            {
                contactInfo.Add("phone2", cvContactInfo.Phone2);
            }
            if (cvContactInfo.CellPhone.Length != 0)
            {
                contactInfo.Add("cellphone", cvContactInfo.CellPhone);
            }
            if (cvContactInfo.Fax.Length != 0)
            {
                contactInfo.Add("fax", cvContactInfo.Fax);
            }
            if (cvContactInfo.Email1.Length != 0)
            {
                contactInfo.Add("email1", cvContactInfo.Email1);
            }
            if (cvContactInfo.Email2.Length != 0)
            {
                contactInfo.Add("email2", cvContactInfo.Email2);
            }
            return(contactInfo);
        }
Ejemplo n.º 10
0
        public static List <string> GetAllCustomerVendorNameICanSee(int cvtype, int ownerId)
        {
            List <int> subIds;

            if (cvtype == 0)
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeSales());
            }
            else
            {
                subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(ownerId, UserCombine.GetUserCanBeBuyers());
            }

            var cvs = from cv in custVenEntity.custvendorinfo
                      where cv.cvtype == (sbyte)cvtype && subIds.Contains(cv.ownerName)
                      orderby cv.lastUpdateDate descending
                      select cv.cvname;

            return(cvs.ToList());
        }
Ejemplo n.º 11
0
        public override void FillTheTable(AmbleClient.RfqGui.RfqManager.Rfq rfq)
        {
            base.FillTheTable(rfq);


            tbCustomer.Text = rfq.customerName;


            this.tbContact.Text = string.Empty; this.tbContact.ReadOnly = true; //can not be seen by sales Manager
            this.tbPhone.Text   = string.Empty; this.tbPhone.ReadOnly = true;   //can not be seen by sales Manager.
            this.tbFax.Text     = string.Empty; this.tbFax.ReadOnly = true;


            //Fill the sales
            List <int> sales = new List <int>();

            sales.Add(rfq.salesId);

            cbSales.Items.Add(AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(sales)[rfq.salesId]);
            cbSales.SelectedIndex = 0;
            // cbSales.Text = (GlobalRemotingClient.GetAccountMgr().GetIdsAndNames(sales))[rfq.salesId];

            //Fill the PA
            mySubs = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeBuyers());
            Dictionary <int, string> mySubsIdAndName = AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(mySubs);

            //确认里面的buyer是不是我的下属,如果不是,不能更改。
            if (rfq.firstPA.HasValue == false || mySubs.Contains(rfq.firstPA.Value))
            {
                foreach (string name in mySubsIdAndName.Values)
                {
                    cbPrimaryPA.Items.Add(name);
                }
                if (rfq.firstPA.HasValue == false)
                {
                    cbPrimaryPA.SelectedIndex = -1;
                }
                else
                {
                    cbPrimaryPA.SelectedIndex = mySubs.IndexOf(rfq.firstPA.Value);
                }
            }
            else
            {
                List <int> buyer = new List <int>();
                buyer.Add(rfq.firstPA.Value);
                cbPrimaryPA.Items.Add(AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(buyer)[rfq.firstPA.Value]);
                cbPrimaryPA.SelectedIndex = 0;
            }
            if (rfq.secondPA.HasValue == false || mySubs.Contains(rfq.secondPA.Value))
            {
                foreach (string name in mySubsIdAndName.Values)
                {
                    cbAltPA.Items.Add(name);
                }

                if (rfq.secondPA.HasValue == false)
                {
                    cbAltPA.SelectedIndex = -1;
                }
                else
                {
                    cbAltPA.SelectedIndex = mySubs.IndexOf(rfq.secondPA.Value);
                }
            }
            else
            {
                List <int> buyer = new List <int>();
                buyer.Add(rfq.secondPA.Value);
                cbAltPA.Items.Add(AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(buyer)[rfq.secondPA.Value]);
                cbAltPA.SelectedIndex = 0;
            }

            //if rfq state is new, promp the buyer Manager to fill the first pa and second pa

            if (rfq.rfqStates == (int)RfqStatesEnum.Routed)
            {
                label23.ForeColor = System.Drawing.Color.Red;
                label24.ForeColor = System.Drawing.Color.Red;
                cbPrimaryPA.Focus();
            }
        }
Ejemplo n.º 12
0
        private void FillThePACombo()
        {
            mysubs = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeBuyers());

            buyerIdsAndNames = AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(mysubs);

            foreach (string buyerName in buyerIdsAndNames.Values)
            {
                cbPa.Items.Add(buyerName);
            }
            cbPa.SelectedIndex = 0; //0为myself
        }
Ejemplo n.º 13
0
        public static List <po> GetPoAccordingToFilter(int userId, bool includedSubs, string filterColumn, string filterString, List <int> stateList)
        {
            //get the sub;
            List <po> poList = new List <po>();

            if (stateList.Count == 0)
            {
                return(poList);
            }

            List <int> userIds = new List <int>();

            if (includedSubs)
            {
                userIds.AddRange(AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                userIds.Add(userId);
            }

            if (filterColumn.Trim().Length == 0 || filterString.Trim().Length == 0)
            {
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates))
                                   orderby poItem.poId descending
                                   select poItem;

                poList.AddRange(poListFromDb);
            }

            else if (filterColumn.Trim() == "vendorName" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates) &&
                                                                                (poItem.vendorName.Contains(filterString.Trim())))
                                   orderby poItem.poId descending
                                   select poItem;

                poList.AddRange(poListFromDb);
            }
            else if (filterColumn.Trim() == "poNo" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates) &&
                                                                                (poItem.poNo.Contains(filterString.Trim())))
                                   orderby poItem.poId descending
                                   select poItem;

                poList.AddRange(poListFromDb);
            }
            else if (filterColumn.Trim() == "mpn" && filterString.Trim().Length != 0)
            {
                var poIds = (from poExactItem in poEntity.poitems
                             where poExactItem.partNo.Contains(filterString.Trim())
                             select poExactItem.poId).Distinct();
                var poListFromDb = from poItem in poEntity.po
                                   where (userIds.Contains((int)poItem.pa)) && (stateList.Contains((int)poItem.poStates) &&
                                                                                (poIds.Contains(poItem.poId)))
                                   orderby poItem.poId descending
                                   select poItem;
                poList.AddRange(poListFromDb);
            }
            else
            {
                Logger.Info(filterColumn + "," + filterString);
            }

            return(poList);
        }
Ejemplo n.º 14
0
        public static List <PoCombine> GetPoCombineAccordingToFilter(int userId, bool includedSubs, string filterColumn, string filterString, List <int> stateList)
        {
            List <PoCombine> poCombineList = new List <PoCombine>();

            if (stateList.Count == 0)
            {
                return(poCombineList);
            }

            List <int> userIds = new List <int>();

            if (includedSubs)
            {
                userIds.AddRange(AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                userIds.Add(userId);
            }

            if (filterColumn.Trim().Length == 0 || filterString.Trim().Length == 0)
            {
                var poListFromDb = from pos in poEntity.po
                                   join poItems in poEntity.poitems
                                   on pos.poId equals poItems.poId
                                   where (userIds.Contains((int)pos.pa)) && (stateList.Contains((int)poItems.poItemState))
                                   orderby pos.poId descending
                                   select new PoCombine
                {
                    poId         = pos.poId,
                    vendorName   = pos.vendorName,
                    buyerId      = pos.pa,
                    salesAgentId = poItems.salesAgent,
                    poDate       = pos.poDate,
                    poItemsId    = poItems.poItemsId,
                    partNo       = poItems.partNo,
                    mfg          = poItems.mfg,
                    dc           = poItems.dc,
                    qty          = poItems.qty,
                    unitPrice    = poItems.unitPrice.Value,
                    poItemState  = poItems.poItemState
                };

                poCombineList.AddRange(poListFromDb);
            }

            else if (filterColumn.Trim() == "vendorName" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from pos in poEntity.po
                                   join poItems in poEntity.poitems
                                   on pos.poId equals poItems.poId
                                   where (userIds.Contains((int)pos.pa)) && (stateList.Contains((int)pos.poStates) &&
                                                                             (pos.vendorName.Contains(filterString.Trim())))
                                   orderby pos.poId descending
                                   select new PoCombine
                {
                    poId         = pos.poId,
                    vendorName   = pos.vendorName,
                    buyerId      = pos.pa,
                    salesAgentId = poItems.salesAgent,
                    poDate       = pos.poDate,
                    poItemsId    = poItems.poItemsId,
                    partNo       = poItems.partNo,
                    mfg          = poItems.mfg,
                    dc           = poItems.dc,
                    qty          = poItems.qty,
                    unitPrice    = poItems.unitPrice.Value,
                    poItemState  = poItems.poItemState
                };

                poCombineList.AddRange(poListFromDb);
            }

            else if (filterColumn.Trim() == "poNo" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from pos in poEntity.po
                                   join poItems in poEntity.poitems
                                   on pos.poId equals poItems.poId
                                   where (userIds.Contains((int)pos.pa)) && (stateList.Contains((int)pos.poStates) &&
                                                                             (pos.poNo.Contains(filterString.Trim())))
                                   orderby pos.poId descending
                                   select new PoCombine
                {
                    poId         = pos.poId,
                    vendorName   = pos.vendorName,
                    buyerId      = pos.pa,
                    salesAgentId = poItems.salesAgent,
                    poDate       = pos.poDate,
                    poItemsId    = poItems.poItemsId,
                    partNo       = poItems.partNo,
                    mfg          = poItems.mfg,
                    dc           = poItems.dc,
                    qty          = poItems.qty,
                    unitPrice    = poItems.unitPrice.Value,
                    poItemState  = poItems.poItemState
                };

                poCombineList.AddRange(poListFromDb);
            }
            else if (filterColumn.Trim() == "mpn" && filterString.Trim().Length != 0)
            {
                var poListFromDb = from pos in poEntity.po
                                   join poItems in poEntity.poitems
                                   on pos.poId equals poItems.poId
                                   where (userIds.Contains((int)pos.pa)) && (stateList.Contains((int)pos.poStates) &&
                                                                             (poItems.partNo.Contains(filterString.Trim())))
                                   orderby pos.poId descending
                                   select new PoCombine
                {
                    poId         = pos.poId,
                    vendorName   = pos.vendorName,
                    buyerId      = pos.pa,
                    salesAgentId = poItems.salesAgent,
                    poDate       = pos.poDate,
                    poItemsId    = poItems.poItemsId,
                    partNo       = poItems.partNo,
                    mfg          = poItems.mfg,
                    dc           = poItems.dc,
                    qty          = poItems.qty,
                    unitPrice    = poItems.unitPrice.Value,
                    poItemState  = poItems.poItemState
                };
                poCombineList.AddRange(poListFromDb);
            }
            else
            {
                Logger.Info(filterColumn + "," + filterString);
            }

            return(poCombineList);
        }
Ejemplo n.º 15
0
        public static DataTable BuyerGetSoItemsWithSameVendor(int userId, int soItemId)
        {
            List <int> buyersIds = new List <int>();

            buyersIds.AddRange(AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            //get vendorName
            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("select vendorName from soItems si, offer o where(si.rfqId=o.rfqNo) and si.soItemsId={0} and ( o.buyerId={1}", soItemId, buyersIds[0]));

            for (int i = 1; i < buyersIds.Count; i++)
            {
                sb.Append(string.Format(" or o.buyerId={0} ", buyersIds[i]));
            }
            sb.Append(")");

            DataTable dt = db.GetDataTable(sb.ToString(), "temp");

            if (dt.Rows.Count < 1)
            {
                return(null);
            }
            List <string> vendorNameList = new List <string>();

            foreach (DataRow dr in dt.Rows)
            {
                vendorNameList.Add(dr["vendorName"].ToString());
            }

            sb.Clear();

            sb.Append(string.Format("select soItemsId,o.mpn,o.mfg,si.dc,o.vendorName,si.qty,o.price from soItems si,offer o where(si.rfqId=o.rfqNo) and si.soItemState={0} and (o.buyerId={1}", new SoItemApprove().GetStateValue(), buyersIds[0]));
            for (int i = 1; i < buyersIds.Count; i++)
            {
                sb.Append(string.Format(" or o.buyerId={0} ", buyersIds[i]));
            }
            sb.Append(string.Format(") and (vendorName='{0}'", vendorNameList[0]));
            for (int i = 1; i < vendorNameList.Count; i++)
            {
                sb.Append(string.Format("or vendorName='{0}'", vendorNameList[i]));
            }
            sb.Append(" )");
            return(db.GetDataTable(sb.ToString(), "temp"));
        }
Ejemplo n.º 16
0
        public static List <SoCombine> BuyerGetSoCombineAccordingToFilter(int userId, bool includedSubs, string filterColumn, string filterString, List <int> states)
        {
            List <SoCombine> soCombineList = new List <SoCombine>();

            if (states.Count == 0)
            {
                return(soCombineList);
            }

            List <int> buyersIds = new List <int>();

            if (includedSubs)
            {
                buyersIds.AddRange(AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(userId, UserCombine.GetUserCanBeBuyers()));
            }
            else
            {
                buyersIds.Add(userId);
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("select s.soId,s.customerName,s.salesId,orderDate,intPartNo,customerPo,soItemsId,si.partNo,si.mfg,si.dc,si.qty,si.unitPrice,soItemState from So s,SoItems si,Rfq r where(s.soId=si.soId and si.rfqId=r.rfqNo) and ( (r.firstPA={0} or r.secondPa={0})", buyersIds[0]));
            for (int i = 1; i < buyersIds.Count; i++)
            {
                sb.Append(string.Format(" or (firstPA={0} or secondPA={0}) ", buyersIds[i]));
            }
            sb.Append(" ) ");

            //append the filter
            if ((!string.IsNullOrWhiteSpace(filterColumn)) && (!string.IsNullOrWhiteSpace(filterString)))
            {
                if (filterColumn.Trim() == "partNo" && (!string.IsNullOrWhiteSpace(filterString)))
                {
                    sb.Append(string.Format(" and si.{0} like '%{1}%' ", filterColumn, filterString));
                }
                else
                {
                    sb.Append(string.Format(" and s.{0} like '%{1}%' ", filterColumn, filterString));
                }
            }
            sb.Append(" and (soItemState=" + states[0]);
            for (int i = 1; i < states.Count; i++)
            {
                sb.Append(" or soItemState=" + states[i]);
            }
            sb.Append(" ) order by s.soId desc");

            DataTable dt = db.GetDataTable(sb.ToString(), "soId");

            foreach (DataRow dr in dt.Rows)
            {
                soCombineList.Add(
                    new SoCombine
                {
                    soId         = Convert.ToInt32(dr["soId"]),
                    customerName = dr["customerName"].ToString(),
                    salesId      = Convert.ToInt32(dr["salesId"]),
                    orderDate    = Convert.ToDateTime(dr["orderDate"]),
                    customerPo   = dr["customerPo"].ToString(),
                    soItemsId    = Convert.ToInt32(dr["soItemsId"]),
                    partNo       = dr["partNo"].ToString(),
                    mfg          = dr["mfg"].ToString(),
                    dc           = dr["dc"].ToString(),
                    qty          = Convert.ToInt32(dr["qty"]),
                    cpn          = dr["intPartNo"].ToString(),
                    unitPrice    = Convert.ToSingle(dr["unitPrice"]),
                    soItemState  = Convert.ToInt32(dr["soItemState"])
                }
                    );
            }
            return(soCombineList);
        }