Пример #1
0
        public override void FillTheTable(Rfq rfq)
        {
            base.FillTheTable(rfq);

               //Fill the salesId
               tbCustomer.Text = rfq.customerName;
               //select the sales ID
               //获得下级号和名字
               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);

               }
               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 = 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
              }

              }
        }
Пример #2
0
        public bool UpdateRfq(Rfq rfq)
        {
            string strSql = string.Format("update rfq set customerName='{0}',partNo='{1}',salesId={2},contact='{3}',project='{4}',rohs={5},phone='{6}',fax='{7}',email='{8}',rfqdate='{9}',priority={10},dockdate='{11}',mfg='{12}',dc='{13}',custPartNo='{14}',genPartNo='{15}',alt='{16}',qty={17},packaging='{18}',targetPrice={19},resale={20},firstPA={21},secondPA={22} where rfqNo={23}",
                                          rfq.customerName, rfq.partNo, rfq.salesId, rfq.contact, rfq.project, rfq.rohs, rfq.phone, rfq.fax, rfq.email, rfq.rfqdate.Date.ToShortDateString(),
                                          rfq.priority.HasValue?rfq.priority.Value.ToString():"null", rfq.dockdate.Date.ToShortDateString(), rfq.mfg, rfq.dc, rfq.custPartNo, rfq.genPartNo, rfq.alt, rfq.qty, rfq.packaging,
                                          rfq.targetPrice.HasValue?rfq.targetPrice.Value.ToString():"null",
                                          rfq.resale.HasValue?rfq.resale.Value.ToString():"null",
                                          rfq.firstPA.HasValue?rfq.firstPA.Value.ToString():"null",
                                          rfq.secondPA.HasValue?rfq.secondPA.Value.ToString():"null", rfq.rfqNo);

            int row = db.ExecDataBySql(strSql);

            if (row == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public static bool SaveRfq(Rfq rfq)
        {
            string strSql = string.Format("insert into rfq(customerName,partNo,salesId,contact,project,rohs,phone,fax,email,rfqdate,priority,dockdate,mfg,dc,custPartNo,genPartNo,alt,qty,packaging,targetPrice,resale,cost,firstPA,secondPA,rfqStates,infoToCustomer,infoToInternal,routingHistory) "
                                          + " values('{0}','{1}',{2},'{3}','{4}',{5},'{6}','{7}','{8}','{9}',{10},'{11}','{12}','{13}','{14}','{15}','{16}',{17},'{18}',{19},{20},{21},{22},{23},{24},'{25}','{26}','{27}')",
                                          rfq.customerName, rfq.partNo, rfq.salesId, rfq.contact, rfq.project, rfq.rohs, rfq.phone, rfq.fax, rfq.email, rfq.rfqdate.Date.ToShortDateString(),
                                          rfq.priority.HasValue?rfq.priority.Value.ToString():"null", rfq.dockdate.Date.ToShortDateString(), rfq.mfg, rfq.dc, rfq.custPartNo, rfq.genPartNo, rfq.alt,
                                          rfq.qty.HasValue?rfq.qty.Value.ToString():"null", rfq.packaging, rfq.targetPrice.HasValue?rfq.targetPrice.Value.ToString():"null",
                                          rfq.resale.HasValue?rfq.resale.Value.ToString():"null", rfq.cost.HasValue?rfq.cost.Value.ToString():"null",
                                          rfq.firstPA.HasValue?rfq.firstPA.Value.ToString():"null", rfq.secondPA.HasValue?rfq.secondPA.Value.ToString():"null", rfq.rfqStates, rfq.infoToCustomer, rfq.infoToInternal, rfq.routingHistory
                                          );

            int row = db.ExecDataBySql(strSql);

            if (row == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        public static bool UpdateRfq(Rfq rfq)
        {
            string strSql=string.Format("update rfq set customerName='{0}',partNo='{1}',salesId={2},contact='{3}',project='{4}',rohs={5},phone='{6}',fax='{7}',email='{8}',priority={9},dockdate='{10}',mfg='{11}',dc='{12}',custPartNo='{13}',genPartNo='{14}',alt='{15}',qty={16},packaging='{17}',targetPrice={18},resale={19},firstPA={20},secondPA={21},closeReason={22} where rfqNo={23}",
             rfq.customerName,rfq.partNo,rfq.salesId,rfq.contact,rfq.project,rfq.rohs,rfq.phone,rfq.fax,rfq.email,
             rfq.priority.HasValue?rfq.priority.Value.ToString():"null",rfq.dockdate.Date.ToShortDateString(),rfq.mfg,rfq.dc,rfq.custPartNo,rfq.genPartNo,rfq.alt,rfq.qty,rfq.packaging,
             rfq.targetPrice.HasValue?rfq.targetPrice.Value.ToString():"null",
             rfq.resale.HasValue?rfq.resale.Value.ToString():"null",
             rfq.firstPA.HasValue?rfq.firstPA.Value.ToString():"null",
             rfq.secondPA.HasValue?rfq.secondPA.Value.ToString():"null",
             rfq.closeReason.HasValue?rfq.closeReason.Value.ToString():"null",
             rfq.rfqNo);

               int row=db.ExecDataBySql(strSql);
            if(row==1)
                return true;
            else
            return false;
        }
Пример #5
0
        public static bool SaveRfq(Rfq rfq)
        {
            string strSql=string.Format("insert into rfq(customerName,partNo,salesId,contact,project,rohs,phone,fax,email,rfqdate,priority,dockdate,mfg,dc,custPartNo,genPartNo,alt,qty,packaging,targetPrice,resale,cost,firstPA,secondPA,rfqStates,infoToCustomer,infoToInternal,routingHistory) "
            +" values('{0}','{1}',{2},'{3}','{4}',{5},'{6}','{7}','{8}','{9}',{10},'{11}','{12}','{13}','{14}','{15}','{16}',{17},'{18}',{19},{20},{21},{22},{23},{24},'{25}','{26}','{27}')",
            rfq.customerName,rfq.partNo,rfq.salesId,rfq.contact,rfq.project,rfq.rohs,rfq.phone,rfq.fax,rfq.email,rfq.rfqdate.Date.ToShortDateString(),
            rfq.priority.HasValue?rfq.priority.Value.ToString():"null",rfq.dockdate.Date.ToShortDateString(),rfq.mfg,rfq.dc,rfq.custPartNo,rfq.genPartNo,rfq.alt,
            rfq.qty.HasValue?rfq.qty.Value.ToString():"null",rfq.packaging,rfq.targetPrice.HasValue?rfq.targetPrice.Value.ToString():"null",
            rfq.resale.HasValue?rfq.resale.Value.ToString():"null",rfq.cost.HasValue?rfq.cost.Value.ToString():"null",
            rfq.firstPA.HasValue?rfq.firstPA.Value.ToString():"null",rfq.secondPA.HasValue?rfq.secondPA.Value.ToString():"null",rfq.rfqStates,rfq.infoToCustomer,rfq.infoToInternal,rfq.routingHistory
            );

            int row=db.ExecDataBySql(strSql);
            if(row==1)
                return true;
            else
            return false;
        }
Пример #6
0
        public static Rfq GetRfqAccordingToRfqId(int rfqId)
        {
            string strSql = string.Format("select * from rfq where rfqNo={0}", rfqId);
               DataTable dt = db.GetDataTable(strSql, "tempTable");

               if (dt.Rows.Count == 0) return null;

               DataRow dr = dt.Rows[0];
               Rfq rfq = new Rfq();

               rfq.customerName=dr["customerName"].ToString();
               rfq.partNo=dr["partNo"].ToString();
               rfq.salesId=Convert.ToInt32(dr["salesId"]);
               rfq.contact=dr["contact"].ToString();
               rfq.project=dr["project"].ToString();
               rfq.rohs=Convert.ToInt32(dr["rohs"]);
               rfq.phone=dr["phone"].ToString();
               rfq.fax=dr["fax"].ToString();
               rfq.email=dr["email"].ToString();
               rfq.rfqdate=Convert.ToDateTime(dr["rfqdate"]);
               if(dr["priority"]==DBNull.Value)
               {
               rfq.priority=null;
               }
               else
               {
            rfq.priority=Convert.ToInt32(dr["priority"]);
               }
               rfq.dockdate=Convert.ToDateTime(dr["dockdate"]);
               rfq.mfg=dr["mfg"].ToString();
               rfq.dc=dr["dc"].ToString();
               rfq.custPartNo=dr["custPartNo"].ToString();
               rfq.genPartNo=dr["genPartNo"].ToString();
               rfq.alt=dr["alt"].ToString();
               if(dr["qty"]==DBNull.Value)
               rfq.qty=null;
               else
               rfq.qty=Convert.ToInt32(dr["qty"]);

               rfq.packaging=dr["packaging"].ToString();

               if(dr["targetPrice"]==DBNull.Value)
               rfq.targetPrice=null;
               else
               rfq.targetPrice=Convert.ToSingle(dr["targetPrice"]);

            if(dr["cost"]==DBNull.Value)
               rfq.cost=null;
               else
               rfq.cost=Convert.ToSingle(dr["cost"]);

            if(dr["resale"]==DBNull.Value)
               rfq.resale=null;
               else
               rfq.resale=Convert.ToSingle(dr["resale"]);

            if(dr["firstPA"]==DBNull.Value)
               rfq.firstPA=null;
               else
               rfq.firstPA=Convert.ToInt32(dr["firstPA"]);
            if(dr["secondPA"]==DBNull.Value)
               rfq.secondPA=null;
               else
               rfq.secondPA=Convert.ToInt32(dr["secondPA"]);

               rfq.rfqStates=Convert.ToInt32(dr["rfqStates"]);
               rfq.infoToCustomer=dr["infoToCustomer"].ToString();
               rfq.infoToInternal=dr["infoToInternal"].ToString();
               rfq.routingHistory=dr["routingHistory"].ToString();

               if (dr["closeReason"] == DBNull.Value)
               rfq.closeReason = null;
               else
               rfq.closeReason = Convert.ToInt32(dr["closeReason"]);

               return rfq;
        }
Пример #7
0
 private void RFQView_Load(object sender, EventArgs e)
 {
     rfq = RfqMgr.GetRfqAccordingToRfqId(rfqId);
     rfqItems1.FillTheTable(rfq);
     GuiOpAccordingToRfqState((RfqStatesEnum)rfq.rfqStates);
 }
Пример #8
0
        public bool UpdateInfo(int rfqId)
        {
            Rfq rfq = new Rfq();
               GetValuesFromGui(rfq);
               rfq.rfqNo = rfqId;
               rfq.salesId = mySubs[cbSales.SelectedIndex];
               bool suc;

               try
               {
               suc = rfqMgr.UpdateRfq(rfq);
               }
               catch (Exception ex)
               {
               suc = false;
               Logger.Error(ex.Message);
               Logger.Error(ex.StackTrace);
               }
               return suc;
        }
Пример #9
0
        public static Rfq GetRfqAccordingToRfqId(int rfqId)
        {
            string    strSql = string.Format("select * from rfq where rfqNo={0}", rfqId);
            DataTable dt     = db.GetDataTable(strSql, "tempTable");

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            DataRow dr  = dt.Rows[0];
            Rfq     rfq = new Rfq();

            rfq.customerName = dr["customerName"].ToString();
            rfq.partNo       = dr["partNo"].ToString();
            rfq.salesId      = Convert.ToInt32(dr["salesId"]);
            rfq.contact      = dr["contact"].ToString();
            rfq.project      = dr["project"].ToString();
            rfq.rohs         = Convert.ToInt32(dr["rohs"]);
            rfq.phone        = dr["phone"].ToString();
            rfq.fax          = dr["fax"].ToString();
            rfq.email        = dr["email"].ToString();
            rfq.rfqdate      = Convert.ToDateTime(dr["rfqdate"]);
            if (dr["priority"] == DBNull.Value)
            {
                rfq.priority = null;
            }
            else
            {
                rfq.priority = Convert.ToInt32(dr["priority"]);
            }
            rfq.dockdate   = Convert.ToDateTime(dr["dockdate"]);
            rfq.mfg        = dr["mfg"].ToString();
            rfq.dc         = dr["dc"].ToString();
            rfq.custPartNo = dr["custPartNo"].ToString();
            rfq.genPartNo  = dr["genPartNo"].ToString();
            rfq.alt        = dr["alt"].ToString();
            if (dr["qty"] == DBNull.Value)
            {
                rfq.qty = null;
            }
            else
            {
                rfq.qty = Convert.ToInt32(dr["qty"]);
            }

            rfq.packaging = dr["packaging"].ToString();

            if (dr["targetPrice"] == DBNull.Value)
            {
                rfq.targetPrice = null;
            }
            else
            {
                rfq.targetPrice = Convert.ToSingle(dr["targetPrice"]);
            }

            if (dr["cost"] == DBNull.Value)
            {
                rfq.cost = null;
            }
            else
            {
                rfq.cost = Convert.ToSingle(dr["cost"]);
            }

            if (dr["resale"] == DBNull.Value)
            {
                rfq.resale = null;
            }
            else
            {
                rfq.resale = Convert.ToSingle(dr["resale"]);
            }

            if (dr["firstPA"] == DBNull.Value)
            {
                rfq.firstPA = null;
            }
            else
            {
                rfq.firstPA = Convert.ToInt32(dr["firstPA"]);
            }
            if (dr["secondPA"] == DBNull.Value)
            {
                rfq.secondPA = null;
            }
            else
            {
                rfq.secondPA = Convert.ToInt32(dr["secondPA"]);
            }

            rfq.rfqStates      = Convert.ToInt32(dr["rfqStates"]);
            rfq.infoToCustomer = dr["infoToCustomer"].ToString();
            rfq.infoToInternal = dr["infoToInternal"].ToString();
            rfq.routingHistory = dr["routingHistory"].ToString();

            if (dr["closeReason"] == DBNull.Value)
            {
                rfq.closeReason = null;
            }
            else
            {
                rfq.closeReason = Convert.ToInt32(dr["closeReason"]);
            }

            return(rfq);
        }
Пример #10
0
        protected void GetValuesFromGui(Rfq rfq)
        {
            rfq.customerName = tbCustomer.Text.Trim();

            rfq.project = tbProject.Text.Trim();
            rfq.contact = tbContact.Text.Trim();
            rfq.phone = tbPhone.Text.Trim();
            rfq.fax = tbFax.Text.Trim();
            rfq.email = tbEmail.Text.Trim();
            //priority
            if (cbPriority.SelectedIndex == -1)
            {
                rfq.priority = null;
            }
            else
            {
                rfq.priority = cbPriority.SelectedIndex;
            }
            if (cbRohs.Checked)
            {
                rfq.rohs = 1;
            }
            else
            {
                rfq.rohs = 0;
            }
            rfq.rfqdate = DateTime.Now.Date;
            rfq.dockdate = dateTimePicker1.Value.Date;
            rfq.partNo = tbPartNo.Text.Trim();
            rfq.mfg = tbMfg.Text.Trim();
            rfq.dc = tbDc.Text.Trim();
            rfq.custPartNo = tbCustPartNo.Text.Trim();
            rfq.genPartNo = tbGenPartNo.Text.Trim();
            rfq.alt = tbAlt.Text.Trim();
            if (string.IsNullOrWhiteSpace(tbQuantity.Text.Trim()))
            {
                rfq.qty = null;
            }
            else
            {
                rfq.qty = int.Parse(tbQuantity.Text.Trim());//checked if non-number value in checkItems();
            }
            rfq.packaging = tbPackaging.Text.Trim();

            if (string.IsNullOrWhiteSpace(tbTargetPrice.Text.Trim()))
            {
                rfq.targetPrice = null;
            }
            else
            {
                rfq.targetPrice = float.Parse(tbTargetPrice.Text.Trim()); //checked  in checkitems()
            }

            if (string.IsNullOrWhiteSpace(tbResale.Text.Trim()))
            {
                rfq.resale = null;
            }
            else
            {
                rfq.resale = float.Parse(tbResale.Text.Trim());

            }

            if (string.IsNullOrWhiteSpace(tbCost.Text.Trim()))
            {
                rfq.cost = null;
            }
            else
            {
                rfq.cost = float.Parse(tbCost.Text.Trim());
            }
            rfq.infoToCustomer = tbToCustomer.Text;
            rfq.infoToInternal = tbToInternal.Text;

            if (cbCloseReason.SelectedIndex == -1)
            {
                rfq.closeReason = null;

            }
            else
            {
                rfq.closeReason = cbCloseReason.SelectedIndex;
            }
        }
Пример #11
0
 public virtual void FillTheTable(Rfq rfq)
 {
     tbProject.Text = rfq.project;
     tbContact.Text = rfq.contact;
     tbPhone.Text = rfq.phone;
     tbFax.Text = rfq.fax;
     tbEmail.Text = rfq.email;
     cbPriority.SelectedIndex = (rfq.priority.HasValue ? rfq.priority.Value : -1);
     cbRohs.Checked = (rfq.rohs == 1 ? true : false);
     tbRfqDate.Text = rfq.rfqdate.ToShortDateString();
     dateTimePicker1.Value = rfq.dockdate;
     tbPartNo.Text = rfq.partNo;
     tbMfg.Text = rfq.mfg;
     tbDc.Text = rfq.dc;
     tbCustPartNo.Text = rfq.custPartNo;
     tbGenPartNo.Text = rfq.genPartNo;
     tbAlt.Text = rfq.alt;
     tbQuantity.Text = rfq.qty.ToString();
     tbPackaging.Text = rfq.packaging.ToString();
     tbTargetPrice.Text = rfq.targetPrice.ToString();
     tbResale.Text = rfq.resale.ToString();
     tbCost.Text = rfq.cost.ToString();
        // tbPrimaryPA.Text = rfq.firstPA.ToString();
     //tbAltPA.Text = rfq.secondPA.ToString();
     cbCloseReason.SelectedIndex = (rfq.closeReason.HasValue ? rfq.closeReason.Value : -1);
     tbToCustomer.Text = rfq.infoToCustomer;
     tbToInternal.Text = rfq.infoToInternal;
     tbRoutingHistory.Text = rfq.routingHistory;
 }
Пример #12
0
        public bool SaveInfo()
        {
            if (base.CheckItems() == false)
            {
                return false;
            }

            Rfq rfq=new Rfq();
            GetValuesFromGui(rfq);
            rfq.closeReason = null;
            rfq.salesId = mySubs[cbSales.SelectedIndex];

            bool suc;
            try
            {
                suc = rfqMgr.SaveRfq(rfq);

                if (UserInfo.UserId == rfq.salesId)
                    rfq.routingHistory = DateTime.Now.ToString() + ":" + UserInfo.UserName.ToString() + "  Created the RFQ" + System.Environment.NewLine;
                else
                    rfq.routingHistory = DateTime.Now.ToString() + ":" + UserInfo.UserName.ToString() + " Created the RFQ for " + new AmbleClient.Admin.AccountMgr.AccountMgr().GetNameById(rfq.salesId) + System.Environment.NewLine;
            }
            catch (Exception ex)
            {
                suc = false;
                Logger.Error(ex.Message);

                Logger.Error(ex.StackTrace);

            }

            return suc;
        }
Пример #13
0
 public override void FillTheTable(Rfq rfq)
 {
     base.FillTheTable(rfq);
     base.tbCustomer.Text = rfq.customerName;
 }
Пример #14
0
 private void BuyerManagerRfqView_Load(object sender, EventArgs e)
 {
     rfq = RfqMgr.GetRfqAccordingToRfqId(rfqId);
     buyerManagerRfqItems1.FillTheTable(rfq);
     SetMenuStateAccordingToRfqState((RfqStatesEnum)rfq.rfqStates);
 }
Пример #15
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();
            }
        }