Exemplo n.º 1
0
        public List <DrugFrom> SearchDrugFrom(string searchCond, IDbConnection conn)
        {
            string sql = @"select 
            ID,DrugFromCode,DrugFromName,Actived,Remark
            from MD_DrugFrom
            Where DrugFromCode=@DrugFromCode
            or DrugFromName=@DrugFromName
            ";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugFromCode", searchCond));
            paramList.Add(new SqlParameter("@DrugFromName", searchCond));
            SqlDataReader   reader   = DataAccessUtil.ExecuteReader(sql, paramList, (SqlConnection)conn);
            List <DrugFrom> fromList = new List <DrugFrom>();

            while (reader.Read())
            {
                DrugFrom from = new DrugFrom();
                from.ID      = reader.GetInt32(0);
                from.Code    = reader.GetString(1);
                from.Name    = reader.GetString(2);
                from.Actived = reader.GetBoolean(3);
                if (!reader.IsDBNull(4))
                {
                    from.Remark = reader.GetString(4);
                }
                fromList.Add(from);
            }
            reader.Close();
            return(fromList);
        }
Exemplo n.º 2
0
        public DrugFrom SelectDrugFrom(int id, IDbConnection conn)
        {
            string sql = @"
            select ID,DrugFromCode,DrugFromName,Actived,Remark
            from MD_DrugFrom where ID=@ID";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@ID", id));
            SqlDataReader reader = DataAccessUtil.ExecuteReader(sql, paramList, (SqlConnection)conn);
            DrugFrom      from   = null;

            while (reader.Read())
            {
                from         = new DrugFrom();
                from.ID      = reader.GetInt32(0);
                from.Code    = reader.GetString(1);
                from.Name    = reader.GetString(2);
                from.Actived = reader.GetBoolean(3);
                if (!reader.IsDBNull(4))
                {
                    from.Remark = reader.GetString(4);
                }
            }
            reader.Close();
            return(from);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 增加一个药品产地
 /// </summary>
 /// <param name="from"></param>
 /// <param name="creator"></param>
 public void CreateDrugFrom(DrugFrom from, string creator)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDrugFromDAO dao = DAOFactory.Instance.CreateDrugFromDAO();
         dao.InsertDrugFrom(from, conn);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 用于修改
 /// </summary>
 /// <param name="model"></param>
 public FrmDrugFrom(DrugFrom model)
 {
     InitializeComponent();
     this.Text               = string.Format(this.Text, "修改药品产地");
     this.Model              = model;
     this.txtCode.Text       = model.Code;
     this.txtName.Text       = model.Name;
     this.ckbActived.Checked = model.Actived;
     this.txtRemark.Text     = model.Remark;
 }
Exemplo n.º 5
0
        public void InsertDrugFrom(DrugFrom from, IDbConnection conn, IDbTransaction trans)
        {
            string sql = @"
            Insert into MD_DrugFrom(DrugFromCode,DrugFromName,Actived,Remark) 
            values(@DrugFromCode,@DrugFromName,@Actived,@Remark) ";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugFromCode", from.Code));
            paramList.Add(new SqlParameter("@DrugFromName", from.Name));
            paramList.Add(new SqlParameter("@Actived", from.Actived));
            paramList.Add(new SqlParameter("@Remark", from.Remark));
            DataAccessUtil.ExecuteNonQuery(sql, paramList, (SqlTransaction)trans);
        }
Exemplo n.º 6
0
        public void UpdateDrugFrom(DrugFrom from, IDbConnection conn, IDbTransaction trans)
        {
            string sql = @"
            Update MD_DrugFrom set 
                DrugFromCode=@DrugFromCode,DrugFromName=@DrugFromName,Actived=@Actived,Remark=@Remark
            where ID=@ID";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugFromCode", from.Code));
            paramList.Add(new SqlParameter("@DrugFromName", from.Name));
            paramList.Add(new SqlParameter("@Actived", from.Actived));
            paramList.Add(new SqlParameter("@Remark", from.Remark));
            paramList.Add(new SqlParameter("@ID", from.ID));
            DataAccessUtil.ExecuteNonQuery(sql, paramList, (SqlTransaction)trans);
        }
Exemplo n.º 7
0
        private List <DrugFrom> GetSelectModelList()
        {
            List <DrugFrom> selectedModelList = new List <DrugFrom>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[0];
                if (cell.EditedFormattedValue != null && (bool)cell.EditedFormattedValue == true)
                {
                    DrugFrom selectedModel = (DrugFrom)row.Tag;
                    selectedModelList.Add(selectedModel);
                }
            }
            if (selectedModelList.Count == 0)
            {
                throw new ApplicationException("请选择要操作的内容。");
            }
            return(selectedModelList);
        }
Exemplo n.º 8
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         //Verify
         if (string.IsNullOrEmpty(this.txtCode.Text.Trim()))
         {
             throw new ApplicationException("编码不能为空");
         }
         if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
         {
             throw new ApplicationException("名称不能为空");
         }
         //save
         ModelService modelService = new ModelService();
         if (this.Model == null)//新建
         {
             DrugFrom model = new DrugFrom();
             model.Code    = this.txtCode.Text.Trim();
             model.Name    = this.txtName.Text.Trim();
             model.Actived = this.ckbActived.Checked;
             model.Remark  = this.txtRemark.Text.Trim();
             modelService.CreateDrugFrom(model, PermissionService.GetCurrentUser().Name);
         }
         else//修改
         {
             this.Model.Code    = this.txtCode.Text.Trim();
             this.Model.Name    = this.txtName.Text.Trim();
             this.Model.Actived = this.ckbActived.Checked;
             this.Model.Remark  = this.txtRemark.Text.Trim();
             modelService.SaveDrugFrom(this.Model, PermissionService.GetCurrentUser().Name);
         }
         //close diaglog
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ErrorHandler.OnError(ex);
     }
 }