예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Maticsoft.Model.ConsumableInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_ConsumableInfo(");
            strSql.Append("C_Type,C_Barcode,C_Name,C_AliasName,C_Model,C_Address,C_Function,C_Lifetime,C_LifeUnit,C_SafeStock,C_Unit,C_Picture,C_Manufacturer,C_Official_Website,C_Tel,C_After_Sale,C_PurchasCycle,C_Remarks)");
            strSql.Append(" values (");
            strSql.Append("@C_Type,@C_Barcode,@C_Name,@C_AliasName,@C_Model,@C_Address,@C_Function,@C_Lifetime,@C_LifeUnit,@C_SafeStock,@C_Unit,@C_Picture,@C_Manufacturer,@C_Official_Website,@C_Tel,@C_After_Sale,@C_PurchasCycle,@C_Remarks)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_Type",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_Barcode",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Name",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_AliasName",        SqlDbType.VarChar, 50),
                new SqlParameter("@C_Model",            SqlDbType.VarChar, 50),
                new SqlParameter("@C_Address",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Function",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_Lifetime",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_LifeUnit",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_SafeStock",        SqlDbType.VarChar, 50),
                new SqlParameter("@C_Unit",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_Picture",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Manufacturer",     SqlDbType.VarChar, 50),
                new SqlParameter("@C_Official_Website", SqlDbType.VarChar, 50),
                new SqlParameter("@C_Tel",              SqlDbType.VarChar, 50),
                new SqlParameter("@C_After_Sale",       SqlDbType.VarChar, 50),
                new SqlParameter("@C_PurchasCycle",     SqlDbType.VarChar, 50),
                new SqlParameter("@C_Remarks",          SqlDbType.Text)
            };
            parameters[0].Value  = model.C_Type;
            parameters[1].Value  = model.C_Barcode;
            parameters[2].Value  = model.C_Name;
            parameters[3].Value  = model.C_AliasName;
            parameters[4].Value  = model.C_Model;
            parameters[5].Value  = model.C_Address;
            parameters[6].Value  = model.C_Function;
            parameters[7].Value  = model.C_Lifetime;
            parameters[8].Value  = model.C_LifeUnit;
            parameters[9].Value  = model.C_SafeStock;
            parameters[10].Value = model.C_Unit;
            parameters[11].Value = model.C_Picture;
            parameters[12].Value = model.C_Manufacturer;
            parameters[13].Value = model.C_Official_Website;
            parameters[14].Value = model.C_Tel;
            parameters[15].Value = model.C_After_Sale;
            parameters[16].Value = model.C_PurchasCycle;
            parameters[17].Value = model.C_Remarks;

            object obj = dbs.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
예제 #2
0
 public frm_Consumable(Maticsoft.Model.ConsumableInfo _ConsumableInfo)
 {
     InitializeComponent();
     grd_ConsumableInfo.DataContext = _ConsumableInfo;
     btn_Edit.IsEnabled             = true;
     MCP_CS.SetControl(grd_ConsumableInfo, false, false); //设置控件为不可编辑模式
     ShowImg(_ConsumableInfo.C_Picture);
 }
예제 #3
0
 //新增
 private void btn_Add_Click(object sender, RoutedEventArgs e)
 {
     Maticsoft.Model.ConsumableInfo _Consum = new Maticsoft.Model.ConsumableInfo();
     _Consum.C_Barcode = MCP_CS.ConsumableInfo.GetMaxID();
     grd_ConsumableInfo.DataContext = _Consum;
     IsAdd = true;
     btn_Save.IsEnabled = true;
     btn_Add.IsEnabled  = false;
     MCP_CS.SetControl(grd_ConsumableInfo, true, false); //设置控件为不可编辑模式
 }
예제 #4
0
 //
 //选择耗材
 //
 private void dgv_ConsumableInfoList_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     try
     {
         if (dgv_ConsumableInfoList.SelectedItem != null)
         {
             Maticsoft.Model.ConsumableInfo _C_Info = (Maticsoft.Model.ConsumableInfo)dgv_ConsumableInfoList.SelectedItem;
             grd_ConsumableInfo.DataContext = _C_Info;
             txb_Consumable_Barcode.Text    = _C_Info.C_Barcode;
             txb_ConsumableName.Text        = _C_Info.C_Name;
         }
     }
     catch { }
 }
예제 #5
0
        //
        //双击弹出物料详细信息
        //
        private void dgv_ConsumableInfoList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (dgv_ConsumableInfoList.SelectedItem != null)
                {
                    Maticsoft.Model.ConsumableInfo _consum = (Maticsoft.Model.ConsumableInfo)dgv_ConsumableInfoList.SelectedItem;

                    frm_Consumable f = new frm_Consumable(_consum);
                    f.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    f.Show();
                }
            }
            catch { }
        }
예제 #6
0
 //
 //保存
 //
 private void btn_Save_Click(object sender, RoutedEventArgs e)
 {
     Maticsoft.Model.ConsumableInfo _Consum = (Maticsoft.Model.ConsumableInfo)grd_ConsumableInfo.DataContext;
     if (IsAdd) //添加模式
     {
         MCP_CS.ConsumableInfo.Add(_Consum);
         btn_Add.IsEnabled = true;
         My_MessageBox.My_MessageBox_Query("添加成功!");
         grd_ConsumableInfo.DataContext = new Maticsoft.Model.ConsumableInfo();
     }
     else      //更新模式
     {
         MCP_CS.ConsumableInfo.Update(_Consum);
     }
     MCP_CS.SetControl(grd_ConsumableInfo, false, false); //设置控件为不可编辑模式
 }
예제 #7
0
 //
 //删除
 //
 private void btn_Delete_Click(object sender, RoutedEventArgs e)
 {
     Maticsoft.Model.ConsumableInfo _Consum = (Maticsoft.Model.ConsumableInfo)grd_ConsumableInfo.DataContext;
     if (_Consum.Csm_ID > 0)
     {
         if (MCP_CS.ConsumableInfo.Delete(_Consum.Csm_ID))
         {
             My_MessageBox.My_MessageBox_Query("删除成功!");
         }
         else
         {
             My_MessageBox.My_MessageBox_Query("删除失败!");
         }
     }
     else
     {
         My_MessageBox.My_MessageBox_Query("删除不合法,请确认操作是否正确!");
     }
 }
예제 #8
0
        /// <summary>
        /// 保存领料记录 并更改库存
        /// </summary>
        private int Add_Receive(DataGrid _Grid)
        {
            ConsumableReceive _M_ConsumableReceive = new ConsumableReceive();
            ConsumableInfo    _M_ConsumableInfo    = new ConsumableInfo();
            int    _recode  = 0;
            string _Message = "";

            foreach (object tem in _Grid.ItemsSource)
            {
                Maticsoft.Model.ConsumableReceive _tem            = (Maticsoft.Model.ConsumableReceive)tem;
                Maticsoft.Model.ConsumableInfo    _ConsumableInfo = _M_ConsumableInfo.GetModel(_tem.C_Barcode);

                int _Count = 0, _SaftCount = 0, Stock = 0;
                int.TryParse(_tem.Count.ToString(), out _Count);           //领取数量
                int.TryParse(_ConsumableInfo.C_SafeStock, out _SaftCount); //安全库存
                int.TryParse(_ConsumableInfo.Stock, out Stock);            //当前剩余数量

                if (_Count < Stock)                                        //如果领取数量小于库存数量
                {
                    if ((Stock - _Count) <= _SaftCount)
                    {
                        _Message += "编号:" + _ConsumableInfo.C_Barcode + "名称:" + _ConsumableInfo.C_Name + "库存不足,请立即请购!";
                    }
                    _tem.Datetime = DateTime.Now.ToString();
                    if (_M_ConsumableReceive.Add(_tem) > 0)
                    {
                        _recode++;
                    }
                }
                else
                {
                    _Message += "\r\n保存失败警告:编号:" + _ConsumableInfo.C_Barcode + "名称:" + _ConsumableInfo.C_Name + "库存不足,未进行保存";
                }
            }
            if (_Message.Length > 2)
            {
                My_MessageBox.My_MessageBox_Message(_Message);
            }
            return(_recode);
        }
