Beispiel #1
0
        protected void AddImages(FishEntity.SalesRContractEntity fish)
        {
            if (fish == null)
            {
                return;
            }

            FishBll.Bll.ImageBll bll = new FishBll.Bll.ImageBll();
            if (setbool.id > 0)
            {
                bll.DeleteByRecordIdAndType(setbool.id, (int)FishEntity.ImageTypeEnum.HETONG);
            }
            List <FishEntity.ImageEntity> images = GetSGSImages();

            images = GetSGSImages();
            if (images != null)
            {
                foreach (FishEntity.ImageEntity item in images)
                {
                    item.recordid   = setbool.id;
                    item.createman  = FishEntity.Variable.User.username;
                    item.createtime = DateTime.Now;
                    item.title      = "合同";
                    item.remark     = this.Name;
                    bll.Add(item);
                }
            }
        }
Beispiel #2
0
        public override void Save()
        {
            _model = new FishEntity.SalesRContractEntity();
            List <FishEntity.productsituationEntity> modelList = new List <FishEntity.productsituationEntity>();

            bll = new FishBll.Bll.SalesRContractBll();
            GetSalesRContract();
            DataView(modelList);
            //bool isok = bll.Exists(_model.ContractCode);
            //if (isok)
            //{
            //    MessageBox.Show("合同编号已存在!");
            //    return;
            //}
            bool isok = bll.ExistsNumbering(_model.Numbering);

            if (isok)
            {
                MessageBox.Show("编号已存在!");
                return;
            }
            _model.Id = bll.Add(_model, modelList);
            if (_model.Id > 0)
            {
                setbool.id = _model.Id;
                AddImages(_model);
                MessageBox.Show("保存成功!");
            }
        }
Beispiel #3
0
        public override int Add()
        {
            tmiSave.Visible     = true;
            tmiCancel.Visible   = true;
            tmiAdd.Visible      = false;
            tmiModify.Visible   = false;
            tmiQuery.Visible    = false;
            tmiDelete.Visible   = false;
            tmiClose.Visible    = false;
            tmiNext.Visible     = false;
            tmiPrevious.Visible = false;
            tmiExport.Visible   = false;
            tmiReview.Visible   = false;
            txtcode.Text        = string.Empty;
            txtdemand.Text      = string.Empty;
            txtNumbering.Text   = string.Empty;
            txtSignplace.Text   = string.Empty;
            txtsupplier.Text    = string.Empty;
            dtpSigndate.Value   = DateTime.Now;

            _model = null;

            dataGridView1.Rows.Clear();

            dataGridView1.Rows.Insert(0, new DataGridViewRow());

            //新增带入

            bll = new FishBll.Bll.SalesRContractBll();
            DataTable queryTable = bll.getxxsqd(" a.Numbering='" + name + "' ");

            if (queryTable != null && queryTable.Rows.Count > 0)
            {
                dataGridView1.Rows.Clear();
                for (int i = 0; i < queryTable.Rows.Count; i++)
                {
                    int             idx = dataGridView1.Rows.Add();
                    DataGridViewRow row = dataGridView1.Rows[idx];
                    txtNumbering.Text              = queryTable.Rows[i]["Numbering"].ToString();
                    dtpSigndate.Value              = DateTime.Parse(queryTable.Rows[i]["Signdate"].ToString());
                    txtdemand.Text                 = queryTable.Rows[i]["demand"].ToString();
                    txtSignplace.Text              = queryTable.Rows[i]["Signplace"].ToString();
                    txtsupplier.Text               = queryTable.Rows[i]["supplier"].ToString();
                    txtcode.Text                   = queryTable.Rows[i]["code"].ToString();
                    row.Cells["product_id"].Value  = queryTable.Rows[i]["product_id"].ToString();
                    row.Cells["productname"].Value = queryTable.Rows[i]["productname"].ToString();
                    row.Cells["Funit"].Value       = queryTable.Rows[i]["Funit"].ToString();
                    row.Cells["Variety"].Value     = queryTable.Rows[i]["Variety"].ToString();
                    row.Cells["Quantity"].Value    = queryTable.Rows[i]["Quantity"].ToString();
                    row.Cells["unitprice"].Value   = queryTable.Rows[i]["unitprice"].ToString();
                    row.Cells["Amonut"].Value      = queryTable.Rows[i]["Amonut"].ToString();
                }
            }
            return(0);
        }
Beispiel #4
0
        public int Add(FishEntity.SalesRContractEntity model, List <FishEntity.productsituationEntity> modeList)
        {
            StringBuilder strsql = new StringBuilder();            Hashtable SQLString = new Hashtable();

            strsql.Append("insert into t_salesrcontract(Numbering,Signdate,Signplace,supplier,demand,createman,createtime,modifyman,modifytime,ContractCode)values(@Numbering,@Signdate,@Signplace,@supplier,@demand,@createman,@createtime,@modifyman,@modifytime,@ContractCode)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ContractCode", MySqlDbType.VarChar,   45),
                new MySqlParameter("@Numbering",    MySqlDbType.VarChar,   45),
                new MySqlParameter("@Signdate",     MySqlDbType.DateTime),
                new MySqlParameter("@Signplace",    MySqlDbType.VarChar,   45),
                new MySqlParameter("@supplier",     MySqlDbType.VarChar,   45),
                new MySqlParameter("@demand",       MySqlDbType.VarChar,   45),
                new MySqlParameter("@createman",    MySqlDbType.VarChar,   45),
                new MySqlParameter("@createtime",   MySqlDbType.DateTime),
                new MySqlParameter("@modifyman",    MySqlDbType.VarChar,   45),
                new MySqlParameter("@modifytime",   MySqlDbType.DateTime)
            };
            parameters[0].Value = model.ContractCode;
            parameters[1].Value = model.Numbering;
            parameters[2].Value = model.Signdate;
            parameters[3].Value = model.Signplace;
            parameters[4].Value = model.Supplier;
            parameters[5].Value = model.Demand;
            parameters[6].Value = model.Createman;
            parameters[7].Value = model.Createtime;
            parameters[8].Value = model.Modifyman;
            parameters[9].Value = model.Modifytime;
            SQLString.Add(strsql.ToString(), parameters);
            foreach (FishEntity.productsituationEntity list in modeList)
            {
                add_body(list, SQLString, strsql);
            }
            if (MySqlHelper.ExecuteSqlTran(SQLString))
            {
                strsql = new StringBuilder();
                strsql.AppendFormat("select id from t_SalesRContract where ContractCode='{0}' and Numbering='{1}'", model.ContractCode, model.Numbering);

                DataTable dt = MySqlHelper.Query(strsql.ToString()).Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    return(string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()) == true ? 0 : Convert.ToInt32(dt.Rows[0]["id"].ToString()));
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Beispiel #5
0
        public override int Modify()
        {
            _model = new FishEntity.SalesRContractEntity();
            GetSalesRContract();
            List <FishEntity.productsituationEntity> modelList = new List <FishEntity.productsituationEntity>();

            DataView(modelList);
            bll = new FishBll.Bll.SalesRContractBll();
            bool isok = bll.Update(_model, modelList);

            if (isok == true)
            {
                AddImages(_model);
                MessageBox.Show("保存成功!"); return(1);
            }
            return(1);
        }
Beispiel #6
0
        public override int Query( )
        {
            if (QueryForm == null)
            {
                QueryForm = new UIForms.FormSalesRContractQuery();
                QueryForm.StartPosition = FormStartPosition.CenterParent;
                QueryForm.ShowInTaskbar = false;
            }
            if (QueryForm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }
            _where = QueryForm.GetWhereCondition;
            bll    = new FishBll.Bll.SalesRContractBll();
            _model = new FishEntity.SalesRContractEntity();
            _model = bll.GetList(_where);
            if (_model != null)
            {
                SetSalesRContract();
                dataGridView1.Rows.Clear();
                GenerateBody();
            }
            else
            {
                MessageBox.Show("查无数据!");
            }

            //FormSalesTables form = new FormSalesTables();
            //form.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            //if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            //if (form.fish == null) return 1;
            //txtcode.Text = string.Empty;
            //txtcode.Text = form.fish.code;
            //dataGridView1.Rows.Clear();
            //GenerateContect();
            //if (result == true)
            //    GenerateBody();

            return(base.Query( ));
        }
Beispiel #7
0
        //void GenerateContect ( )
        //{
        //    result = _bll . Exist (txtNumbering. Text );
        //    if ( result == true )
        //    {
        //        _rolewhere += " Numbering= '" + txtNumbering.Text+"' ";
        //        if (FishEntity.Variable.User.roletype.Equals(FishEntity.Constant.Role_SalesMan))
        //        {
        //            _rolewhere += string.Format(" and createman='{0}' ", FishEntity.Variable.User.username);
        //        }
        //        FishEntity . SalesRequisitionEntity _list = _bll . GetList (_rolewhere);
        //        if ( _list == null )
        //            return;
        //        headSetValue ( _list );

        //    }
        //    else
        //        MessageBox . Show ( "编号:" + txtNumbering. Text + "不存在,请核实" );
        //}
        //void GenerateContectCode()
        //{
        //    result = _bll.ExistCode(txtNumbering.Text);
        //    if (result == true)
        //    {
        //        _rolewhere += " Numbering= '" + txtcode.Text + "' ";
        //        if (FishEntity.Variable.User.roletype.Equals(FishEntity.Constant.Role_SalesMan))
        //        {
        //            _rolewhere += string.Format(" and createman='{0}' ", FishEntity.Variable.User.username);
        //        }
        //        FishEntity.SalesRequisitionEntity _list = _bll.GetList(_rolewhere);
        //        if (_list == null)
        //            return;
        //        headSetValue(_list);

        //    }
        //    else
        //        MessageBox.Show("销售编号:" + txtcode.Text + "不存在,请核实");
        //}
        void GenerateContectNumbering()
        {
            bll    = new FishBll.Bll.SalesRContractBll();
            result = _bll.ExistCode(txtNumbering.Text);
            if (result == true)
            {
                _rolewhere += " Numbering= '" + txtNumbering.Text + "' ";
                if (FishEntity.Variable.User.roletype.Equals(FishEntity.Constant.Role_SalesMan))
                {
                    _rolewhere += string.Format(" and createman='{0}' ", FishEntity.Variable.User.username);
                }
                _model = new FishEntity.SalesRContractEntity();
                _model = bll.GetList(_rolewhere);
                if (_model == null)
                {
                    return;
                }
                SetSalesRContract();
            }
            //else
            //MessageBox.Show("销售编号:" + txtcode.Text + "不存在,请核实");
        }
Beispiel #8
0
        public static FishEntity.SalesRContractEntity DataRowToModel(DataRow row)
        {
            FishEntity.SalesRContractEntity model = new FishEntity.SalesRContractEntity();

            if (row != null)
            {
                if (row["Numbering"] != null && row["Numbering"].ToString() != "")
                {
                    model.Numbering = row["Numbering"].ToString();
                }
                if (row["ContractCode"] != null && row["ContractCode"].ToString() != "")
                {
                    model.ContractCode = row["ContractCode"].ToString();
                }
                if (row["demand"] != null && row["demand"].ToString() != "")
                {
                    model.Demand = row["demand"].ToString();
                }
                if (row["supplier"] != null && row["supplier"].ToString() != "")
                {
                    model.Supplier = row["supplier"].ToString();
                }
                if (row["Signplace"] != null && row["Signplace"].ToString() != "")
                {
                    model.Signplace = row["Signplace"].ToString();
                }
                if (row["Signdate"] != null && row["Signdate"].ToString() != "")
                {
                    model.Signdate = DateTime.Parse(row["Signdate"].ToString());
                }
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.Id = int.Parse(row["id"].ToString());
                }
            }
            return(model);
        }
Beispiel #9
0
 /// <summary>
 /// 编辑一单记录
 /// </summary>
 /// <param name="model"></param>
 /// <param name="modeList"></param>
 /// <returns></returns>
 public bool Update(FishEntity.SalesRContractEntity model, List <FishEntity.productsituationEntity> modeList)
 {
     return(Dao.Update(model, modeList));
 }
Beispiel #10
0
 /// <summary>
 /// 新建
 /// </summary>
 /// <param name="_model"></param>
 /// <param name="modeList"></param>
 /// <returns></returns>
 public int Add(FishEntity.SalesRContractEntity _model, List <FishEntity.productsituationEntity> modeList)
 {
     return(Dao.Add(_model, modeList));
 }
Beispiel #11
0
        /// <summary>
        /// 编辑一单记录
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modeList"></param>
        /// <returns></returns>
        public bool Update(FishEntity.SalesRContractEntity model, List <FishEntity.productsituationEntity> modeList)
        {
            Hashtable SQLString = new Hashtable();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_salesrcontract set ");
            strSql.Append("ContractCode=@ContractCode,");
            strSql.Append("Signdate=@Signdate,");
            strSql.Append("Signplace=@Signplace,");
            strSql.Append("supplier=@supplier,");
            strSql.Append("demand=@demand,");
            strSql.Append("modifyman=@modifyman,");
            strSql.Append("modifytime=@modifytime ");
            strSql.Append(" where id = @id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ContractCode", model.ContractCode),
                new MySqlParameter("@Signdate",     model.Signdate),
                new MySqlParameter("@Signplace",    model.Signplace),
                new MySqlParameter("@supplier",     model.Supplier),
                new MySqlParameter("@demand",       model.Demand),
                new MySqlParameter("@modifyman",    model.Modifyman),
                new MySqlParameter("@modifytime",   model.Modifytime),
                new MySqlParameter("@id",           model.Id),
            };
            SQLString.Add(strSql.ToString(), parameters);


            foreach (FishEntity.productsituationEntity list in modeList)
            {
                if (Exists(list.Numbering, list.Product_id) == false)
                {
                    add_body(list, SQLString, strSql);
                }
                else
                {
                    edit_body(list, SQLString, strSql);
                }
            }
            DataSet   ds = MySqlHelper.Query("SELECT product_id FROM t_productsituation WHERE code='" + model.ContractCode + "'" + " and Numbering='" + model.Numbering + "'");
            DataTable dt = ds.Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                FishEntity.productsituationEntity list = new FishEntity.productsituationEntity();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    model.Product_id = list.Product_id = dt.Rows[i]["product_id"].ToString();
                    list             = modeList.Find((k) =>
                    {
                        return(k.Product_id.Equals(model.Product_id));
                    });
                    if (list == null)
                    {
                        delete_body(model.Numbering, model.Product_id, SQLString, strSql);
                    }
                }
            }
            return(MySqlHelper.ExecuteSqlTran(SQLString));
        }