Пример #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DB.Model.PAPER_SIZE DataRowToModel(DataRow row)
 {
     DB.Model.PAPER_SIZE model = new DB.Model.PAPER_SIZE();
     if (row != null)
     {
         if (row["GUID"] != null)
         {
             model.GUID = row["GUID"].ToString();
         }
         if (row["PAPER_NAME"] != null)
         {
             model.PAPER_NAME = row["PAPER_NAME"].ToString();
         }
         if (row["PAPER_LENGTH"] != null && row["PAPER_LENGTH"].ToString() != "")
         {
             model.PAPER_LENGTH = decimal.Parse(row["PAPER_LENGTH"].ToString());
         }
         if (row["PAPER_WIDTH"] != null && row["PAPER_WIDTH"].ToString() != "")
         {
             model.PAPER_WIDTH = decimal.Parse(row["PAPER_WIDTH"].ToString());
         }
         if (row["PAPER_PIXEL_LENGTH"] != null && row["PAPER_PIXEL_LENGTH"].ToString() != "")
         {
             model.PAPER_PIXEL_LENGTH = decimal.Parse(row["PAPER_PIXEL_LENGTH"].ToString());
         }
         if (row["PAPER_PIXEL_WIDTH"] != null && row["PAPER_PIXEL_WIDTH"].ToString() != "")
         {
             model.PAPER_PIXEL_WIDTH = decimal.Parse(row["PAPER_PIXEL_WIDTH"].ToString());
         }
     }
     return(model);
 }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DB.Model.PAPER_SIZE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PAPER_SIZE(");
            strSql.Append("GUID,PAPER_NAME,PAPER_LENGTH,PAPER_WIDTH,PAPER_PIXEL_LENGTH,PAPER_PIXEL_WIDTH)");
            strSql.Append(" values (");
            strSql.Append(":GUID,:PAPER_NAME,:PAPER_LENGTH,:PAPER_WIDTH,:PAPER_PIXEL_LENGTH,:PAPER_PIXEL_WIDTH)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":GUID",               OracleType.VarChar, 100),
                new OracleParameter(":PAPER_NAME",         OracleType.VarChar, 100),
                new OracleParameter(":PAPER_LENGTH",       OracleType.Number,    8),
                new OracleParameter(":PAPER_WIDTH",        OracleType.Number,    8),
                new OracleParameter(":PAPER_PIXEL_LENGTH", OracleType.Number,    5),
                new OracleParameter(":PAPER_PIXEL_WIDTH",  OracleType.Number, 5)
            };
            parameters[0].Value = model.GUID;
            parameters[1].Value = model.PAPER_NAME;
            parameters[2].Value = model.PAPER_LENGTH;
            parameters[3].Value = model.PAPER_WIDTH;
            parameters[4].Value = model.PAPER_PIXEL_LENGTH;
            parameters[5].Value = model.PAPER_PIXEL_WIDTH;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DB.Model.PAPER_SIZE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PAPER_SIZE set ");
            strSql.Append("GUID=:GUID,");
            strSql.Append("PAPER_LENGTH=:PAPER_LENGTH,");
            strSql.Append("PAPER_WIDTH=:PAPER_WIDTH,");
            strSql.Append("PAPER_PIXEL_LENGTH=:PAPER_PIXEL_LENGTH,");
            strSql.Append("PAPER_PIXEL_WIDTH=:PAPER_PIXEL_WIDTH");
            strSql.Append(" where PAPER_NAME=:PAPER_NAME ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":GUID",               OracleType.VarChar, 100),
                new OracleParameter(":PAPER_LENGTH",       OracleType.Number,    8),
                new OracleParameter(":PAPER_WIDTH",        OracleType.Number,    8),
                new OracleParameter(":PAPER_PIXEL_LENGTH", OracleType.Number,    5),
                new OracleParameter(":PAPER_PIXEL_WIDTH",  OracleType.Number,    5),
                new OracleParameter(":PAPER_NAME",         OracleType.VarChar, 100)
            };
            parameters[0].Value = model.GUID;
            parameters[1].Value = model.PAPER_LENGTH;
            parameters[2].Value = model.PAPER_WIDTH;
            parameters[3].Value = model.PAPER_PIXEL_LENGTH;
            parameters[4].Value = model.PAPER_PIXEL_WIDTH;
            parameters[5].Value = model.PAPER_NAME;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 添加纸张
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_AddPaper_Click(object sender, EventArgs e)
        {
            if (textBox_PaperName.Text == "" || textBox_userdef_printlen.Text == "" || textBox_userdef_printwidth.Text == "")
            {
                MessageBox.Show("请先完成纸张定义");
                return;
            }

            //写入数据库
            DB.BLL.PAPER_SIZE bll = new DB.BLL.PAPER_SIZE();
            DB.Model.PAPER_SIZE model = new DB.Model.PAPER_SIZE();
            model.GUID = System.Guid.NewGuid().ToString();
            model.PAPER_NAME = textBox_PaperName.Text;

            if (checkBox_unit.Checked)
            {
                
                model.PAPER_LENGTH = Convert.ToDecimal(textBox_userdef_printlen.Text);
                model.PAPER_WIDTH = Convert.ToDecimal(textBox_userdef_printwidth.Text);
                model.PAPER_PIXEL_LENGTH = Convert.ToDecimal(Math.Ceiling((Convert.ToDouble(textBox_userdef_printlen.Text)) * 37.8));//根据厘米长度计算像素
                model.PAPER_PIXEL_WIDTH = Convert.ToDecimal(Math.Ceiling((Convert.ToDouble(model.PAPER_WIDTH)) * 37.8));
                bll.Add(model);
            }
            else
            {
                model.PAPER_LENGTH = Convert.ToDecimal(Convert.ToDouble(textBox_userdef_printlen.Text) * 2.54 / 96);
                model.PAPER_WIDTH = Convert.ToDecimal(Convert.ToDouble(textBox_userdef_printwidth.Text) * 2.54 / 96);
                model.PAPER_PIXEL_LENGTH = Convert.ToDecimal(textBox_userdef_printlen.Text);
                model.PAPER_PIXEL_WIDTH = Convert.ToDecimal(textBox_userdef_printwidth.Text);
                bll.Add(model);
            }
                              
            Init_dgv_PaperSizeList();

            //将纸张信息添加进pmp文件
            SavePaper();
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DB.Model.PAPER_SIZE GetModel(string PAPER_NAME)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select GUID,PAPER_NAME,PAPER_LENGTH,PAPER_WIDTH,PAPER_PIXEL_LENGTH,PAPER_PIXEL_WIDTH from PAPER_SIZE ");
            strSql.Append(" where PAPER_NAME=:PAPER_NAME ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":PAPER_NAME", OracleType.VarChar, 100)
            };
            parameters[0].Value = PAPER_NAME;

            DB.Model.PAPER_SIZE model = new DB.Model.PAPER_SIZE();
            DataSet             ds    = DbHelperOra.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }