Exemplo n.º 1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                GBJCLRDts MasterEntity = (GBJCLRDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Dev_GBJCLRDts WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID) + " AND MainID=" + SysString.ToDBString(MasterEntity.MainID);
                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(Sql);
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(Sql);
                }

                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 检验字段值是否已存在
        /// </summary>
        /// <param name="p_TableName">表名</param>
        /// <param name="p_FieldName">字段名</param>
        /// <param name="p_FieldValue">字段值</param>
        /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param>
        /// <param name="p_KeyValue">主键值</param>
        /// <param name="p_sqlTrans"></param>
        /// <returns></returns>
        private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans)
        {
            GBJCLRDts entity = (GBJCLRDts)p_BE;
            bool      ret    = false;
            string    sql    = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, GBJCLRDts.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID);
            DataTable dt     = p_sqlTrans.Fill(sql);

            if (dt.Rows.Count != 0)
            {
                ret = true;
            }

            return(ret);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="p_BE">要删除的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         GBJCLRDts    entity  = (GBJCLRDts)p_BE;
         GBJCLRDtsCtl control = new GBJCLRDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 新增(传入事务处理)
 /// </summary>
 /// <param name="p_BE">要新增的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         GBJCLRDts    entity  = (GBJCLRDts)p_BE;
         GBJCLRDtsCtl control = new GBJCLRDtsCtl(sqlTrans);
         //entity.ID=(int)EntityIDTable.GetID((long)SysEntity.Dev_GBJCDts,sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Dev_GBJCLRDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private GBJCLRDts[] EntityDtsGet()
        {
            int Num = 0;

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (SysConvert.ToString(gridView1.GetRowCellValue(i, "GBCode")) != string.Empty)
                {
                    Num++;
                }
            }
            GBJCLRDts[] entitydts = new GBJCLRDts[Num];
            int         index     = 0;

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (SysConvert.ToString(gridView1.GetRowCellValue(i, "GBCode")) != string.Empty)
                {
                    entitydts[index]    = new GBJCLRDts();
                    entitydts[index].ID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ID"));;
                    entitydts[index].SelectByID();
                    entitydts[index].MainID = HTDataID;
                    entitydts[index].Seq    = i + 1;


                    entitydts[index].GBCode       = SysConvert.ToString(gridView1.GetRowCellValue(i, "GBCode"));       //挂板条码
                    entitydts[index].GBStatusID   = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "GBStatusID"));    //挂板状态
                    entitydts[index].JCTime       = SysConvert.ToDateTime(gridView1.GetRowCellValue(i, "JCTime"));     //借出时间
                    entitydts[index].GHTime       = SysConvert.ToDateTime(gridView1.GetRowCellValue(i, "GHTime"));     //归还时间
                    entitydts[index].GHOPID       = SysConvert.ToString(gridView1.GetRowCellValue(i, "GHOPID"));       //归还操作人
                    entitydts[index].LYFlag       = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "LYFlag"));        //留样标志
                    entitydts[index].LYVendorID   = SysConvert.ToString(gridView1.GetRowCellValue(i, "LYVendorID"));   //留样客户编码
                    entitydts[index].LYVendorName = SysConvert.ToString(gridView1.GetRowCellValue(i, "LYVendorName")); //留样客户名称

                    index++;
                }
            }
            return(entitydts);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 扫描条码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtScanCode_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (HTFormStatus != FormStatus.查询)
                    {
                        this.ShowMessage("请先保存再扫描");
                        txtScanCode.Text = string.Empty;
                        return;
                    }

                    if (HTDataSubmitFlag != (int)YesOrNo.No)
                    {
                        this.ShowMessage("只有未提交才允许扫描");
                        txtScanCode.Text = string.Empty;
                        return;
                    }

                    string ScanCode = txtScanCode.Text.Trim();
                    txtScanCode.Text = string.Empty;
                    if (ScanCode == string.Empty)
                    {
                        this.ShowMessage("请扫描挂板条形码");
                        return;
                    }
                    if (!checkScanCode(ScanCode))
                    {
                        this.ShowMessage("挂板条形码不存在,请检查后重新扫描");
                        return;
                    }
                    if (!CheckDouble(ScanCode))
                    {
                        this.ShowMessage("请勿重复扫描");
                        return;
                    }
                    //if (!checkSameGB(ScanCode)) //深圳那边提出,剪样后可以重复扫描,sc 2013.12.18
                    //{
                    //    return;
                    //}
                    //if (!checkScanStatus(ScanCode))
                    //{
                    //    return;
                    //}

                    //插入明细数据
                    GBJCLRDts     entity = new GBJCLRDts();
                    GBJCLRDtsRule rule   = new GBJCLRDtsRule();
                    entity.MainID       = this.HTDataID;
                    entity.Seq          = SelectSeq(HTDataID);
                    entity.GBCode       = ScanCode;             //挂板条码
                    entity.GBStatusID   = (int)EnumGBStatus.借出; //挂板状态
                    entity.JCTime       = DateTime.Now.Date;    //借出时间
                    entity.GHOPID       = "";                   //归还操作人
                    entity.LYVendorID   = "";                   //留样客户编码
                    entity.LYVendorName = "";                   //留样客户名称
                    rule.RAdd(entity);
                    BindGrid();
                    ProcessGrid.GridViewFocus(gridView1, new string[1] {
                        "GBCode"
                    }, new string[1] {
                        ScanCode
                    });
                    txtScanCode.Focus();
                }
            }
            catch (Exception E)
            {
                this.ShowMessage(E.Message);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     GBJCLRDts entity = (GBJCLRDts)p_BE;
 }
Exemplo n.º 8
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                GBJCLRDts MasterEntity = (GBJCLRDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Dev_GBJCLRDts(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("MainID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ",");
                MasterField.Append("Seq" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ",");
                MasterField.Append("GBCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GBCode) + ",");
                MasterField.Append("GBStatusID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GBStatusID) + ",");
                MasterField.Append("JCTime" + ",");
                if (MasterEntity.JCTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.JCTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("GHTime" + ",");
                if (MasterEntity.GHTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.GHTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("GHOPID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GHOPID) + ",");
                MasterField.Append("LYFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.LYFlag) + ",");
                MasterField.Append("LYVendorID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.LYVendorID) + ",");
                MasterField.Append("LYVendorName" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.LYVendorName) + ")");



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                GBJCLRDts MasterEntity = (GBJCLRDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Dev_GBJCLRDts SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ",");
                UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ",");
                UpdateBuilder.Append(" GBCode=" + SysString.ToDBString(MasterEntity.GBCode) + ",");
                UpdateBuilder.Append(" GBStatusID=" + SysString.ToDBString(MasterEntity.GBStatusID) + ",");

                if (MasterEntity.JCTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    UpdateBuilder.Append(" JCTime=" + SysString.ToDBString(MasterEntity.JCTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" JCTime=null,");
                }


                if (MasterEntity.GHTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    UpdateBuilder.Append(" GHTime=" + SysString.ToDBString(MasterEntity.GHTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" GHTime=null,");
                }

                UpdateBuilder.Append(" GHOPID=" + SysString.ToDBString(MasterEntity.GHOPID) + ",");
                UpdateBuilder.Append(" LYFlag=" + SysString.ToDBString(MasterEntity.LYFlag) + ",");
                UpdateBuilder.Append(" LYVendorID=" + SysString.ToDBString(MasterEntity.LYVendorID) + ",");
                UpdateBuilder.Append(" LYVendorName=" + SysString.ToDBString(MasterEntity.LYVendorName));

                UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID) + " AND MainID=" + SysString.ToDBString(MasterEntity.MainID));



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAddLR(int HTDataID, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "SELECT ID FROM Dev_GBJCLR WHERE DID=" + SysString.ToDBString(HTDataID);
                if (sqlTrans.Fill(sql).Rows.Count > 0)
                {
                    throw new BaseException("已经同步,请撤销后再同步");
                }

                GBJC entity = new GBJC(sqlTrans);
                entity.ID = HTDataID;
                entity.SelectByID();

                sql  = "SELECT * FROM Dev_GBJCDts WHERE MainID=" + SysString.ToDBString(HTDataID);
                sql += " AND ISNULL(LYVendorID,'')<>''";
                DataTable dt = sqlTrans.Fill(sql);

                DataTable dtVendor = new DataTable();
                dtVendor.Columns.Add("VendorID", typeof(string));
                dtVendor.Columns.Add("GBCode", typeof(string));

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string   VendorIDStr = SysConvert.ToString(dt.Rows[i]["LYVendorID"]);
                    string[] VendorID    = VendorIDStr.Split(',');
                    for (int j = 0; j < VendorID.Length; j++)
                    {
                        DataRow dr = dtVendor.NewRow();
                        dr["VendorID"] = VendorID[j].ToString();
                        dr["GBCode"]   = SysConvert.ToString(dt.Rows[i]["GBCode"]);
                        dtVendor.Rows.Add(dr);
                    }
                }

                ArrayList list = new ArrayList();
                for (int i = 0; i < dtVendor.Rows.Count; i++)
                {
                    string VendorID = SysConvert.ToString(dtVendor.Rows[i]["VendorID"]);
                    bool   Find     = false;
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (VendorID == list[j].ToString())
                        {
                            Find = true;
                        }
                    }
                    if (!Find)
                    {
                        list.Add(VendorID);
                    }
                }

                for (int i = 0; i < list.Count; i++)
                {
                    DataRow[] drVendor = dtVendor.Select(" VendorID=" + SysConvert.ToString(list[i]));

                    FormNoControlRule frule    = new FormNoControlRule();
                    GBJCLRRule        rule     = new GBJCLRRule();
                    GBJCLR            entityLR = new GBJCLR();
                    entityLR.FormNo     = frule.RGetFormNo((int)FormNoControlEnum.挂板借出录入单号, sqlTrans);
                    entityLR.DID        = HTDataID;
                    entityLR.DNo        = entity.FormNo;
                    entityLR.MakeDate   = entity.MakeDate;
                    entityLR.MakeOPID   = entity.MakeOPID;
                    entityLR.SaleOPID   = entity.SaleOPID;
                    entityLR.VendorID   = list[i].ToString();
                    entityLR.SubmitFlag = 1;
                    entityLR.Remark     = "自动回填,回填单号:" + entity.FormNo + ",日期:" + entity.MakeDate.ToString("yyyy-MM-dd");
                    rule.RAdd(entityLR, sqlTrans);

                    frule.RAddSort((int)FormNoControlEnum.挂板借出录入单号, sqlTrans);

                    for (int j = 0; j < drVendor.Length; j++)
                    {
                        GBJCLRDtsRule DRule     = new GBJCLRDtsRule();
                        GBJCLRDts     entityDts = new GBJCLRDts(sqlTrans);
                        entityDts.MainID = entityLR.ID;
                        entityDts.Seq    = 1;
                        entityDts.GBCode = SysConvert.ToString(drVendor[j]["GBCode"]);
                        entityDts.JCTime = entity.MakeDate;
                        entityDts.LYFlag = 1;
                        DRule.RAdd(entityDts, sqlTrans);
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }