コード例 #1
0
        public void Insert(PurchaseDetilModel model)
        {
            var sSql = @"
                INSERT INTO
                    PurchaseDetil (
                        PurchaseID, PurchaseDetilID, NoUrut, BrgID, 
                        Qty, Harga, Diskon, TaxProsen, TaxRupiah, 
                        SubTotal )
                VALUES (
                        @PurchaseID, @PurchaseDetilID, @NoUrut, @BrgID, 
                        @Qty, @Harga, @Diskon, @TaxProsen, @TaxRupiah, 
                        @SubTotal ) ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@PurchaseID", model.PurchaseID);
                    cmd.AddParam("@PurchaseDetilID", model.PurchaseDetilID);
                    cmd.AddParam("@NoUrut", model.NoUrut);
                    cmd.AddParam("@BrgID", model.BrgID);
                    cmd.AddParam("Qty", model.Qty);
                    cmd.AddParam("@Harga", model.Harga);
                    cmd.AddParam("@Diskon", model.Diskon);
                    cmd.AddParam("@TaxProsen", model.TaxProsen);
                    cmd.AddParam("@TaxRupiah", model.TaxRupiah);
                    cmd.AddParam("@SubTotal", model.SubTotal);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
コード例 #2
0
        public PurchaseDetilModel ValidateBrg(PurchaseDetilModel pd)
        {
            var brg = _brgBL.GetData(pd.BrgID);

            if (brg == null)
            {
                return(null);
            }
            pd.BrgName = brg.BrgName;
            return(pd);
        }
コード例 #3
0
        public IEnumerable <PurchaseDetilModel> ListData(string purchaseID)
        {
            List <PurchaseDetilModel> result = null;
            var sSql = @"
                SELECT
                    aa.PurchaseID, aa.PurchaseDetilID, aa.NoUrut, aa.BrgID,
                    aa.Qty, aa.Harga, aa.Diskon, aa.TaxProsen, aa.TaxRupiah,
                    aa.SubTotal,
                    ISNULL(bb.BrgName, '') BrgName 
                FROM
                    PurchaseDetil aa
                    LEFT JOIN Brg bb ON aa.BrgID = bb.BrgID 
                WHERE
                    aa.PurchaseID = @PurchaseID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@PurchaseID", purchaseID);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        result = new List <PurchaseDetilModel>();
                        while (dr.Read())
                        {
                            var item = new PurchaseDetilModel
                            {
                                PurchaseID      = dr["PurchaseID"].ToString(),
                                PurchaseDetilID = dr["PurchaseDetilID"].ToString(),
                                NoUrut          = Convert.ToInt16(dr["NoUrut"]),
                                BrgID           = dr["BrgID"].ToString(),
                                BrgName         = dr["BrgName"].ToString(),
                                Qty             = Convert.ToInt64(dr["Qty"]),
                                Harga           = Convert.ToDecimal(dr["Harga"]),
                                Diskon          = Convert.ToDecimal(dr["Diskon"]),
                                SubTotal        = Convert.ToDecimal(dr["SubTotal"]),
                                TaxProsen       = Convert.ToDouble(dr["TaxProsen"]),
                                TaxRupiah       = Convert.ToDecimal(dr["TaxRupiah"])
                            };
                            result.Add(item);
                        }
                    }
                }
            return(result);
        }
コード例 #4
0
 private PurchaseDetilModel PurchaseDetilDataFactory()
 {
     var result = new PurchaseDetilModel
     {
         PurchaseID = "A1",
         PurchaseDetilID = "B1",
         BrgID = "C1",
         BrgName = "",
         Harga = 1,
         NoUrut = 2,
         Qty = 3,
         Diskon = 200,
         SubTotal = 2121,
         TaxProsen = 7.6,
         TaxRupiah = 122
     };
     return result;
 }
コード例 #5
0
        public PurchaseDetilModel PilihBrg(PurchaseDetilModel pd)
        {
            var searchForm   = new SearchingForm <BrgSearchResultModel>(_brgBL);
            var resultDialog = searchForm.ShowDialog();

            if (resultDialog == DialogResult.OK)
            {
                var brgID = searchForm.SelectedDataKey;
                var brg   = _brgBL.GetData(brgID);
                if (brg == null)
                {
                    return(pd);
                }

                if (pd == null)
                {
                    pd = new PurchaseDetilModel();
                }

                pd.BrgID   = brgID;
                pd.BrgName = brg.BrgName;
            }
            return(pd);
        }
コード例 #6
0
 public PurchaseDetilModel Calculate(PurchaseDetilModel pd)
 {
     pd.SubTotal = pd.Qty * (pd.Harga - pd.Diskon + pd.TaxRupiah);
     return(pd);
 }