Beispiel #1
0
        private void LoadInventorys()
        {
            DataTable dt1 = InventoryLogic.GetInstance().GetInventoryView_Product(string.Empty);
            DataTable dt2 = InventoryLogic.GetInstance().GetInventoryView_Property(string.Empty);

            dataGridView1.DataSource = dt1;
            dataGridView2.DataSource = dt2;
        }
Beispiel #2
0
        public bool UpdateIncome(Income element)
        {
            string sql = "update TF_Income set PID=" + element.PID + ", IsProduct=" + (element.IsProduct ? "1" : "0") + ", IsIncome=" + (element.IsIncome ? "1" : "0") + ", 数量=" + element.数量 + ", 实价=" + element.实价 + ", 备注='" + element.备注 + "', 经手人='" + element.经手人 + "', 时间=getdate() where ID=" + element.ID;
            int    r   = sqlHelper.ExecuteSql(sql);

            if (r > 0)
            {
                InventoryLogic.GetInstance().SaveInventory(element.PID, element.IsProduct, element.IsIncome, element.数量);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        public int AddIncome(Income element)
        {
            string sql = "insert into TF_Income (PID, IsProduct, IsIncome, 数量, 实价, 备注, 经手人) values (" + element.PID + ", " + (element.IsProduct ? "1" : "0") + ", " + (element.IsIncome ? "1" : "0") + "," + element.数量 + ", " + element.实价 + ", '" + element.备注 + "', '" + element.经手人 + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                InventoryLogic.GetInstance().SaveInventory(element.PID, element.IsProduct, element.IsIncome, element.数量);
                return(R);
            }
            else
            {
                return(0);
            }
        }
Beispiel #4
0
        private DataTable Search(bool isProduct, string name, DateTime start, DateTime end)
        {
            DataTable dt = null;

            string where = " like '%" + name + "%' and 更新时间 between '" + start.ToString("yyyy-MM-dd HH:mm:ss.fff") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss.fff") + "' order by 更新时间 desc";;
            if (isProduct)
            {
                where = "品名" + where;
                InventoryLogic.GetInstance().GetInventoryView_Product(where);
            }
            else
            {
                where = "名称" + where;
                dt    = InventoryLogic.GetInstance().GetInventoryView_Property(where);
            }
            return(dt);
        }
Beispiel #5
0
        //public bool DeleteIncome(Income element)
        //{
        //    string sql = "delete from TF_Income where ID=" + element.ID;
        //    int r = sqlHelper.ExecuteSql(sql);
        //    return r > 0;
        //}
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool UpgradeList(List <Income> list)
        {
            int errCount = 0;

            foreach (Income element in list)
            {
                string sqlStr = "if exists (select 1 from TF_Income where ID=" + element.ID + ") update TF_Income set PID=" + element.PID + ", IsProduct=" + (element.IsProduct ? "1" : "0") + ", IsIncome=" + (element.IsIncome ? "1" : "0") + ", 数量=" + element.数量 + ", 实价=" + element.实价 + ", 备注='" + element.备注 + "', 经手人='" + element.经手人 + "', 时间=getdate() where ID=" + element.ID + " else insert into TF_Income (PID, IsProduct, IsIncome, 数量, 实价, 备注, 经手人) values (" + element.PID + ", " + (element.IsProduct ? "1" : "0") + ", " + (element.IsIncome ? "1" : "0") + "," + element.数量 + ", " + element.实价 + ", '" + element.备注 + "', '" + element.经手人 + "')";
                try
                {
                    sqlHelper.ExecuteSql(sqlStr);
                    InventoryLogic.GetInstance().SaveInventory(element.PID, element.IsProduct, element.IsIncome, element.数量);
                }
                catch (Exception)
                {
                    errCount++;
                }
            }
            return(errCount == 0);
        }
Beispiel #6
0
        private DataTable Search(bool isProduct, string name, DateTime start, DateTime end, int action, ProductType pt = null)
        {
            DataTable dt   = null;
            string    time = " and 更新时间 between '" + start.ToString("yyyy-MM-dd HH:mm") + "' and '" + end.ToString("yyyy-MM-dd HH:mm") + "'";
            string    act  = "";

            if (action > 0)
            {
                act = " and 动作='" + (action == 1 ? "入库" : "出库") + "'";
            }
            if (isProduct)
            {
                string nm = "";
                if (!string.IsNullOrEmpty(name) && name.Trim() != "")
                {
                    nm = " and 品名 like '%" + name + "%'";
                }
                string type = "";
                if (pt != null)
                {
                    type = " and 种类='" + pt.类型 + "'";
                }
                string where = "(1=1)" + nm + time + act + type;
                dt           = InventoryLogic.GetInstance().GetInventoryView_Product(where);
            }
            else
            {
                string nm = "";
                if (!string.IsNullOrEmpty(name) && name.Trim() != "")
                {
                    nm = " and 名称 like '%" + name + "%'";
                }
                string where = "(1=1)" + nm + time + act;
                dt           = InventoryLogic.GetInstance().GetInventoryView_Property(where);
            }
            return(dt);
        }