private static string CreateOpCode(string[] arr, string format, OP_TYPE type) { string newCode = string.Empty; if ((type == OP_TYPE.Type1) || (type == OP_TYPE.Type2)) { string rd = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(arr[1], @"\d+").Value), 2), 5); string rs = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(GetNumber(arr[2]), @"\d+").Value), 2), 5); string third_term = string.Empty; if (type == OP_TYPE.Type1) { third_term = ConstructCode(string.Empty, 12); if (arr.Length > 3) { third_term = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(arr[3], @"\d+").Value), 2), 12); } } else { third_term = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(arr[3], @"\d+").Value), 2), 5); } newCode = String.Format(format, rd, rs, third_term).Replace(" ", ""); } else { string rd = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(arr[1], @"\d+").Value), 2), 5); string rs = ConstructCode(Convert.ToString(Int32.Parse(Regex.Match(arr[2], @"\d+").Value), 2), 5); newCode = String.Format(format, "00000", rd, rs, "0000000").Replace(" ", ""); } return(newCode); }
private static string GenerateOpCode(string[] arr) { string format = string.Empty; OP_TYPE type = OP_TYPE.Type1; switch (arr[0].ToUpper()) { case "LB": format = LB; type = OP_TYPE.Type1; break; case "LH": format = LH; type = OP_TYPE.Type1; break; case "LW": format = LW; type = OP_TYPE.Type1; break; case "SB": format = SB; type = OP_TYPE.Type3; break; case "SH": format = SH; type = OP_TYPE.Type3; break; case "SW": format = SW; type = OP_TYPE.Type3; break; case "ADD": format = ADD; type = OP_TYPE.Type2; break; case "ADDI": format = ADDI; type = OP_TYPE.Type1; break; case "SLT": format = SLT; type = OP_TYPE.Type2; break; case "SLTI": format = SLTI; type = OP_TYPE.Type1; break; case "BEQ": format = BEQ; type = OP_TYPE.Type3; break; case "BNE": format = BNE; type = OP_TYPE.Type3; break; case "BLT": format = BLT; type = OP_TYPE.Type3; break; case "BGE": format = BGE; type = OP_TYPE.Type3; break; } return(CreateOpCode(arr, format, type)); }
private void ChangeFile(string file) { //打开文件 //解析文件 //替换文件 string content = ""; string ext = Path.GetExtension(file); content = ReadFile(file); if (content == "") { return; } string fileTagname = Path.GetFileName(file); if (ext.ToLower().EndsWith(".java") == true) { OP = OP_TYPE.JAVA; if (log_func == "") { log_func = "Log.d"; } content = JavaReplaceContent(content, fileTagname); } else if (ext.ToLower().EndsWith(".c") == true) { OP = OP_TYPE.C; if (log_func == "") { log_func = "printf"; } content = C_ReplaceContent(content, fileTagname); } else { return; } string filename = "content" + DateTime.Now.Ticks.ToString().Substring(7, 3) + ".txt"; if (checkBox1.Checked) { if (content.Length > 0) { try { System.IO.File.WriteAllText(file, content); } catch (Exception) { System.IO.File.WriteAllText("D:\\" + filename, content); MessageBox.Show("文件没有正确保存,临时存放到D:\\" + filename); } } } else { System.IO.File.WriteAllText("D:\\" + filename, content); } }
/// <summary> /// 保存 /// </summary> /// <returns></returns> public bool Save(OP_TYPE OpType) { ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log(); Guid log_djid = Guid.Empty; try { string sql = ""; InstanceForm.BDatabase.BeginTransaction(); if (OpType == OP_TYPE.新增项目) { //插入新纪录 sql = "insert into jc_hoitemdiction ( order_name,order_unit,order_type,default_usage,default_dept,py_code,wb_code,bz,FJSMBT,d_code)"; sql += " values ('" + _order_name + "','" + _order_unit + "'," + _order_type_id + ",'" + _usage + "'," + _default_exec_dept + ",'" + _py_code + "','" + _wb_code + "','" + bz + "'," + _fjsmbt.ToString() + ",'" + _d_code + "')"; object obj; InstanceForm.BDatabase.InsertRecord(sql, out obj); _order_id = Convert.ToInt32(obj); } if (OpType == OP_TYPE.更新项目) { sql = "update jc_hoitemdiction set order_name='" + _order_name + "',order_unit='" + _order_unit + "',order_type=" + _order_type_id + ",default_usage='" + _usage + "',default_dept=" + _default_exec_dept + ",py_code='" + _py_code + "',wb_code='" + _wb_code + "',bz='" + bz + "',FJSMBT=" + _fjsmbt.ToString() + ",d_code='" + _d_code + "'"; sql += " where order_id=" + _order_id; InstanceForm.BDatabase.DoCommand(sql); } //执行科室 sql = "delete from jc_hoi_dept where order_id = " + _order_id; InstanceForm.BDatabase.DoCommand(sql); for (int i = 0; i < _execdeptList.Count; i++) { sql = "insert into jc_hoi_dept ( order_id,exec_dept ) values (" + _order_id + "," + ((TrasenFrame.Classes.Department)_execdeptList[i]).DeptId + ")"; InstanceForm.BDatabase.DoCommand(sql); } //与收费项目对应 sql = "delete from jc_hoi_hdi where hoitem_id=" + _order_id; InstanceForm.BDatabase.DoCommand(sql); if (_match_type == 1) { if (_charge_item_id != 0) { sql = "insert into jc_hoi_hdi ( hoitem_id,hditem_id,num,tc_flag,tcid ) values (" + _order_id + "," + _charge_item_id + "," + _item_exec_num + ",1," + _charge_item_id + ")"; InstanceForm.BDatabase.DoCommand(sql); } } else { if (_charge_item_id != 0) { sql = "insert into jc_hoi_hdi ( hoitem_id,hditem_id,num,tc_flag,tcid ) values (" + _order_id + "," + _charge_item_id + "," + _item_exec_num + ",0,-1)"; InstanceForm.BDatabase.DoCommand(sql); } } //同步更新检查化验表 sql = "delete from jc_jc_item where yzid=" + _order_id; InstanceForm.BDatabase.DoCommand(sql); sql = "delete from jc_assay where yzid=" + _order_id; InstanceForm.BDatabase.DoCommand(sql); if (this.isJCorHy == 1) { sql = "insert into jc_jc_item(yzid,jclxid) values (" + _order_id + "," + jclx + ")"; InstanceForm.BDatabase.DoCommand(sql); } else if (this.isJCorHy == 2) { sql = "insert into jc_assay(yzid,bbid,hylxid) values (" + _order_id + "," + sample + ", " + hylx + ")"; InstanceForm.BDatabase.DoCommand(sql); } string _bz = ""; if (OpType == OP_TYPE.新增项目) { _bz = "新增医嘱项目:【" + _order_name + "】"; } else { _bz = "修改医嘱项目:【" + _order_name + "】"; } ts.Save_log(ts_HospData_Share.czlx.jc_医嘱项目修改, _bz, "jc_hoitemdiction", "order_id", _order_id.ToString(), InstanceForm._menuTag.Jgbm, 0, "", out log_djid, InstanceForm.BDatabase); InstanceForm.BDatabase.CommitTransaction(); } catch (Exception err) { InstanceForm.BDatabase.RollbackTransaction(); throw err; } //三院数据处理 try { string errtext = ""; ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_医嘱项目修改, InstanceForm.BDatabase); if (ty.Bzx == 1 && log_djid != Guid.Empty) { ts.Pexec_log(log_djid, InstanceForm.BDatabase, out errtext); } if (errtext != "") { throw new Exception(errtext); } } catch (System.Exception err) { MessageBox.Show("保存成功 " + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); }