Ejemplo n.º 1
0
 public void addPurOrderChildTest1()
 {
     CommodityImpl_Accessor target = new CommodityImpl_Accessor(); // TODO: Initialize to an appropriate value
     PurchaseChild purchaseChild = new PurchaseChild(); // TODO: Initialize to an appropriate value
     purchaseChild.PurParentId = "PO_ID_20101206_002";
     purchaseChild.DetailId = 1;
     purchaseChild.PurKBN = 1;
     purchaseChild.CommId = "Comd_ID_00006";
     purchaseChild.Amount = 10;
     purchaseChild.UnitPrice = 2.5f;
     purchaseChild.TotlePrice = 25f;
     purchaseChild.Remark = "备注";
     target.addPurOrderChild(purchaseChild);
 }
Ejemplo n.º 2
0
        public int AddPurchaseChild(PurchaseChild purchaseChild, string currentUser)
        {
            string sqlStr = dbUtil.getSqlStatement("SQL_Comd_PurchaseChild_Insert");

            SqlParameter[] sqlParms = {
                new SqlParameter("@PurchaseOrderID",SqlDbType.VarChar,20),
                new SqlParameter("@PurchaseOrderDetailID",SqlDbType.Int),
                new SqlParameter("@PurchaseKBN",SqlDbType.Int),
                new SqlParameter("@ComdID",SqlDbType.VarChar,20),
                new SqlParameter("@amount",SqlDbType.Int),
                new SqlParameter("@PriceUnit",SqlDbType.Float),
                new SqlParameter("@PriceTotal",SqlDbType.Float),
                new SqlParameter("@Remark",SqlDbType.NVarChar,800),
                new SqlParameter("@CreateUser",SqlDbType.VarChar,20),
                new SqlParameter("@UpdateUser",SqlDbType.VarChar,20)
            };

            sqlParms[0].Value = purchaseChild.PurParentId;
            sqlParms[1].Value = purchaseChild.DetailId;
            sqlParms[2].Value = purchaseChild.PurKBN;
            sqlParms[3].Value = purchaseChild.CommId;
            sqlParms[4].Value = purchaseChild.Amount;
            sqlParms[5].Value = purchaseChild.UnitPrice;
            sqlParms[6].Value = purchaseChild.TotlePrice;
            sqlParms[7].Value = purchaseChild.Remark;
            sqlParms[8].Value = currentUser;
            sqlParms[9].Value = currentUser;

            int resultCount = 0;
            try
            {
                resultCount = (int)DAO.DBAccess.ExecuteNonQuery(DAO.DBAccess.SQLConnectionString, CommandType.Text, sqlStr, sqlParms);
            }
            catch (Exception ex)
            {
                throw new DAOException("E0001");
            }
            return resultCount;
        }
Ejemplo n.º 3
0
        public void addPurOrderTest()
        {
            CommodityImpl_Accessor target = new CommodityImpl_Accessor(); // TODO: Initialize to an appropriate value
            PurchaseParent purchaseParent = new PurchaseParent(); // TODO: 初始化为适当的值
            purchaseParent.OrderId = "";
            purchaseParent.Supplier = "北京中关村明基代理";
            purchaseParent.PurchaseEmpId = "EMP_ID_001";
            purchaseParent.PurchaseDate = DateTime.Parse("2010-12-6");
            purchaseParent.StatusKBN = 2;
            purchaseParent.ReceivingFLG = false;
            purchaseParent.PaymentFLG = false;
            purchaseParent.Remark = "分期付款";

            List<PurchaseChild> purchaseChildList = new List<PurchaseChild>(); // TODO: Initialize to an appropriate value

            PurchaseChild purchaseChild = new PurchaseChild(); // TODO: Initialize to an appropriate value
            purchaseChild.PurParentId = "";
            purchaseChild.DetailId = 0;
            purchaseChild.PurKBN = 1;
            purchaseChild.CommId = "Comd_ID_00006";
            purchaseChild.Amount = 10;
            purchaseChild.UnitPrice = 2.5f;
            purchaseChild.TotlePrice = 25f;
            purchaseChild.Remark = "备注";

            purchaseChildList.Add(purchaseChild);

            purchaseChild = new PurchaseChild(); // TODO: Initialize to an appropriate value
            purchaseChild.PurParentId = "";
            purchaseChild.DetailId = 0;
            purchaseChild.PurKBN = 1;
            purchaseChild.CommId = "Comd_ID_00006";
            purchaseChild.Amount = 10;
            purchaseChild.UnitPrice = 2.5f;
            purchaseChild.TotlePrice = 25f;
            purchaseChild.Remark = "备注";

            purchaseChildList.Add(purchaseChild);

            string actual = target.addOrUpdatePurOrder(purchaseParent, purchaseChildList);
            Assert.AreEqual("PO_ID_20101208_00001", actual);
        }
Ejemplo n.º 4
0
        public List<PurchaseChild> SearchPurchaseChildByOrderID(string strPurchaseOrderID)
        {
            List<PurchaseChild> purchaseChildList = new List<PurchaseChild>();

            string sqlStr = dbUtil.getSqlStatement("SQL_Comd_PurchaseChild_SearchByOrderID");
            SqlParameter[] sqlParms = {
                new SqlParameter("@PurchaseOrderID",SqlDbType.VarChar,20)
            };
            sqlParms[0].Value = strPurchaseOrderID;

            DataSet searchResult = null;
            try
            {
                searchResult = DAO.DBAccess.ExecuteAdapter(DAO.DBAccess.SQLConnectionString, CommandType.Text, sqlStr, sqlParms);
                foreach (DataTable dt in searchResult.Tables)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        PurchaseChild purchaseChild = new PurchaseChild();

                        purchaseChild.PurParentId = dr["PurchaseOrderID"].ToString();
                        purchaseChild.DetailId = Convert.ToInt32(dr["PurchaseOrderDetailID"]);
                        purchaseChild.CommId = dr["ComdID"].ToString();
                        purchaseChild.CommName = dr["ComdName"].ToString();
                        purchaseChild.Standard = dr["ComdStandard"].ToString();

                        purchaseChild.Unit = dr["Unit"].ToString();
                        purchaseChild.Amount = Convert.ToInt32(dr["amount"]);
                        purchaseChild.UnitPrice =  Convert.ToSingle(dr["PriceUnit"]);
                        purchaseChild.TotlePrice = Convert.ToSingle(dr["PriceTotal"]);
                        purchaseChild.PurKBN = Convert.ToInt32(dr["PurchaseKBN"]);
                        purchaseChild.Remark = dr["Remark"].ToString();

                        purchaseChildList.Add(purchaseChild);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new DAOException("E0001");
            }

            return purchaseChildList;
        }
Ejemplo n.º 5
0
        public object Clone()
        {
            PurchaseChild child = new PurchaseChild();
            child.purParentId = purParentId;
            child.detailId = detailId;
            child.commId = commId;
            child.commName = commName;
            child.standard = standard;
            child.unit = unit;
            child.amount = amount;
            child.unitPrice = unitPrice;
            child.totlePrice = totlePrice;
            child.remark = remark;
            child.purKBN = purKBN;

            return child;
        }
