Ejemplo n.º 1
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.º 2
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.º 3
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)
            {
                var accountMgr = new AmbleClient.Admin.AccountMgr.AccountMgr();
                salesIds.AddRange(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(" ) ");

            //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.º 4
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.º 5
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.º 6
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.º 7
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.º 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 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);
        }