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
 public AmbleStock()
 {
     InitializeComponent();
     if (!UserCombine.GetuserCanBeLogistics().Contains((int)UserInfo.Job))
     {
         tsbImport.Enabled = false;
         tsbAdd.Enabled    = false;
         tsbDelete.Enabled = false;
     }
 }
Ejemplo n.º 4
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.º 5
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.º 6
0
        private void FillTheSalesComboBox()
        {
            AmbleClient.Admin.AccountMgr.AccountMgr accMgr = new Admin.AccountMgr.AccountMgr();

            mySubs = accMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeSales());

            Dictionary <int, string> mySubsIdAndName = accMgr.GetIdsAndNames(mySubs);

            foreach (string name in mySubsIdAndName.Values)
            {
                cbSp.Items.Add(name);
            }
        }
Ejemplo n.º 7
0
        public SoItemsControl()
        {
            InitializeComponent();

            this.cbCurrency.Items.AddRange(
                Enum.GetNames(typeof(Currency))
                );
            if (!UserCombine.GetUserCanBeFinance().Contains((int)UserInfo.Job) && !UserCombine.GetuserCanBeLogistics().Contains((int)UserInfo.Job))
            {
                tbTrackingNo.ReadOnly = true;
                tbQtyShipped.ReadOnly = true;
            }
        }
Ejemplo n.º 8
0
        public void NewRfqFill()
        {
            this.tbCustomer.Leave += new System.EventHandler(this.tbCustomer_Leave);


            cbCloseReason.Enabled = false;
            tbRfqDate.ReadOnly    = true; tbRfqDate.Enabled = false;
            //clear all the necessary textbox

            tbCustomer.Clear();
            //customer auto complete
            CustomerAutoComplete();
            tbProject.Clear();
            tbContact.Clear();
            tbPhone.Clear();
            tbFax.Clear();
            tbEmail.Clear();
            cbPriority.SelectedIndex = -1;
            cbRohs.Checked           = false;
            tbPartNo.Clear();
            tbMfg.Clear();
            tbDc.Clear();
            tbCustPartNo.Clear();
            tbGenPartNo.Clear();
            tbAlt.Clear();
            tbQuantity.Clear();
            tbPartNo.Clear();
            tbTargetPrice.Clear();
            tbResale.Clear();
            tbCost.Clear();
            cbPrimaryPA.Text            = "";
            cbAltPA.Text                = "";
            cbCloseReason.SelectedIndex = -1;
            tbToCustomer.Clear();
            tbToInternal.Clear();
            tbRoutingHistory.Clear();


            //Fill the cbSale;
            //获得下级号和名字
            AmbleClient.Admin.AccountMgr.AccountMgr accountMgr = new Admin.AccountMgr.AccountMgr();
            mySubs = accountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeSales());

            Dictionary <int, string> mySubsIdAndName = accountMgr.GetIdsAndNames(mySubs);

            foreach (string name in mySubsIdAndName.Values)
            {
                cbSales.Items.Add(name);
            }
            cbSales.SelectedIndex = 0;
        }
Ejemplo n.º 9
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.º 10
0
        //for sale and salesManager
        public DataTable GetICanSeeRfqDataTableAccordingToPageNumber(int salesId, int pageNumber, int itemsPerPage, string filterColumn, string filterString, List <RfqStatesEnum> selections)
        {
            if (selections.Count == 0)
            {
                return(null);
            }

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

            List <int> subIds = accountMgr.GetAllSubsId(salesId, UserCombine.GetUserCanBeSales());

            StringBuilder sb = new StringBuilder();

            if ((!string.IsNullOrEmpty(filterColumn)) && (!(string.IsNullOrEmpty(filterString))))
            {
                if (filterColumn == "rfqDate")
                {
                    string[] date = GetStartDateAndEndDate(filterString);

                    sb.Append(string.Format("select * from rfq where {0} between '{1}' and '{2}' and ( salesId={3} ", filterColumn, date[0], date[1], subIds[0]));
                }
                else
                {
                    sb.Append(string.Format("select * from rfq where {0} like '%{1}%' and ( salesId={2}", filterColumn, filterString, subIds[0]));
                }
            }
            else
            {
                sb.Append("select * from rfq where ( salesId=" + subIds[0]);
            }

            if (subIds.Count() > 1)
            {
                for (int i = 1; i < subIds.Count(); i++)
                {
                    sb.Append(" or salesId=" + subIds[i]);
                }
            }
            sb.Append(" )");
            sb.Append(" and (rfqstates=" + selections[0].GetHashCode());
            for (int i = 1; i < selections.Count; i++)
            {
                sb.Append(" or rfqstates=" + selections[i].GetHashCode());
            }

            sb.Append(string.Format(")  limit {0},{1}", pageNumber * itemsPerPage, itemsPerPage));

            return(db.GetDataTable(sb.ToString(), "Table" + pageNumber));
        }
Ejemplo n.º 11
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.º 12
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!UserCombine.GetuserCanBeLogistics().Contains((int)UserInfo.Job))
            {
                return;
            }

            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                if (e.RowIndex > dataGridView1.RowCount - 1)
                {
                    return;
                }

                //get the real index.
                int stockId = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);

                AmbleClient.AmbleStock.stockDataSet.amblestockRow selectedRow = null;

                foreach (AmbleClient.AmbleStock.stockDataSet.amblestockRow row in this.stockDataSet1.amblestock.Rows)
                {
                    if (row.stockId == stockId)
                    {
                        selectedRow = row;
                        break;
                    }
                }
                if (selectedRow != null)
                {
                    StockOp op = new StockOp(false);
                    op.FillTheTable(selectedRow);
                    if (DialogResult.OK == op.ShowDialog())
                    {
                        Stock_Load(this, null);
                    }
                }
            }
            RestoreSelectedRow();
        }
Ejemplo n.º 13
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.º 14
0
        public static DataTable GetRfqForSo(string customerName, int saleId)
        {
            List <int> subIds = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(saleId, UserCombine.GetUserCanBeSales());

            StringBuilder sb = new StringBuilder();

            sb.Append(string.Format("select * from rfq where customerName ='{0}' and (salesId={1} ", customerName, saleId));
            if (subIds.Count() > 1)
            {
                for (int i = 1; i < subIds.Count(); i++)
                {
                    sb.Append(" or salesId=" + subIds[i]);
                }
            }
            sb.Append(" )  ");
            sb.Append(string.Format(" and rfqStates={0}", (int)RfqStatesEnum.Quoted));
            return(db.GetDataTable(sb.ToString(), "temp"));
        }
Ejemplo n.º 15
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.º 16
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.º 17
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.º 18
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.º 19
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.º 20
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.º 21
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.º 22
0
        public static List <SoCombine> SalesGetSoCombineAccordingTofilter(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> salesIds = new List <int>();

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

            StringBuilder sb = new StringBuilder();

            sb.Append("select s.soId,customerName,salesId,orderDate,customerPo,soItemsId,partNo,mfg,dc,intPartNo,qty,unitPrice,soItemState from So s,SoItems si where(s.soId=si.soId) and  ( salesId=" + salesIds[0]);
            for (int i = 1; i < salesIds.Count; i++)
            {
                sb.Append(" or salesId=" + salesIds[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 (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);
        }
Ejemplo n.º 23
0
        private void GenerateGui()
        {
            So so = soList[tabControl1.SelectedIndex];

            //for view Po
            if (Order.PoMgr.PoMgr.GetPoNumberAccordingToSoId(soList[tabControl1.SelectedIndex].soId) <= 0)
            {
                tsbViewPo.Enabled = false;
            }
            else
            {
                tsbViewPo.Enabled = true;
            }

            //for approve and rejected.
            if (so.soStates == (int)SoStatesEnum.New)
            {
                tsbApprove.Enabled = true;
                tsbReject.Enabled  = true;
            }
            else
            {
                tsbApprove.Enabled = false;
                tsbReject.Enabled  = false;
            }
            //for cancel

            if (so.soStates == (int)SoStatesEnum.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 (so.soStates != (int)SoStatesEnum.New && UserCombine.GetUserCanBeSalesManager().Contains((int)UserInfo.Job))
            {
                tsbUpdate.Enabled = true;
            }
            else if (so.soStates == (int)SoStatesEnum.New && UserCombine.GetUserCanBeSales().Contains((int)UserInfo.Job))
            {
                tsbUpdate.Enabled = true;
            }
            else
            {
                tsbUpdate.Enabled = false;
            }

            if (!UserCombine.GetUserCanBeSalesManager().Contains((int)UserInfo.Job))
            {
                tsbApprove.Enabled    = false;
                tsbReject.Enabled     = false;
                tsbForceClose.Enabled = false;
                tsbCancel.Enabled     = false;
            }
        }
Ejemplo n.º 24
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.º 25
0
        public override void FillTheTable(Rfq rfq)
        {
            base.FillTheTable(rfq);

            //Fill the salesId
            tbCustomer.Text = rfq.customerName;
            //select the sales ID
            //获得下级号和名字

            mySubs = AmbleClient.Admin.AccountMgr.AccountMgr.GetAllSubsId(UserInfo.UserId, UserCombine.GetUserCanBeSales());

            Dictionary <int, string> mySubsIdAndName = AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(mySubs);

            foreach (string name in mySubsIdAndName.Values)
            {
                cbSales.Items.Add(name);
            }
            for (int i = 0; i < mySubs.Count; i++)
            {
                if (mySubs[i] == rfq.salesId)
                {
                    cbSales.SelectedIndex = i;
                    break;
                }
            }

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

            //Fill the PA
            if (rfq.firstPA.HasValue)
            {
                pAList.Add(rfq.firstPA.Value);
            }
            if (rfq.secondPA.HasValue)
            {
                pAList.Add(rfq.secondPA.Value);
            }

            if (pAList.Count > 0)
            {
                Dictionary <int, string> paIDAndName = AmbleClient.Admin.AccountMgr.AccountMgr.GetIdsAndNames(pAList);

                if (rfq.firstPA.HasValue && rfq.secondPA.HasValue)
                {
                    cbPrimaryPA.Text = paIDAndName[rfq.firstPA.Value];
                    cbAltPA.Text     = paIDAndName[rfq.secondPA.Value];
                }
                else if (rfq.firstPA.HasValue)
                {
                    cbPrimaryPA.Text = paIDAndName[rfq.firstPA.Value];
                }
                else if (rfq.secondPA.HasValue)
                {
                    cbAltPA.Text = paIDAndName[rfq.secondPA.Value];
                }
                else
                {
                    //error
                }
            }
        }
Ejemplo n.º 26
0
        public static List <So> SalesGetSoAccordingTofilter(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> salesIds = new List <int>();

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

            StringBuilder sb = new StringBuilder();

            sb.Append("select soId from So where ( salesId=" + salesIds[0]);
            for (int i = 1; i < salesIds.Count; i++)
            {
                sb.Append(" or salesId=" + salesIds[i]);
            }
            sb.Append(" ) ");

            if (filterColumn.Trim() == "partNo" && (!string.IsNullOrWhiteSpace(filterString)))
            {
                List <int> idsList = GetSoIdByMPN(filterString.Trim());
                if (idsList.Count >= 1)
                {
                    sb.Append(" and (soId=" + idsList[0]);

                    for (int i = 1; i < idsList.Count; i++)
                    {
                        sb.Append(" or soId=" + idsList[i]);
                    }
                    sb.Append(" ) ");
                }
                else
                {
                    return(soList);
                }
            }
            else
            {
                //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(" ) order by soId desc ");

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

            foreach (DataRow dr in dt.Rows)
            {
                soList.Add(GetSoAccordingToSoId(Convert.ToInt32(dr["soId"])));
            }
            return(soList);
        }