Ejemplo n.º 6
0
        private void addPurOrderChild(PurchaseChild purchaseChild)
        {
            if (purchaseChild.PurParentId == null || purchaseChild.PurParentId == string.Empty)
            {
                throw new BIZException("W03003");
            }

            if (purchaseChild.DetailId == 0)
            {
                purchaseChild.DetailId = this.GeneratePurOrderDetailId(purchaseChild.PurParentId);
            }

            int resutcount = 0;
            try
            {
                resutcount = comdDAO.AddPurchaseChild(purchaseChild, this.currentUser);
                if (resutcount != 1)
                {
                    throw new BIZException("W03002");
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="purchaseParent"></param>
        /// <param name="purchaseChildList"></param>
        /// <returns>parent OrderID</returns>
        private string addOrUpdatePurOrder(PurchaseParent purchaseParent, List<PurchaseChild> purchaseChildList)
        {
            string parentOrderId = "";
            try
            {
                //add parent into db
                if (purchaseParent.Valid == false)
                {
                    //purchaseParent.OrderId = this.GeneratePurOrderId();
                    purchaseParent.StatusKBN = 0;
                    purchaseParent.ReceivingFLG = false;
                    purchaseParent.PaymentFLG = false;

                    parentOrderId = this.addPurOrderParent(purchaseParent);
                }
                else
                {
                    purchaseParent.StatusKBN = 0;
                    purchaseParent.ReceivingFLG = false;
                    purchaseParent.PaymentFLG = false;
                    this.UpdatePurOrderParent(purchaseParent);
                    this.DeletePurOrderChild(purchaseParent.OrderId);
                    parentOrderId = purchaseParent.OrderId;
                }

                //goods
                foreach (PurchaseChild purchaseChild in purchaseChildList)
                {
                    purchaseChild.PurKBN = 1;
                }

                //discount
                PurchaseChild purchaseChildDiscount = new PurchaseChild();
                purchaseChildDiscount.PurKBN = 2;
                purchaseChildDiscount.Amount = 1;
                purchaseChildDiscount.UnitPrice = purchaseParent.Rebate;
                purchaseChildDiscount.TotlePrice = purchaseParent.Rebate;

                //freight
                PurchaseChild purchaseChildFreight = new PurchaseChild();
                purchaseChildFreight.PurKBN = 3;
                purchaseChildFreight.Amount = 1;
                purchaseChildFreight.UnitPrice = purchaseParent.Freight;
                purchaseChildFreight.TotlePrice = purchaseParent.Freight;

                //other pay
                PurchaseChild purchaseChildOtherPay = new PurchaseChild();
                purchaseChildOtherPay.PurKBN = 4;
                purchaseChildOtherPay.Amount = 1;
                purchaseChildOtherPay.UnitPrice = purchaseParent.OtherPay;
                purchaseChildOtherPay.TotlePrice = purchaseParent.OtherPay;

                purchaseChildList.Add(purchaseChildDiscount);
                purchaseChildList.Add(purchaseChildFreight);
                purchaseChildList.Add(purchaseChildOtherPay);

                //add child into db
                foreach (PurchaseChild purchaseChild in purchaseChildList)
                {
                    //purchaseChild.PurParentId = purchaseParent.OrderId;
                    purchaseChild.PurParentId = parentOrderId;
                    //purchaseChild.DetailId = this.GeneratePurOrderDetailId(purchaseChild.PurParentId);
                    this.addPurOrderChild(purchaseChild);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return parentOrderId;
        }
Ejemplo n.º 8
0
        private bool ReadDetail(PurchaseChild purChild)
        {
            if (cmbCommo.SelectedItem == null)
            {
                ShowErrorInfo("必须输入商品名");
                return false;
            }

            if (cmbStandard.SelectedItem == null)
            {
                ShowErrorInfo("必须输入商品规格型号");
                return false;
            }

            purChild.CommId = (cmbStandard.SelectedItem as ExtItem).Tag.ToString();
            purChild.CommName = cmbCommo.SelectedItem.ToString();
            purChild.Standard = (cmbStandard.SelectedItem as ExtItem).Item.ToString();

            purChild.Unit = txtUnit.Text;
            purChild.Amount = neAmount.IntValue;
            purChild.UnitPrice = (float)neUnitPrice.Value;
            purChild.TotlePrice = purChild.UnitPrice * purChild.Amount;
            purChild.Remark = txtChildRemark.Text;

            return true;
        }
Ejemplo n.º 9
0
 private void DgvCommo_SelChanged(object sender, EventArgs e)
 {
     if (DgvCommo.CurrentRow != null)
     {
         if (DgvCommo.CurrentRow.Index < purFormEntity.PurChildren.Count)
         {
             curPurChild = purFormEntity.PurChildren[DgvCommo.CurrentRow.Index];
         }
         UpdateItemDetail();
     }
 }
Ejemplo n.º 10
0
        private void BtnContinueAdd_Click(object sender, EventArgs e)
        {
            this.HideErrorInfo();

            ReadOrderInfo();

            if (curPurChild.CommId == null || curPurChild.CommId.Equals(""))
            {
                if (!ReadDetail(curPurChild))
                {
                    return;
                }

                purFormEntity.PurChildren.Add(curPurChild);
                UpdateOrderMoney();

                UpdatePage();

                ClearSelection(DgvCommo);
                curPurChild = new PurchaseChild();
                UpdateItemDetail();
            }
            else
            {
                if (!ReadDetail(curPurChild))
                {
                    return;
                }

                UpdateOrderMoney();

                UpdatePage();

                DgvCommo.Rows[DgvCommo.Rows.Count - 1].Selected = true;
                DgvCommo.CurrentCell = DgvCommo.Rows[DgvCommo.Rows.Count - 1].Cells[0];
            }
        }
Ejemplo n.º 11
0
        private void BtnCancelAdd_Click(object sender, EventArgs e)
        {
            this.HideErrorInfo();

            if (DgvCommo.CurrentRow == null)
            {
                curPurChild = null;
            }

            UpdateItemDetail();
        }
Ejemplo n.º 12
0
        private void BtnAddDetail_Click(object sender, EventArgs e)
        {
            this.HideErrorInfo();

            // 读取界面数据。
            ReadOrderInfo();

            ClearSelection(DgvCommo);
            curPurChild = new PurchaseChild();

            UpdateItemDetail();
        }