예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidatePage())
            {
                return;
            }

            if (CurrEditMode == eEditMode.新增)
            {
                if (this.SelFuelKind == null)
                {
                    return;
                }
                CmcsFuelKind entity = new CmcsFuelKind();
                entity.Code     = commonDAO.GetFuelKindNewChildCode(this.SelFuelKind.Code);
                entity.Name     = txt_FuelName.Text;
                entity.Sort     = dbi_Sequence.Value;
                entity.ParentId = this.SelFuelKind.Id;
                entity.IsStop   = chb_IsUse.Checked ? 0 : 1;
                Dbers.GetInstance().SelfDber.Insert <CmcsFuelKind>(entity);
            }
            else if (CurrEditMode == eEditMode.修改)
            {
                if (this.SelFuelKind == null)
                {
                    return;
                }

                //是否更新子节点状态
                if (this.SelFuelKind.IsStop != (chb_IsUse.Checked ? 0 : 1))
                {
                    if (MessageBoxEx.Show("是否将启用状态应用到子节点", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        commonDAO.UpdateFuelKindChildsIsUse(this.SelFuelKind.Id, chb_IsUse.Checked ? 0 : 1);
                    }
                }

                this.SelFuelKind.Name   = txt_FuelName.Text;
                this.SelFuelKind.Code   = txtFuelCode.Text;
                this.SelFuelKind.Sort   = dbi_Sequence.Value;
                this.SelFuelKind.IsStop = chb_IsUse.Checked ? 0 : 1;
                this.SelFuelKind.ReMark = txt_ReMark.Text;

                Dbers.GetInstance().SelfDber.Update <CmcsFuelKind>(this.SelFuelKind);
            }

            InitTree();
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidatePage())
            {
                return;
            }

            if (EditMode == eEditMode.新增)
            {
                if (this.SelFuelKind == null)
                {
                    return;
                }
                CmcsFuelKind entity = new CmcsFuelKind();
                entity.Code     = commonDAO.GetFuelKindNewChildCode(this.SelFuelKind.Code);
                entity.Name     = txt_FuelName.Text;
                entity.Sequence = dbi_Sequence.Value;
                entity.ParentId = this.SelFuelKind.Id;
                entity.IsStop   = chb_IsUse.Checked ? 0 : 1;
                entity.ReMark   = txt_ReMark.Text;

                Dbers.GetInstance().SelfDber.Insert <CmcsFuelKind>(entity);
            }
            else if (EditMode == eEditMode.修改)
            {
                if (this.SelFuelKind == null)
                {
                    return;
                }
                this.SelFuelKind.Name     = txt_FuelName.Text;
                this.SelFuelKind.Code     = txtFuelCode.Text;
                this.SelFuelKind.Sequence = dbi_Sequence.Value;
                this.SelFuelKind.IsStop   = chb_IsUse.Checked ? 0 : 1;
                this.SelFuelKind.ReMark   = txt_ReMark.Text;
                this.SelFuelKind.IsSynch  = 0;
                Dbers.GetInstance().SelfDber.Update <CmcsFuelKind>(this.SelFuelKind);
            }

            InitTree();
        }
예제 #3
0
        /// <summary>
        /// 同步集团数据
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="thirdDber"></param>
        /// <param name="output"></param>
        private void DownLoadData(TableOrView entity, OracleDapperDber thirdDber, Action <string, eOutputType> output)
        {
            //同步集团数据
            string sbSearch = "select ";

            foreach (var item in entity.PropertySetDetails)
            {
                sbSearch += string.Format("{0},", item.Source);
            }

            sbSearch  = sbSearch.Trim(',');
            sbSearch += string.Format(" from {0} ", entity.Source);

            if (!string.IsNullOrWhiteSpace(entity.TimeIntervalProperty))
            {
                int    intervalValue = 7;
                string configValue   = commonDAO.GetAppletConfigString("数据同步智仁接口", "获取集团数据时间间隔(天)");
                if (!string.IsNullOrWhiteSpace(configValue))
                {
                    Int32.TryParse(configValue, out intervalValue);
                }
                DateTime startTime = DateTime.Now.AddDays(-intervalValue);

                sbSearch += string.Format(" where {0}>=to_date('{1}','yyyy-MM-dd hh24:mi:ss')", entity.TimeIntervalProperty, startTime.ToString("yyyy-MM-dd HH:mm:ss"));
            }

            DataTable dt = thirdDber.ExecuteDataTable(sbSearch);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return;
            }

            Boolean ishavepk = entity.PropertySetDetails.Count(a => a.DesPrimaryKey != null && a.DesPrimaryKey.ToLower() == "true") > 0;

            foreach (DataRow item in dt.Rows)
            {
                //只有更新和新增操作
                string strChaXun = string.Format("select * from {0} where 1=1 ", entity.Destination);
                if (ishavepk)
                {
                    foreach (var pk in entity.PropertySetDetails.Where(a => a.DesPrimaryKey != null && a.DesPrimaryKey.ToLower() == "true"))
                    {
                        strChaXun += string.Format("and {0}='{1}' ", pk.Destination, item[pk.Source] == null ? "" : item[pk.Source].ToString());
                    }
                }
                else
                {
                    foreach (var pk in entity.PropertySetDetails)
                    {
                        strChaXun += string.Format("and {0}='{1}' ", pk.Destination, item[pk.Source] == null ? "" : item[pk.Source].ToString());
                    }
                }

                DataTable dtHaveData = SelfDber.ExecuteDataTable(strChaXun);
                if (dtHaveData == null || dtHaveData.Rows.Count <= 0)
                {
                    //新增
                    string insertSql = string.Format(@"insert into {0} (", entity.Destination);
                    string names     = "ID, CREATIONTIME, CREATORUSERID,LASTMODIFICATIONTIME,";
                    string values    = string.Format("'{0}', sysdate,1,sysdate,", Guid.NewGuid().ToString());

                    if (entity.Description == "矿点同步")
                    {
                        string code = commonDAO.GetMineNewChildCode("000");
                        if (!string.IsNullOrEmpty(code))
                        {
                            names  += "Code,";
                            values += "'" + code + "',";
                        }
                        names  += "Sort,";
                        values += commonDAO.GetMineSort() + ",";
                    }
                    else if (entity.Description == "煤种同步")
                    {
                        string code = commonDAO.GetFuelKindNewChildCode("000");
                        if (!string.IsNullOrEmpty(code))
                        {
                            names  += "Code,";
                            values += "'" + code + "',";
                        }
                        names  += "Sort,";
                        values += commonDAO.GetFuelKindSort() + ",";
                    }

                    if (!string.IsNullOrWhiteSpace(entity.IsSoftDelete) && entity.IsSoftDelete.ToLower() == "true")
                    {
                        names  += "ISDELETED,";
                        values += "0,";
                    }

                    if (!string.IsNullOrWhiteSpace(entity.TreeParentId))
                    {
                        names  += "parentid,";
                        values += string.Format("'{0}',", entity.TreeParentId);
                    }

                    foreach (var detail in entity.PropertySetDetails)
                    {
                        names  += string.Format("{0},", detail.Destination);
                        values += string.Format("'{0}',", item[detail.Source] == null ? "" : item[detail.Source].ToString());
                    }

                    if (!string.IsNullOrWhiteSpace(entity.IsHaveSyncTime) && entity.IsHaveSyncTime.ToLower() == "true")
                    {
                        names  += "SYNCTIME,";
                        values += "sysdate,";
                    }

                    insertSql += names.Trim(',') + ") values (" + values.Trim(',') + ")";
                    if (SelfDber.Execute(insertSql) > 0)
                    {
                        output(string.Format("接口取数【{0}】已同步,操作:新增", entity.Description), eOutputType.Normal);
                    }
                }
                else
                {
                    //更新
                    string updateSql = string.Format("update {0} set ", entity.Destination);

                    foreach (var detail in entity.PropertySetDetails)
                    {
                        updateSql += string.Format("{0}='{1}',", detail.Destination, item[detail.Source] == null ? "" : item[detail.Source].ToString());
                    }

                    if (!string.IsNullOrWhiteSpace(entity.IsHaveSyncTime) && entity.IsHaveSyncTime.ToLower() == "true")
                    {
                        updateSql += "SYNCTIME=sysdate,";
                    }

                    updateSql = updateSql.Trim(',') + string.Format(" where id='{0}'", dtHaveData.Rows[0]["ID"].ToString());
                    if (SelfDber.Execute(updateSql) > 0)
                    {
                        output(string.Format("接口取数【{0}】已同步,操作:更新", entity.Description), eOutputType.Normal);
                    }
                }
            }
        }