예제 #9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.ConsumableInfo GetModel(string Csm_BarCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Csm_ID,C_Type,C_Barcode,C_Name,C_AliasName,C_Model,C_Address,C_Function,C_Lifetime,C_LifeUnit,C_SafeStock,C_Unit,C_Picture,C_Manufacturer,C_Official_Website,C_Tel,C_After_Sale,C_PurchasCycle,C_Remarks from tb_ConsumableInfo ");
            strSql.Append(" where C_Barcode=@C_Barcode");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_Barcode", SqlDbType.VarChar)
            };
            parameters[0].Value = Csm_BarCode;

            Maticsoft.Model.ConsumableInfo model = new Maticsoft.Model.ConsumableInfo();
            DataSet ds = dbs.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Csm_ID"] != null && ds.Tables[0].Rows[0]["Csm_ID"].ToString() != "")
                {
                    model.Csm_ID = decimal.Parse(ds.Tables[0].Rows[0]["Csm_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["C_Type"] != null && ds.Tables[0].Rows[0]["C_Type"].ToString() != "")
                {
                    model.C_Type = ds.Tables[0].Rows[0]["C_Type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Barcode"] != null && ds.Tables[0].Rows[0]["C_Barcode"].ToString() != "")
                {
                    model.C_Barcode = ds.Tables[0].Rows[0]["C_Barcode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Name"] != null && ds.Tables[0].Rows[0]["C_Name"].ToString() != "")
                {
                    model.C_Name = ds.Tables[0].Rows[0]["C_Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_AliasName"] != null && ds.Tables[0].Rows[0]["C_AliasName"].ToString() != "")
                {
                    model.C_AliasName = ds.Tables[0].Rows[0]["C_AliasName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Model"] != null && ds.Tables[0].Rows[0]["C_Model"].ToString() != "")
                {
                    model.C_Model = ds.Tables[0].Rows[0]["C_Model"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Address"] != null && ds.Tables[0].Rows[0]["C_Address"].ToString() != "")
                {
                    model.C_Address = ds.Tables[0].Rows[0]["C_Address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Function"] != null && ds.Tables[0].Rows[0]["C_Function"].ToString() != "")
                {
                    model.C_Function = ds.Tables[0].Rows[0]["C_Function"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Lifetime"] != null && ds.Tables[0].Rows[0]["C_Lifetime"].ToString() != "")
                {
                    model.C_Lifetime = ds.Tables[0].Rows[0]["C_Lifetime"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_LifeUnit"] != null && ds.Tables[0].Rows[0]["C_LifeUnit"].ToString() != "")
                {
                    model.C_LifeUnit = ds.Tables[0].Rows[0]["C_LifeUnit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_SafeStock"] != null && ds.Tables[0].Rows[0]["C_SafeStock"].ToString() != "")
                {
                    model.C_SafeStock = ds.Tables[0].Rows[0]["C_SafeStock"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Unit"] != null && ds.Tables[0].Rows[0]["C_Unit"].ToString() != "")
                {
                    model.C_Unit = ds.Tables[0].Rows[0]["C_Unit"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Picture"] != null && ds.Tables[0].Rows[0]["C_Picture"].ToString() != "")
                {
                    model.C_Picture = ds.Tables[0].Rows[0]["C_Picture"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Manufacturer"] != null && ds.Tables[0].Rows[0]["C_Manufacturer"].ToString() != "")
                {
                    model.C_Manufacturer = ds.Tables[0].Rows[0]["C_Manufacturer"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Official_Website"] != null && ds.Tables[0].Rows[0]["C_Official_Website"].ToString() != "")
                {
                    model.C_Official_Website = ds.Tables[0].Rows[0]["C_Official_Website"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Tel"] != null && ds.Tables[0].Rows[0]["C_Tel"].ToString() != "")
                {
                    model.C_Tel = ds.Tables[0].Rows[0]["C_Tel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_After_Sale"] != null && ds.Tables[0].Rows[0]["C_After_Sale"].ToString() != "")
                {
                    model.C_After_Sale = ds.Tables[0].Rows[0]["C_After_Sale"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_PurchasCycle"] != null && ds.Tables[0].Rows[0]["C_PurchasCycle"].ToString() != "")
                {
                    model.C_PurchasCycle = ds.Tables[0].Rows[0]["C_PurchasCycle"].ToString();
                }
                if (ds.Tables[0].Rows[0]["C_Remarks"] != null && ds.Tables[0].Rows[0]["C_Remarks"].ToString() != "")
                {
                    model.C_Remarks = ds.Tables[0].Rows[0]["C_Remarks"].ToString();
                }

                //通过计算得出当前库存
                ConsumableReceive _M_Re         = new ConsumableReceive();
                ConsumableStorage _M_St         = new ConsumableStorage();
                double            _storageCount = _M_St.Get_Stock(model.C_Barcode);
                double            _receiveCount = _M_Re.Get_Stock(model.C_Barcode);
                model.Stock = (_storageCount - _receiveCount).ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.ConsumableInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_ConsumableInfo set ");
            strSql.Append("C_Type=@C_Type,");
            strSql.Append("C_Barcode=@C_Barcode,");
            strSql.Append("C_Name=@C_Name,");
            strSql.Append("C_AliasName=@C_AliasName,");
            strSql.Append("C_Model=@C_Model,");
            strSql.Append("C_Address=@C_Address,");
            strSql.Append("C_Function=@C_Function,");
            strSql.Append("C_Lifetime=@C_Lifetime,");
            strSql.Append("C_LifeUnit=@C_LifeUnit,");
            strSql.Append("C_SafeStock=@C_SafeStock,");
            strSql.Append("C_Unit=@C_Unit,");
            strSql.Append("C_Picture=@C_Picture,");
            strSql.Append("C_Manufacturer=@C_Manufacturer,");
            strSql.Append("C_Official_Website=@C_Official_Website,");
            strSql.Append("C_Tel=@C_Tel,");
            strSql.Append("C_After_Sale=@C_After_Sale,");
            strSql.Append("C_PurchasCycle=@C_PurchasCycle,");
            strSql.Append("C_Remarks=@C_Remarks");
            strSql.Append(" where Csm_ID=@Csm_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@C_Type",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_Barcode",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Name",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_AliasName",        SqlDbType.VarChar, 50),
                new SqlParameter("@C_Model",            SqlDbType.VarChar, 50),
                new SqlParameter("@C_Address",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Function",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_Lifetime",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_LifeUnit",         SqlDbType.VarChar, 50),
                new SqlParameter("@C_SafeStock",        SqlDbType.VarChar, 50),
                new SqlParameter("@C_Unit",             SqlDbType.VarChar, 50),
                new SqlParameter("@C_Picture",          SqlDbType.VarChar, 50),
                new SqlParameter("@C_Manufacturer",     SqlDbType.VarChar, 50),
                new SqlParameter("@C_Official_Website", SqlDbType.VarChar, 50),
                new SqlParameter("@C_Tel",              SqlDbType.VarChar, 50),
                new SqlParameter("@C_After_Sale",       SqlDbType.VarChar, 50),
                new SqlParameter("@C_PurchasCycle",     SqlDbType.VarChar, 50),
                new SqlParameter("@C_Remarks",          SqlDbType.Text),
                new SqlParameter("@Csm_ID",             SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = model.C_Type;
            parameters[1].Value  = model.C_Barcode;
            parameters[2].Value  = model.C_Name;
            parameters[3].Value  = model.C_AliasName;
            parameters[4].Value  = model.C_Model;
            parameters[5].Value  = model.C_Address;
            parameters[6].Value  = model.C_Function;
            parameters[7].Value  = model.C_Lifetime;
            parameters[8].Value  = model.C_LifeUnit;
            parameters[9].Value  = model.C_SafeStock;
            parameters[10].Value = model.C_Unit;
            parameters[11].Value = model.C_Picture;
            parameters[12].Value = model.C_Manufacturer;
            parameters[13].Value = model.C_Official_Website;
            parameters[14].Value = model.C_Tel;
            parameters[15].Value = model.C_After_Sale;
            parameters[16].Value = model.C_PurchasCycle;
            parameters[17].Value = model.C_Remarks;
            parameters[18].Value = model.Csm_ID;

            int rows = dbs.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }