/// <summary>
        /// 加载数据同时保存数据到指定位置
        /// </summary>
        /// <param name="obj"></param>
        private void AddData(FarPoint.Win.Spread.FpSpread obj)
        {
            wait = new WaitDialogForm("", "正在加载数据, 请稍候...");
            try
            {
                //打开Excel表格
                //清空工作表
                fpSpread1.Sheets.Clear();
                obj.OpenExcel(System.Windows.Forms.Application.StartupPath + "\\xls\\中压配电网分析.xls");
                PF.SpreadRemoveEmptyCells(obj);
                //this.AddCellChanged();
                //this.barEditItem2.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                //S4_2_1.AddBarEditItems(this.barEditItem2, this.barEditItem1, this);
            }
            catch (System.Exception e)
            {
                //如果打开出错则重新生成并保存
                LoadData();
                //判断文件夹是否存在,不存在则创建
                if (!Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\xls"))
                {
                    Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\xls");
                }
                //保存EXcel文件
                obj.SaveExcel(System.Windows.Forms.Application.StartupPath + "\\xls\\中压配电网分析.xls", FarPoint.Excel.ExcelSaveFlags.NoFlagsSet);
                // 定义要使用的Excel 组件接口
                // 定义Application 对象,此对象表示整个Excel 程序
                Microsoft.Office.Interop.Excel.Application excelApp = null;
                // 定义Workbook对象,此对象代表工作薄
                Microsoft.Office.Interop.Excel.Workbook workBook;
                // 定义Worksheet 对象,此对象表示Execel 中的一张工作表
                Microsoft.Office.Interop.Excel.Worksheet ws = null;
                Microsoft.Office.Interop.Excel.Range range = null;
                excelApp = new Microsoft.Office.Interop.Excel.Application();
                string filename = System.Windows.Forms.Application.StartupPath + "\\xls\\中压配电网分析.xls";
                workBook = excelApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                for (int i = 1; i <= workBook.Worksheets.Count; i++)
                {

                    ws = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Worksheets[i];
                    //取消保护工作表
                    ws.Unprotect(Missing.Value);
                    //有数据的行数
                    int row = ws.UsedRange.Rows.Count;
                    //有数据的列数
                    int col = ws.UsedRange.Columns.Count;
                    //创建一个区域
                    range = ws.get_Range(ws.Cells[1, 1], ws.Cells[row, col]);
                    //设区域内的单元格自动换行
                    range.WrapText = true;
                    //保护工作表
                    ws.Protect(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                }
                //保存工作簿
                workBook.Save();
                //关闭工作簿
                excelApp.Workbooks.Close();
            }
            wait.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool SaveFile(byte[] byt,string type)
        {
            bool result = false;
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "文件类型|*" + type;
            if (sfd.ShowDialog() == DialogResult.OK)
            {

                WaitDialogForm wait = new WaitDialogForm("", "正在下载数据, 请稍候...");
                try
                {
                    GetFile(byt, sfd.FileName);
                    wait.Close();
                    if (MsgBox.ShowAskMessageBox("下载已完成,是否打开文件?") == DialogResult.OK)
                    {
                        try
                        {
                            System.Diagnostics.Process.Start(sfd.FileName);
                        }
                        catch { System.Diagnostics.Process.Start(sfd.FileName); }
                    }

                }
                catch
                {
                    wait.Close();
                }
            }
            return result;
        }
Ejemplo n.º 3
0
 public FileReadDV(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, string con, StringBuilder dianYaResult)
 {
     this.projectSUID = projectSUID;
     this.projectid = projectid;
     this.dulutype = dulutype;
     this.ratecaplity = ratecaplity;
     this.wf = wf;
     this.con = con;
     this.dianYaResult = dianYaResult;
 }
Ejemplo n.º 4
0
 public FileReadV(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, bool shortiflag, StringBuilder duanResult)
 {
     this.projectSUID = projectSUID;
     this.projectid = projectid;
     this.dulutype = dulutype;
     this.ratecaplity = ratecaplity;
     this.wf = wf;
     this.shortiflag = shortiflag;
     this.duanResult = duanResult;
 }
Ejemplo n.º 5
0
 public bool showLoading(string message)
 {
     try
     {
         dlg = new DevExpress.Utils.WaitDialogForm(message, "โปรแกรมกำลังทำงาน");
         dlg.Show();
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 6
0
 public bool ValidateConnection(XlsFileConnection conn, string fileNamePath, WaitDialogForm wait)
 {
     if (conn.Open() == null)
     {
         if (wait != null) wait.Close();
         if (conn.ConnectionError == XlsFileErrorCode.NOT_EXCEL_FORMATED)
         {
             HelpMsgBox.ShowNotificationMessage("Tập tin \"" + fileNamePath + "\" không phải định dạng excel!");
         }
         else if (conn.ConnectionError == XlsFileErrorCode.PASSWORD_PROTECTED)
         {
             HelpMsgBox.ShowNotificationMessage("Tập tin \"" + new FileInfo(fileNamePath).Name + "\" đã được bảo vệ bằng mật khẩu!");
         }
         else
         {
             HelpMsgBox.ShowNotificationMessage("Truy cập vào tập tin \"" + fileNamePath + "\" không thành công!");
         }
         return false;
     }
     return true;
 }
Ejemplo n.º 7
0
 public WaitingMsg(string title, string caption, XtraForm main)
 {
     main.Shown += new EventHandler(this.end);
     this.wait   = new WaitDialogForm(caption, title, new Size(250, 50), main);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            wait = new WaitDialogForm("", "正在更新数据, 请稍候...");
            ////由于SheetView已经没有了所以移除SheetView
            //MessageBox.Show(fpSpread1.Sheets[0].SheetName);
            //===================================================
            FarPoint.Win.Spread.SheetView obj = null;
            //由于更新数据时间太长需要建个空表做初始界面
            FarPoint.Win.Spread.SheetView fpSpread1_SheetN = new FarPoint.Win.Spread.SheetView();
            fpSpread1.Sheets.Add(fpSpread1_SheetN);
            obj = fpSpread1.ActiveSheet;
            fpSpread1.ActiveSheet = fpSpread1_SheetN;
            //PF.CreateSheet(this, fpSpread1, "kk");
            SheetIndex = fpSpread1.ActiveSheetIndex;//记住当前的SheetView的索引值

            //fpSpread1.ActiveSheet=fpSpread1.Sheets[fpSpread1.Sheets.Count-1];//把当前界面给空表
            PF.RemoveSheetView(this.fpSpread1, (fpSpread1.Sheets.Count - 1));//清空所有行列

            //this.fpSpread1.Sheets.Clear();
            IsCreateSheet = false;

            S_30.SetSheet_30Title(this, fpSpread1.Sheets[0], "附表30 本地区“十二五”规划项目资金需求表 ");

            //newwait.Close();
            IsCreateSheet = true;
            fpSpread1.ActiveSheet = obj;//fpSpread1.Sheets[SheetIndex];//把以前显示的界面在显示出来

            //if (obj.SheetName == "附表10 铜陵县中压线路“N-1”分析" || obj.SheetName == "附表11 铜陵县110kV及35kV变电站主变故障或检修“N-1”通过情况")
            //{
            //    this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            //}
            //删除临时SheetView
            //fpSpread1.Sheets.Remove(fpSpread1.Sheets[fpSpread1.Sheets.Count - 1]);
            fpSpread1.Sheets.Remove(fpSpread1_SheetN);
            //MessageBox.Show("更新数据完成!");
            wait.Close();
        }
Ejemplo n.º 9
0
        private void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm wait = null;
            wait = new WaitDialogForm("", "正在保存数据, 请稍候...");
            //判断文件夹xls是否存在,不存在则创建
            if (!Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\xls"))
            {
                Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\xls");
            }
            try
            {
                //保存excel文件
                fpSpread1.SaveExcel(System.Windows.Forms.Application.StartupPath + "\\xls\\PDWXZ"+year+".xls");
                //以下是打开文件设表格自动换行

                // 定义要使用的Excel 组件接口
                // 定义Application 对象,此对象表示整个Excel 程序
                Microsoft.Office.Interop.Excel.Application excelApp = null;
                // 定义Workbook对象,此对象代表工作薄
                Microsoft.Office.Interop.Excel.Workbook workBook;
                // 定义Worksheet 对象,此对象表示Execel 中的一张工作表
                Microsoft.Office.Interop.Excel.Worksheet ws = null;
                Microsoft.Office.Interop.Excel.Range range = null;
                excelApp = new Microsoft.Office.Interop.Excel.Application();
                string filename = System.Windows.Forms.Application.StartupPath + "\\xls\\PDWXZ" + year + ".xls";
                workBook = excelApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                for (int i = 1; i <= workBook.Worksheets.Count; i++)
                {

                    ws = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Worksheets[i];
                    //取消保护工作表
                    ws.Unprotect(Missing.Value);
                    //有数据的行数
                    int row = ws.UsedRange.Rows.Count;
                    //有数据的列数
                    int col = ws.UsedRange.Columns.Count;
                    //创建一个区域
                    range = ws.get_Range(ws.Cells[1, 1], ws.Cells[row, col]);
                    //设区域内的单元格自动换行
                    range.WrapText = true;
                    //保护工作表
                    ws.Protect(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                }
                //保存工作簿
                workBook.Save();
                //关闭工作簿
                excelApp.Workbooks.Close();
                wait.Close();
                MsgBox.Show("保存成功");
            }
            catch (System.Exception ee)
            {
                wait.Close();
                MsgBox.Show("保存错误!确定您安装有Office Excel,或者关闭所有Excel文件重试");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_query_Click(object sender, EventArgs e)
        {
            try
            {
                //SetWaitDialogCaption("请稍候正在查询...");
                m_WaitDialog = new WaitDialogForm("正在查询相应记录...", "请稍候");
                //门急诊诊断代码
                string inDiag = this.lookUpEditorInDiag.CodeValue;
                //出院诊断代码
                string outDiag = this.lookUpEditorOutDiag.CodeValue;
                //手术代码
                string   oper      = this.lookUpEditorOper.CodeValue;
                string   tablename = DataAccess.GetConfigValueByKey("AutoScoreMainpage");
                string[] mainpage  = tablename.Split(',');
                if (this.dateEdit_begin.DateTime > this.dateEdit_end.DateTime)
                {
                    MessageBox.Show("起始时间不能大于结束时间");
                    HideWaitDialog();
                    return;
                }
                string begin_time = this.dateEdit_begin.DateTime.ToString("yyyy-MM-dd") + " 00:00:00";
                string end_time   = this.dateEdit_end.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";//.AddDays(1)
                string sqlText    = SQLUtil.sql_QueryDiagOperRecord;
                string valueStr   = DrectSoft.Service.DS_SqlService.GetConfigValueByKey("AutoScoreMainpage");
                if (valueStr.ToLower().Contains("iem_mainpage_diagnosis_sx"))
                {
                    sqlText = SQLUtil.sql_QueryDiagOperRecord_ZY;
                }
                string outdiagspliter = string.Empty;//根据传入出院诊断条件将查询条件拼接进去(后期建议改为存储过程实现)add by ywk
                string indiagspliter  = string.Empty;
                string operspliter    = string.Empty;
                string menjidiag      = "  diag1.name";
                string outdiagname    = string.Empty;
                string admitdiagname  = string.Empty;
                if (string.IsNullOrEmpty(outDiag)) //出院诊断为空说明此不要
                {
                    outdiagspliter = "  ";         //查有
                    outdiagname    = "";
                }
                else//输入条件
                {
                    outdiagspliter = string.Format(" and  diag.diagnosis_code = '{0}'", outDiag);
                    outdiagname    = string.Format("temp1.OUTDIAG ='{0}' and ", lookUpEditorOutDiag.Text.Trim());
                }
                if (string.IsNullOrEmpty(inDiag))//门急诊诊断为空
                {
                    indiagspliter = string.Format("inner join diagnosis diag1 on imd.diagnosis_code = diag1.icd and diag1.valid=1   and imd.DIAGNOSIS_TYPE_ID=13", inDiag);
                    admitdiagname = "";
                    // menjidiag = "''  ";
                }
                else
                {
                    //menjidiag = " diag1.name ";
                    admitdiagname = string.Format("diag1.name='{0}' and ", lookUpEditorInDiag.Text.Trim());
                    indiagspliter = string.Format("left join diagnosis diag1 on imd.diagnosis_code = diag1.icd and diag1.valid=1   and imd.DIAGNOSIS_TYPE_ID=13 and imd.diagnosis_code = '{0}'", inDiag);
                }
                if (string.IsNullOrEmpty(oper))
                {
                    oper = " ";
                }
                else
                {
                    oper = string.Format(" and oper.operation_code='{0}'", oper);
                }

                DataTable dt = m_app.SqlHelper.ExecuteDataTable(string.Format(sqlText, indiagspliter, outdiagspliter, oper, begin_time, end_time, mainpage[0], mainpage[3], mainpage[2], menjidiag, outdiagname, admitdiagname));

                ImpressDataSet(ref dt, "NOOFINPAT", "OutDiag");

                this.gridControlRecord.DataSource = dt;

                if (valueStr.ToLower().Contains("iem_mainpage_diagnosis_sx"))
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (string.IsNullOrEmpty(dr["mzzyzd_name"].ToString()))
                        {
                            dr["ADMITDIAG"] = dr["mzxyzd_name"].ToString();
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(dr["mzxyzd_name"].ToString()))
                            {
                                dr["ADMITDIAG"] = dr["mzzyzd_name"].ToString();
                            }
                            else
                            {
                                dr["ADMITDIAG"] = dr["mzzyzd_name"].ToString() + "," + dr["mzxyzd_name"].ToString();
                            }
                        }
                    }
                }
                HideWaitDialog();
                this.labPatCount.Text = dt.Rows.Count.ToString();
                if (dt == null || dt.Rows.Count == 0)
                {
                    MessageBox.Show("没有符合条件的记录");
                    this.gridControlRecord.DataSource = null;
                    return;
                }
            }
            catch (Exception ex)
            {
                MyMessageBox.Show(1, ex);
            }
        }
Ejemplo n.º 11
0
        public void acc_gl()
        {
            string str = "ACCGL_" + Class6.smethod_0(SystemInformation.ComputerName);

            new FrmGetDates().ShowDialog();
            if (Class7.IsInputDate)
            {
                DataSet        set;
                WaitDialogForm form = new WaitDialogForm();
                form.Caption = "Xin đợi một ch\x00fat ....";
                try
                {
                    this.string_2           = "CREATE TABLE " + str + "([account_id] [nchar](9) ,[name] [nvarchar](200) NULL,[mof_gl] [nchar](4) NULL,[beg_debit] [numeric](18, 2) DEFAULT ((0)),[beg_credit] [numeric](18, 2) DEFAULT ((0)),[db_amount] [numeric](18, 2) DEFAULT ((0)),[cr_amount] [numeric](18, 2) DEFAULT ((0)),[end_debit] [numeric](18, 2) DEFAULT ((0)),[end_credit] [numeric](18, 2) DEFAULT ((0)),[sumdebit] [numeric](18, 2) DEFAULT ((0)),[sumcredit] [numeric](18, 2) DEFAULT ((0))) ";
                    this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                    using (set = new DataSet())
                    {
                        this.oleDbDataAdapter_0.Fill(set);
                        this.oleDbConnection_0.Close();
                    }
                }
                catch (Exception)
                {
                    this.string_2           = "DELETE FROM " + str;
                    this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                    using (set = new DataSet())
                    {
                        this.oleDbDataAdapter_0.Fill(set);
                        this.oleDbConnection_0.Close();
                    }
                }
                this.string_2           = "INSERT INTO " + str + "(account_id, name, mof_gl) SELECT account_id, name, mof_gl from tblAccount";
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                using (set = new DataSet())
                {
                    this.oleDbDataAdapter_0.Fill(set);
                    this.oleDbConnection_0.Close();
                }
                this.string_2           = string.Concat(new object[] { "select account_id, db_amount, cr_amount from tblAccTrans where status = 1 and (tran_date between '", Class7.dateTimeFrom, "' and '", Class7.dateTimeTo, "') " });
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                DataTable dataTable = new DataTable();
                this.oleDbDataAdapter_0.Fill(dataTable);
                foreach (DataRow row in dataTable.Rows)
                {
                    this.string_2           = string.Concat(new object[] { "update ", str, " set db_amount = db_amount + ", row["db_amount"], ", cr_amount = cr_amount + ", row["cr_amount"], " where account_id = '", row["account_id"], "'" });
                    this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                    using (set = new DataSet())
                    {
                        this.oleDbDataAdapter_0.Fill(set);
                        this.oleDbConnection_0.Close();
                        continue;
                    }
                }
                this.string_2           = "select account_id, SUM(cr_amount) - SUM(db_amount) AS beg_amt from tblAccTrans where status = 1 and tran_date <= '" + Class7.dateTimeFrom + "' GROUP BY account_id ";
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                DataTable table3 = new DataTable();
                this.oleDbDataAdapter_0.Fill(table3);
                foreach (DataRow row in table3.Rows)
                {
                    if (Class7.smethod_2(row["beg_amt"]) < 0.0)
                    {
                        this.string_2           = string.Concat(new object[] { "update ", str, " set beg_debit = ABS(", row["beg_amt"], ") where account_id = '", row["account_id"], "'" });
                        this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                        using (set = new DataSet())
                        {
                            this.oleDbDataAdapter_0.Fill(set);
                            this.oleDbConnection_0.Close();
                            continue;
                        }
                    }
                    this.string_2           = string.Concat(new object[] { "update ", str, " set beg_credit = ", row["beg_amt"], " where account_id = '", row["account_id"], "'" });
                    this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                    using (set = new DataSet())
                    {
                        this.oleDbDataAdapter_0.Fill(set);
                        this.oleDbConnection_0.Close();
                        continue;
                    }
                }
                this.string_2           = "select account_id, (cr_amount + beg_credit) - (db_amount + beg_debit) AS end_amt from " + str;
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                DataTable table2 = new DataTable();
                this.oleDbDataAdapter_0.Fill(table2);
                foreach (DataRow row in table2.Rows)
                {
                    if (Class7.smethod_2(row["end_amt"]) < 0.0)
                    {
                        this.string_2           = string.Concat(new object[] { "update ", str, " set end_debit = ABS(", row["end_amt"], ") where account_id = '", row["account_id"], "'" });
                        this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                        using (set = new DataSet())
                        {
                            this.oleDbDataAdapter_0.Fill(set);
                            this.oleDbConnection_0.Close();
                            continue;
                        }
                    }
                    this.string_2           = string.Concat(new object[] { "update ", str, " set end_credit =", row["end_amt"], " where account_id = '", row["account_id"], "'" });
                    this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                    using (set = new DataSet())
                    {
                        this.oleDbDataAdapter_0.Fill(set);
                        this.oleDbConnection_0.Close();
                        continue;
                    }
                }
                this.string_2           = "delete from " + str + " where beg_debit + beg_credit + db_amount + cr_amount + end_debit + end_credit = 0";
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                using (set = new DataSet())
                {
                    this.oleDbDataAdapter_0.Fill(set);
                    this.oleDbConnection_0.Close();
                }
                form.Close();
                new acc_gl().ShowPreviewDialog();
                this.string_2           = "DROP TABLE " + str;
                this.oleDbDataAdapter_0 = new OleDbDataAdapter(this.string_2, this.oleDbConnection_0);
                using (set = new DataSet())
                {
                    this.oleDbDataAdapter_0.Fill(set);
                    this.oleDbConnection_0.Close();
                }
            }
        }
Ejemplo n.º 12
0
        //更新变电站
        private void barButtonItem15_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //更新第2 5,8,11项

            string conn = "ProjectID='" + GetProjectID + "' and ParentID='0'";
            IList<Ps_Table_220Result> list = Common.Services.BaseService.GetList<Ps_Table_220Result>("SelectPs_Table_220ResultByConn", conn);
            int m = 0;
            WaitDialogForm frm = new WaitDialogForm("", "正在更新电源及变电站,请稍后...");
            foreach (Ps_Table_220Result pt in list)
            {
                m++;
                UpdataDY(pt.ID);
                UpDataRL(pt.ID);
                UpDataBDZ(pt.ID);
                UpData(pt.ID);
                double complete = m * 100 / list.Count;
                frm.Caption = "已完成" + Math.Round(complete, 0) + "%";
            }
            frm.Hide();
            LoadData1();
        }
Ejemplo n.º 13
0
        private void barButtonItem19_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.ctrlPowerEachList1.FocusedObject == null)
                return;

            typeFlag2 = this.ctrlPowerEachList1.FocusedObject.UID;
            this.Cursor = Cursors.WaitCursor;
            treeList1.BeginUpdate();
            WaitDialogForm wait = null;
            updat = "false";
            try
            {
                wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                InitSodata();
                wait.Close();
               // MsgBox.Show("计算成功");

            }
            catch
            {
                wait.Close();
            }

            //LoadData();
            treeList1.EndUpdate();
            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 14
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("此项目下有子项目,请先删除子项目!");
                return;
            }
            if (treeList1.FocusedNode.ParentNode == null)
            {
                if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("L3") + "?") == DialogResult.Yes)
                {
                    PowerProValues PowerValues = new PowerProValues();
                    PowerValues.TypeID = treeList1.FocusedNode["ID"].ToString();
                    PowerValues.Year = typeFlag2;

                    PSP_PowerProValues_LangFang ppss = new PSP_PowerProValues_LangFang();
                    ppss.ID = treeList1.FocusedNode["ID"].ToString();
                    ppss.Flag2 = typeFlag2;

                    PSP_PowerProValues_LangFang ppss1 = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppss);
                    PowerValues.TypeID1 = ppss1.Code;

                    try
                    {
                        //DeletePowerValuesByType里面删除数据和分类

                        Common.Services.BaseService.Update("DeletePowerProValuesByType", PowerValues);

                        TreeListNode brotherNode = null;
                        try
                        {
                            if (treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                            {
                                brotherNode = treeList1.FocusedNode.PrevNode;
                                if (brotherNode == null)
                                {
                                    brotherNode = treeList1.FocusedNode.NextNode;
                                }
                            }
                        }
                        catch { }
                        Common.Services.BaseService.Update("DeletePSP_PowerProValues_LangFangByIDFlag2", ppss);
                        treeList1.DeleteNode(treeList1.FocusedNode);
                        WaitDialogForm wait = null;

                        try
                        {
                            wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                            LoadDatadata();
                            wait.Close();
                        //    MsgBox.Show("计算成功");

                        }
                        catch
                        {
                            wait.Close();
                        }

                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("删除出错:" + ex.Message);
                    }
                }
                return;
            }
            else {

            if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("L3") + "?") == DialogResult.Yes)
            {
                bool flag = false;
                PowerProValues PowerValues = new PowerProValues();
                PowerValues.TypeID = treeList1.FocusedNode["ID"].ToString();
                PowerValues.Year = typeFlag2;

                PSP_PowerProValues_LangFang ppss = new PSP_PowerProValues_LangFang();
                ppss.ID=treeList1.FocusedNode["ID"].ToString();
                ppss.Flag2=typeFlag2;

                PSP_PowerProValues_LangFang ppss1 = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(ppss);
                PowerValues.TypeID1 = ppss1.Code;

                try
                {
                    //DeletePowerValuesByType里面删除数据和分类

                    Common.Services.BaseService.Update("DeletePowerProValuesByType", PowerValues);

                    TreeListNode brotherNode = null;
                    try
                    {
                        if (treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                        {
                            flag = false;
                            brotherNode = treeList1.FocusedNode.PrevNode;
                            if (brotherNode == null)
                            {
                                brotherNode = treeList1.FocusedNode.NextNode;
                            }
                        }
                        if (treeList1.FocusedNode.ParentNode.Nodes.Count == 1)
                        {
                            flag = true;
                        }
                     }
                    catch { }
                    Common.Services.BaseService.Update("DeletePSP_PowerProValues_LangFangByIDFlag2",ppss);
                    TreeListColumn column = treeList1.Columns["L10"];
                    treeList1.DeleteNode(treeList1.FocusedNode);
                    if(flag==false)
                       CalculateSum(treeList1.FocusedNode.ParentNode, column, 0,false);
                    else
                       CalculateSum(treeList1.FocusedNode, column, 0,false);
                   WaitDialogForm wait = null;

                   try
                   {
                       wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                       LoadDatadata();
                       wait.Close();
                       //MsgBox.Show("计算成功");

                   }
                   catch
                   {
                       wait.Close();
                   }

                }
                catch (Exception ex)
                {
                    MsgBox.Show("删除出错:" + ex.Message);
                }
            }
            }
              //            InitSodata();
              //obj= frm.OBJ;

              // CalculateSum(focusedNode, column, double.Parse(obj.L10));
        }
Ejemplo n.º 15
0
        private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            //if (treeList1.FocusedNode.ParentNode == null)
            //{
            //    MsgBox.Show("一级项目名称不能修改!");
            //    return;
            //}
            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("此项目下有子项目,不允许修改此记录!");
                return;
            }
            FormAddInfo_LangFang frm = new FormAddInfo_LangFang();
            frm.FlagId = typeFlag2;
            frm.PowerUId =this.treeList1.FocusedNode.GetValue("ID").ToString();
            frm.Text = "修改项目";
            frm.Isupdate = true;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                int i = this.treeList1.FocusedNode.Id;

                WaitDialogForm wait = null;

                try
                {
                    wait = new WaitDialogForm("", "正在计算数据, 请稍候...");
                    LoadDatadata();
                    wait.Close();
                    //MsgBox.Show("计算成功");

                }
                catch
                {
                    wait.Close();
                }

                //obj = frm.OBJ;
                TreeListColumn column = treeList1.Columns["L10"];
                CalculateSum(treeList1.FindNodeByID(i).ParentNode, column, 0,true);

                ////try
                ////{
                ////    string id = treeList1.FocusedNode["ID"].ToString();
                ////    string flag22 = typeFlag2;

                ////    PSP_PowerProValues_LangFang pptss = new PSP_PowerProValues_LangFang();
                ////    pptss.ID = id;
                ////    pptss.Flag2 = flag22;

                ////    PSP_PowerProValues_LangFang psp_Type = Services.BaseService.GetOneByKey<PSP_PowerProValues_LangFang>(pptss);
                ////    psp_Type.L3 = frm.TypeTitle;
                ////psp_Type.Flag = frm.PowerType;
                ////Common.Services.BaseService.Update<PSP_PowerProValues_LangFang>(psp_Type);

                ////    if (psp_Type.Code != "")
                ////    {
                ////        LineInfo li3 = Services.BaseService.GetOneByKey<LineInfo>(psp_Type.Code);
                ////        if (li3 != null)
                ////        {
                ////            li3.LineName = psp_Type.L3;
                ////            Common.Services.BaseService.Update<LineInfo>(li3);
                ////        }

                ////        substation sb3 = Services.BaseService.GetOneByKey<substation>(psp_Type.Code);
                ////        if (sb3 != null)
                ////        {
                ////            sb3.EleName = psp_Type.L3;
                ////            Common.Services.BaseService.Update<substation>(sb3);
                ////        }
                ////    }

                ////    treeList1.FocusedNode.SetValue("L3", frm.TypeTitle);
                ////    FoucsLocation(id, treeList1.Nodes);
                ////}
                ////catch (Exception ex)
                ////{
                ////    //MsgBox.Show("修改出错:" + ex.Message);
                ////}
            }
        }
Ejemplo n.º 16
0
        void KiemTraVatTu()
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang kiem tra..."))
            {
                string[] listFilePath = Directory.GetFiles("D:/ListDMVT");
                foreach (string filePath in listFilePath)
                {
                    try
                    {
                        string    moduleCode = Path.GetFileName(filePath).Substring(3, 10);
                        DataTable dtDMVT     = TextUtils.ExcelToDatatableNoHeader(filePath, "DMVT");
                        var       results    = from myRow in dtDMVT.AsEnumerable()
                                               where TextUtils.ToDecimal(myRow.Field <string>("F1")) > 0 &&
                                               !(myRow.Field <string>("F4")).StartsWith("TPAD") &&
                                               !(myRow.Field <string>("F4")).StartsWith("PCB")
                                               select myRow;
                        if (results.Count() == 0)
                        {
                            continue;
                        }

                        dtDMVT = results.CopyToDataTable();

                        for (int i = 0; i <= dtDMVT.Rows.Count - 1; i++)
                        {
                            string nameDMVT = dtDMVT.Rows[i][3].ToString();
                            if (nameDMVT == "")
                            {
                                continue;
                            }
                            string hang = dtDMVT.Rows[i][9].ToString();

                            List <string> errorString = new List <string>();

                            #region Kiem tra hang co hop le
                            DataTable dtGroup = TextUtils.Select("select CustomerCode from vMaterialCustomer a where replace(a.Code,' ','') ='" + nameDMVT.Replace(" ", "").Replace("(", "/") + "'");
                            if (dtGroup.Rows.Count > 0)
                            {
                                DataRow[] drsCustomer = dtGroup.Select("CustomerCode = '" + hang + "'");
                                if (drsCustomer.Count() == 0)
                                {
                                    errorString.Add("Hãng không được sử dụng");
                                }
                            }
                            #endregion

                            #region Vật tư ngừng sử dụng

                            DataTable dtViewMaterial = TextUtils.Select("SELECT MaterialGroupCode FROM [vMaterial] with (nolock) where replace(Code,' ','') = '" + nameDMVT.Replace(" ", "").Replace(")", "/") + "'");
                            if (dtViewMaterial.Rows.Count > 0)
                            {
                                string materialGroupCode = dtViewMaterial.Rows[0][0].ToString();
                                if (materialGroupCode == "TPAVT.Z01")
                                {
                                    errorString.Add("Vật tư ngừng sử dụng");
                                }
                            }
                            #endregion

                            #region Vật tư tạm dừng sử dụng
                            DataTable dtMaterialCSDL = TextUtils.Select("SELECT * FROM [Material] with (nolock) where [StopStatus] = 1 and replace(Code,' ','') = '" + nameDMVT.Replace(" ", "").Replace(")", "/") + "'");
                            if (dtMaterialCSDL.Rows.Count > 0)
                            {
                                errorString.Add("Vật tư tạm dừng sử dụng");
                            }
                            #endregion

                            #region Kiểm tra trên quản lý sản xuất
                            //Kiem tra xem vat tu co trong kho chua
                            DataTable dtMaterialQLSX = LibQLSX.Select("SELECT top 1 p.PartsCode,m.ManufacturerCode"
                                                                      + " FROM Manufacturer m RIGHT OUTER JOIN"
                                                                      + " PartsManufacturer pm ON m.ManufacturerId = pm.ManufacturerId RIGHT OUTER JOIN"
                                                                      + " Parts p ON pm.PartsId = p.PartsId"
                                                                      + " where p.PartsCode = '" + nameDMVT.Replace(" ", "").Replace("(", "/") + "'");
                            if (dtMaterialQLSX.Rows.Count == 0)
                            {
                                errorString.Add("Vật tư không tồn tại");
                            }
                            else
                            {
                                if (dtMaterialQLSX.Rows[0]["ManufacturerCode"].ToString().ToUpper() != hang.ToUpper())
                                {
                                    errorString.Add("Hãng khác với hãng trên QLSX (" + hang + " - " + dtMaterialQLSX.Rows[0]["ManufacturerCode"].ToString() + ")");
                                }
                            }
                            #endregion

                            if (errorString.Count > 0)
                            {
                                TestModel model = new TestModel();
                                model.ModuleCode   = moduleCode;
                                model.MaterialCode = nameDMVT;
                                model.MaterialName = dtDMVT.Rows[i]["F2"].ToString();
                                model.Hang         = hang;
                                model.Error        = string.Join(", ", errorString.ToArray());
                                TestBO.Instance.Insert(model);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            MessageBox.Show("ok");
        }
        private void btnControl_btnEventExcel_Click(object sender, EventArgs e)
        {
            WaitDialogForm waitDialogForm = new WaitDialogForm("Đang xuất excel ...", "Vui lòng chờ giây lát !");

            try
            {
                ExcelManager excelManager = new ExcelManager(true);

                // Print band header
                BandedGridView view = gvGrid;
                view.ExpandAllGroups();
                object[] data = new object[view.VisibleColumns.Count];
                excelManager.BandedGridHeader2Excel(view, false, 6, 1, "headerRangeName");
                excelManager.SetTitleRows();
                excelManager.SelectRange()
                .SetFontFamily("Times New Roman");

                waitDialogForm.SetCaption(String.Format("{0} - {1}%", "Đang xuất excel ...", 50));

                excelManager.GridData2Excel(gvGrid, 7, 1, false, false, "", false, false);

                //excelManager.SelectRange(excelManager.WorkingRange.Row + excelManager.WorkingRange.Rows.Count, excelManager.WorkingRange.Column,
                //    excelManager.WorkingRange.Row + excelManager.WorkingRange.Rows.Count, excelManager.WorkingRange.Column + excelManager.WorkingRange.Columns.Count - 1);


                // Save working range
                //excelManager.MoveRange(2, 0);
                //int maxCol = 12;
                //int xtraCol = 2;

                int sr = excelManager.WorkingRange.Row + 1;
                int sc = excelManager.WorkingRange.Column;
                int er = excelManager.WorkingRange.Row + 1;
                int ec = excelManager.WorkingRange.Column + excelManager.WorkingRange.Columns.Count - 1;

                //excelManager.SelectRange(8, 1, 8, maxCol).SetRowHeight("", 45);

                ////Dòng Title
                excelManager
                .SelectRange(1, 1, 1, 1)
                .SetFontStyle(true, false, false)
                .SetFontSize(12)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft)
                .SetRangeValue(clsParameter.pParentHospital);

                excelManager
                .SelectRange(2, 1, 2, 1)
                .SetFontStyle(false, false, false)
                .SetFontSize(12)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft)
                .SetRangeValue(clsParameter.pHospital);

                excelManager
                .SelectRange(4, 1, 4, ec)
                .Merge()
                .SetFontStyle(true, false, false)
                .SetFontSize(16)
                .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                .SetRangeValue("DANH SÁCH TRẺ KHUYẾT TẬT VÀ CON NGƯỜI KHUYẾT TẬT");

                excelManager.SelectRange(11, 2, er, ec).AutoFitColumn();
                //excelManager.SelectRange(11, 2, er, ec).SetNumberFormat("#,#0");

                // excelManager
                // .SelectRange(er + 2, ec - 3, er + 2, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue(string.Format("Ngày {0} tháng {1} năm {2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year));

                // excelManager
                // .SelectRange(er + 3, ec - 3, er + 3, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue("Thư ký");

                // excelManager
                // .SelectRange(er + 6, ec - 3, er + 6, ec)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue(clsParameter.pThuKy);

                // excelManager
                // .SelectRange(er + 3, 3, er + 3, 4)
                // .Merge()
                // .SetFontStyle(false, false, false)
                // .SetFontSize(12)
                // .SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                // .SetRangeValue("Giám đốc");

                // excelManager
                //.SelectRange(er + 6, 3, er + 6, 4)
                //.Merge()
                //.SetFontStyle(false, false, false)
                //.SetFontSize(12)
                //.SetHorizontalAlignment(Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter)
                //.SetRangeValue(clsParameter.pGiamDoc);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("Lỗi trong quá trình xuất Excel.\nVui lòng kiểm tra lại biểu mẫu hoặc tài liệu đang mở.", "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                //Marshal.ReleaseComObject(excelSheet);
                //Marshal.ReleaseComObject(excelBook);
                //Marshal.ReleaseComObject(books);
                //Marshal.ReleaseComObject(excel);

                waitDialogForm.Close();
            }
        }
Ejemplo n.º 18
0
        //更新区域
        private void barButtonItem5_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string conn = "ProjectID='" + GetProjectID + "' and ParentID='0'";
            IList<Ps_Table_220Result> list = Common.Services.BaseService.GetList<Ps_Table_220Result>("SelectPs_Table_220ResultByConn", conn);
            Hashtable AreaTable = new Hashtable();
            for (int i = 0; i < list.Count; i++)
            {
                AreaTable.Add(list[i].Title, list[i].Title);
            }
            string connarea = "ProjectID='" + Itop.Client.MIS.ProgUID + "'order by Sort";
            IList<PS_Table_AreaWH> listarea = Common.Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", connarea);
            int m = 0;
            WaitDialogForm frm = new WaitDialogForm("","正在更新区域,请稍后...");
            foreach (PS_Table_AreaWH area in listarea)
            {
                m++;
                if (!AreaTable.Contains(area.Title))
                {

                    AddArea(area.Title);
                }
                double complete = m * 100 / listarea.Count ;
                frm.Caption = "已完成" + Math.Round(complete, 0) + "%";
            }
            frm.Hide();
            LoadData1();
        }
Ejemplo n.º 19
0
        private void SaveText()
        {
            if (treeList1.FocusedNode == null)
                return;
            string uid = treeList1.FocusedNode["UID"].ToString();
            LayoutContent obj = Services.BaseService.GetOneByKey<LayoutContent>(uid);

            obj.Contents = dsoFramerWordControl1.FileDataGzip;
            WaitDialogForm wait = null;
            try
            {
                wait = new WaitDialogForm("", "���ڱ�������, ���Ժ�...");
                Services.BaseService.Update("UpdateLayoutContentByte", obj);
                wait.Close();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                wait.Close();
                return;
            }
        }
Ejemplo n.º 20
0
        //���仯�����¸ı�word����
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            killAllProcess();
            //���㷢���仯ʱ�����ݿ�����ȡ�µ�word�ļ�
            if (treeList1.FocusedNode == null)
                return;
            string uid = treeList1.FocusedNode["UID"].ToString();
            LayoutContentANTL obj = Services.BaseService.GetOneByKey<LayoutContentANTL>(uid);
            WaitDialogForm wait=null;
            WordBuilder wb = new WordBuilder();

            // public static Word.Bookmarks W_Bkm =

            //if (fb != null)
            //    wb.InsertFromStreamGzip(fb);

            //��һ�µ�ǰword�еı�ǩ
            //�ı�һ�µ�ǰ��¼��word��UID���Ա����±�ǩʱʹ��
            LayoutID = treeList1.FocusedNode["UID"].ToString();

            try
            {
                wait = new WaitDialogForm("", "������������, ���Ժ�...");

                if (obj.Contents != null && obj.Contents.Length > 0)
                {
                    if (fb != null)
                    {
                        wb.InsertFromStreamGzip(obj.Contents);
                        dsoFramerWordControl1.FileData = wb.FileData;
                        Staword = wb;

                    }
                    else
                    {
                        dsoFramerWordControl1.FileDataGzip = obj.Contents;
                    }
                }
                else
                {
                    dsoFramerWordControl1.FileNew();
                }
                dsoFramerWordControl1.AxFramerControl.Menubar = true;
                if(dsoFramerWordControl1.AxFramerControl.DocumentFullName!=null)
                {
                 W_Doc = (Word.Document)dsoFramerWordControl1.AxFramerControl.ActiveDocument;
                }

                wait.Close();

            }

            catch (Exception ex)
            {
                wait.Close();
            MessageBox.Show(ex.Message);

            }
        }
Ejemplo n.º 21
0
        private void btnAddModule_Click(object sender, EventArgs e)
        {
            frmListModules frm = new frmListModules();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm module..."))
                {
                    foreach (DataRow r in frm.dtSeleted.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }

                        decimal price = TextUtils.GetPrice(code, true);

                        int deliveryTime = -1;
                        if (code.StartsWith("PCB."))
                        {
                            //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                            //        + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                            //        + "TPAT." + code.Substring(4, 7) + "'"
                            //        + " ORDER BY DateAboutF DESC";
                            //DataTable dtPrice = LibQLSX.Select(sqlM);

                            string    sqlM    = "exec spGetPriceOfPart 'TPAT." + code.Substring(4, 7) + "'";
                            DataTable dtPrice = LibQLSX.Select(sqlM);

                            deliveryTime = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                        }

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]  = TextUtils.ToString(r["Code"]);
                        dr["Name"]  = TextUtils.ToString(r["Name"]);
                        dr["Hang"]  = TextUtils.ToString(r["Hang"]);
                        dr["Unit"]  = "Bộ";
                        dr["Price"] = price.ToString("n0");
                        dr["Total"] = price.ToString("n0");
                        dr["Qty"]   = 1;

                        if (deliveryTime != -1)
                        {
                            dr["Time"] = deliveryTime;

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Status"] = "Không đạt";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }

                        _dtVT.Rows.Add(dr);
                    }

                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }
Ejemplo n.º 22
0
        private void btJSDJ_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
            //计算列表中所有台区下的低压线路
            int ncount = 0;
            WaitDialogForm dlg = new WaitDialogForm("", "正计算档距,请稍候。。。");
            string info = "(第{0}共" + gridView1.RowCount + "个){1}";
            try {
                foreach (var item in gridViewOperation.BindingList) {
                    ncount++;

                    dlg.Caption = string.Format(info, ncount, item.tqName);
                    SbFuns.CountTQLen(item.tqCode);

                }
            } catch (Exception err) {
                dlg.Close();
                throw err;
            }
            dlg.Close();
            MsgBox.ShowTipMessageBox("计算完毕,共计算了" + ncount + "个台区。");
        }
Ejemplo n.º 23
0
        private void btnCreateIPT_Click(object sender, EventArgs e)
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo..."))
            {
                string tkPath       = string.Format(@"D:\Thietke.Ck\{0}\{1}.Ck\3D.{1}\", _moduleCode.Substring(0, 6), _moduleCode);
                string templatePath = Application.StartupPath + "\\Templates\\";
                string cadPath      = string.Format(@"D:\Thietke.Ck\{0}\{1}.Ck\CAD.{1}\", _moduleCode.Substring(0, 6), _moduleCode);
                string hangPath     = string.Format(tkPath + @"\COM.{0}\", _moduleCode);

                foreach (DataRow row in _dtDMVT.Rows)
                {
                    string stt  = TextUtils.ToString(row["F1"]);
                    string code = TextUtils.ToString(row["F4"]).Replace("/", ")");
                    string hang = TextUtils.ToString(row["F10"]);
                    string unit = TextUtils.ToString(row["F6"]);

                    Directory.CreateDirectory(hangPath + hang);
                    if (!code.StartsWith(_moduleCode))
                    {
                        if (unit == "BỘ")
                        {
                            File.Copy(templatePath + "demo.iam", hangPath + hang + "\\" + code + ".iam", true);
                        }
                        else
                        {
                            File.Copy(templatePath + "demo.ipt", hangPath + hang + "\\" + code + ".ipt", true);
                        }
                    }

                    //if (code.StartsWith("TPAD."))
                    //{
                    File.Copy(templatePath + "demo.dwg", cadPath + code + ".dwg", true);
                    //}

                    if (stt.Contains("."))
                    {
                        string[]      array = stt.Split('.');
                        List <string> list  = array.ToList();
                        list.RemoveAt(array.Length - 1);
                        string parent = string.Join(".", list.ToArray());

                        row["Pr"] = parent;
                    }
                    else
                    {
                        row["Pr"] = "";
                    }
                }

                //DataRow[] drsBO = _dtDMVT.Select("F6 = 'BỘ'");// and Parent = ''
                //DataTable dtBO = new DataTable();
                //if (drsBO.Length > 0)
                //{
                //    dtBO = drsBO.CopyToDataTable();
                //}

                foreach (DataRow row in _dtDMVT.Rows)
                {
                    string stt    = TextUtils.ToString(row["F1"]);
                    string code   = TextUtils.ToString(row["F4"]);
                    string parent = TextUtils.ToString(row["Pr"]);
                    string unit   = TextUtils.ToString(row["F6"]);

                    if (unit == "BỘ")
                    {
                        if (parent == "")
                        {
                            string pathBo = tkPath + code;

                            row["Path"] = pathBo;
                            Directory.CreateDirectory(pathBo);
                            File.Copy(templatePath + "demo.iam", pathBo + "\\" + code + ".iam", true);

                            createCT(stt, pathBo, templatePath);
                        }
                    }
                    else
                    {
                        if (code.StartsWith(_moduleCode))
                        {
                            if (parent == "")
                            {
                                File.Copy(templatePath + "demo.ipt", tkPath + "\\" + code + ".ipt", true);
                            }
                            else
                            {
                                DataRow[] drs  = _dtDMVT.Select("F1 = '" + parent + "'");
                                string    path = TextUtils.ToString(drs[0]["Path"]);
                                File.Copy(templatePath + "demo.ipt", path + "\\" + code + ".ipt", true);
                            }
                        }
                    }
                }
            }
            MessageBox.Show("Xuất file thành công!");
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm newwait = new WaitDialogForm("", "正在更新数据, 请稍候...");
            ////由于SheetView已经没有了所以移除SheetView

            //由于更新数据时间太长需要建个空表做初始界面
            //FarPoint.Win.Spread.SheetView fpSpread1_Sheet5 = new FarPoint.Win.Spread.SheetView();
            //PF.CreateSheet(this, fpSpread1, "kk");
            SheetIndex = fpSpread1.ActiveSheetIndex;//记住当前的SheetView的索引值
            fpSpread1.ActiveSheet = fpSpread1.Sheets[fpSpread1.Sheets.Count-1];//把当前界面给空表

            //PF.RemoveSheetView(this.fpSpread1, (fpSpread1.Sheets.Count-1));
            //MessageBox.Show(fpSpread1.Sheets[0].SheetName);
            //===================================================

            this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            fpSpread1.Sheets.Clear();
            IsCreateSheet = false;
            LoadData();

            newwait.Close();
            IsCreateSheet = true;
            fpSpread1.ActiveSheet = fpSpread1.Sheets[SheetIndex];//把以前显示的界面在显示出来
            //删除临时SheetView
            //fpSpread1.Sheets.Remove(fpSpread1.Sheets[fpSpread1.Sheets.Count - 1]);
            if (SheetIndex == 1)//第二个工作簿
            {
                this.barEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
            }
            MessageBox.Show("更新数据完成!");
        }
Ejemplo n.º 25
0
        /// 保存交易信息
        private void btnStoreReceiverMsg_Click(object sender, EventArgs e)
        {
            if (_currentTradeRow == null)
            {
                XtraMessageBox.Show("请选中一条交易!");
                return;
            }
            Alading.Entity.Trade focusedTrade = TradeService.GetTrade(_currentTradeRow["CustomTid"].ToString());
            //算法辅助量 默认Yes。如果时间戳不相等,弹出YesNoDialog,由此可决定是否更新
            DialogResult result = DialogResult.Yes;

            #region 利用时间戳来防止并发
            //调用辅助函数来比较时间戳是否相等
            if (!Alading.Utils.SystemHelper.CompareTimeStamp(_currentTradeRow["TradeTimeStamp"] as byte[], focusedTrade.TradeTimeStamp))
            {
                //如果时间戳不相等,则执行此代码段
                result = XtraMessageBox.Show("该交易的已被修改,是否继续修改(YES)/查看流程信息(NO)", "确认修改", MessageBoxButtons.YesNo);
            }
            #endregion

            #region 根据result的值更新数据库

            if (result == DialogResult.Yes)
            {
                #region 构造一条交易数据修改信息
                StringBuilder builder = new StringBuilder();
                try
                {
                    if (focusedTrade.receiver_name != txtBuyerName.Text)
                    {
                        builder.Append("  收获人姓名:" + focusedTrade.receiver_name + "->" + txtBuyerName.Text);
                    }
                    if (focusedTrade.receiver_mobile != txtMobile.Text)
                    {
                        builder.Append("  收货人电话:" + focusedTrade.receiver_mobile + "->" + txtMobile.Text);
                    }
                    if (focusedTrade.receiver_zip != txtZip.Text)
                    {
                        builder.Append("  收货人邮编:" + txtZip.Text + "->" + focusedTrade.receiver_zip);
                    }
                    if (focusedTrade.receiver_phone != txtPhone.Text)
                    {
                        builder.Append("  收货人座机:" + focusedTrade.receiver_phone + "->" + txtPhone.Text);
                    }
                    if (focusedTrade.LogisticCompanyCode != cmbShippingCompany.EditValue.ToString())
                    {
                        builder.Append("  收货人物流公司:" +
                                       LogisticCompanyService.GetLogisticCompany(p => p.code == focusedTrade.LogisticCompanyCode).FirstOrDefault().name +
                                       "->" + cmbShippingCompany.Text);
                    }
                    if (focusedTrade.receiver_address != txtReceiverAddress.Text)
                    {
                        builder.Append("  收货人地址:" + focusedTrade.receiver_address + "->" + txtReceiverAddress.Text);
                    }
                    if (focusedTrade.receiver_state != cmbReceiverState.SelectedItem.ToString())
                    {
                        builder.Append("  收货人省:" + focusedTrade.receiver_state + "->" + cmbReceiverState.SelectedItem.ToString());
                    }
                    if (focusedTrade.receiver_city != cmbReceiverCity.SelectedItem.ToString())
                    {
                        builder.Append("  收货人市:" + focusedTrade.receiver_city + "->" + cmbReceiverCity.SelectedItem.ToString());
                    }
                    if (focusedTrade.receiver_district != cmbReceiverDistrict.SelectedItem.ToString())
                    {
                        builder.Append("  收货人地区:" + focusedTrade.receiver_district + "->" + cmbReceiverDistrict.SelectedItem.ToString());
                    }
                    if ((focusedTrade.buyer_memo == null ? string.Empty : focusedTrade.buyer_memo) != memoBuyerMemo.Text)
                    {
                        builder.Append("  收货人备注:" + focusedTrade.buyer_memo + "->" + memoBuyerMemo.Text);
                    }
                    if ((focusedTrade.buyer_message == null ? string.Empty : focusedTrade.buyer_message) != memoBuyerMessage.Text)
                    {
                        builder.Append("  收货人信息:" + focusedTrade.buyer_message + "->" + memoBuyerMessage.Text);
                    }
                }
                catch (System.Exception ex)
                {
                }

                #endregion

                #region 从界面读取修改信息
                focusedTrade.receiver_name       = txtBuyerName.Text;
                focusedTrade.receiver_mobile     = txtMobile.Text;
                focusedTrade.receiver_zip        = txtZip.Text;
                focusedTrade.receiver_phone      = txtPhone.Text;
                focusedTrade.LogisticCompanyCode = cmbShippingCompany.EditValue.ToString();
                focusedTrade.TemplateCode        = cmbShippingTemplate.EditValue.ToString();
                focusedTrade.receiver_address    = txtReceiverAddress.Text;
                focusedTrade.receiver_state      = cmbReceiverState.SelectedItem.ToString();
                focusedTrade.receiver_city       = cmbReceiverCity.SelectedItem.ToString();
                focusedTrade.receiver_district   = cmbReceiverDistrict.SelectedItem.ToString();
                focusedTrade.buyer_memo          = memoBuyerMemo.Text;
                focusedTrade.buyer_message       = memoBuyerMessage.Text;
                focusedTrade.HasInvoice          = false;
                #endregion

                WaitDialogForm wdf = new WaitDialogForm(Constants.OPERATE_TBDB_DATA);
                try
                {
                    //将修改数据更新到淘宝
                    UpdateTaobaoTradeAddressMessage(focusedTrade);
                    //更新修改数据到数据库
                    TradeService.UpdateTrade(focusedTrade);
                    //创建一条流水信息到数据库
                    Alading.Utils.SystemHelper.CreateFlowMessage(focusedTrade.CustomTid, "收货信息修改", builder.ToString(), "订单管理");
                    wdf.Close();
                    XtraMessageBox.Show("修改收货信息成功!");
                }
                catch (Exception ex)
                {
                    wdf.Close();
                    XtraMessageBox.Show("修改收货保存到淘宝失败,修改无效!原因:" + ex.Message);
                }

                //将更新信息同步到界面
                _currentTradeRow["receiver_name"] = txtBuyerName.Text;
                //时间由系统自动生成,需将本地时间戳与数据库最新同步
                _currentTradeRow["TradeTimeStamp"] = TradeService.GetTrade(focusedTrade.CustomTid).TradeTimeStamp;
            }
            else
            {
                tabsTradeDetail.SelectedTabPage = detailTabFlowMsg;
            }
            #endregion
        }
Ejemplo n.º 26
0
        /// <summary>
        ///  创建数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateData_Click(object sender, EventArgs e)
        {
            if (!CheckForm())
            {
                return;
            }

            string connstr1 = " Connection Timeout=2; Pooling=False ;server=" + txtServerAddress.Text.Trim() + ";database=Master;uid=" + txtServerUser.Text.Trim() + ";pwd=" + txtServerPwd.Text.Trim() + ";";
            if (!CheckConn(connstr1))
            {
                SQLDMOHelper.MesShow("无法连接到服务器,请确认服务器信息!");
                return;
            }
            SQLDMOHelper smh = new SQLDMOHelper(txtServerAddress.Text.Trim(),txtServerUser.Text.Trim(),txtServerPwd.Text.Trim());

            ArrayList datalist = smh.GetDbList();
            if (datalist.Contains(txtServerName.Text.Trim()))
            {
                SQLDMOHelper.MesShow("该服务器中已在名为 " + txtServerName.Text.Trim() + " 的数据库");
                return;
            }
            FrmDirTree frmd = new FrmDirTree();
             SQLDMO.SQLServer svr = new SQLDMO.SQLServerClass();
             svr.Connect(txtServerAddress.Text.Trim(), txtServerUser.Text.Trim(), txtServerPwd.Text.Trim());
            frmd.svr=svr;
            frmd.Text = txtServerAddress.Text.Trim() + "选择路径";
            string FilePath="";
            if (frmd.ShowDialog()==DialogResult.OK)
            {
                FilePath = frmd.SelectPaht;
            }
            else
            {
                return;
            }
            WaitDialogForm frm = new WaitDialogForm("正在创建数据库,请稍后...");
            frm.Show();

            if (smh.CreateDB(txtServerName.Text.Trim(), FilePath))
            {
                //读取配置数据表.sql文件

                IList<SysDataFiles> sdflist = ServicesSys.BaseService.GetList<SysDataFiles>("SelectSysDataFilesList", "");
                if (sdflist.Count==0)
                {
                    frm.Hide();
                    SQLDMOHelper.MesShow("服务器中创建数据库文件不存在,请管管员先添加该文件! ");
                    return;
                }
                SysDataFiles file = sdflist[0];
                string path = Application.StartupPath + "\\BlogData";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string filepath = path + "\\" + file.FileName;
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                getfile(file.Files, filepath);

                ArrayList alist = smh.GetSqlFile(filepath, txtServerName.Text.Trim());
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                string connstr2 = "Pooling=False ; server=" + txtServerAddress.Text.Trim() + ";database=" + txtServerName.Text.Trim() + ";uid=" + txtServerUser.Text.Trim() + ";pwd=" + txtServerPwd.Text.Trim() + ";";
                SqlConnection conn = new SqlConnection(connstr2);
                frm.Caption = "正在创建数据表,请稍后...";
                if (smh.ExecuteCommand(alist,conn))
                {
                    frm.Caption = "正在初始化数据,请稍后...";

                    //添加数据
                    if (CopyData(smh))
                    {
                        frm.Hide();
                        SQLDMOHelper.MesShow("数据库 " + txtServerName.Text.Trim() + " 已成功创建");
                    }
                    else
                    {
                        frm.Hide();
                        SQLDMOHelper.MesShow("数据库 " + txtServerName.Text.Trim() + " 已成功创建,初始化数据败");
                    }

                }
                else
                {
                    frm.Hide();
                    SQLDMOHelper.MesShow("创建数据库表失败,请检查服务器中创建数据库文件是否损坏");
                }
            }
            frm.Hide();
        }
Ejemplo n.º 27
0
 public WaitingMsg(XtraForm main)
 {
     main.Shown += new EventHandler(this.end);
     this.wait   = new WaitDialogForm("Xin vui l\x00f2ng chờ trong gi\x00e2y l\x00e1t", "Đang xử l\x00fd", new Size(250, 50), main);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// 删除数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelData_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除当前数据库吗?(不可恢复,请慎重操作)", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            WaitDialogForm frm = new WaitDialogForm("", "正在删除数据库,请稍后...");
            frm.Show();
            string connstr1 = " Connection Timeout=2; server=" + txtServerAddress.Text.Trim() + ";database=Master;uid=" + txtServerUser.Text.Trim() + ";pwd=" + txtServerPwd.Text.Trim() + ";";
            if (!CheckConn(connstr1))
            {
                frm.Hide();
                SQLDMOHelper.MesShow("无法连接到服务器,请确认服务器信息!");
                return;
            }
            SQLDMOHelper smh = new SQLDMOHelper(txtServerAddress.Text.Trim(), txtServerUser.Text.Trim(), txtServerPwd.Text.Trim());
            ArrayList datalist = smh.GetDbList();
            if (datalist.Contains(txtServerName.Text.Trim()))
            {
                if (smh.KillDB(txtServerName.Text.Trim()))
                {
                    frm.Hide();
                    SQLDMOHelper.MesShow("已成功删除 " + txtServerName.Text.Trim() + " 数据库");
                }

            }
            else
            {
                frm.Hide();
                SQLDMOHelper.MesShow("该服务器中不存在名为 " + txtServerName.Text.Trim() + " 的数据库");
            }
            frm.Hide();
        }
Ejemplo n.º 29
0
 static void createWaitDlg() {
     waitdlg = new WaitDialogForm("", "正在加载数据,请稍候。。。");
 }
Ejemplo n.º 30
0
 public FileReadDV(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf, string con, StringBuilder dianYaResult)
 {
     this.projectSUID  = projectSUID;
     this.projectid    = projectid;
     this.dulutype     = dulutype;
     this.ratecaplity  = ratecaplity;
     this.wf           = wf;
     this.con          = con;
     this.dianYaResult = dianYaResult;
 }
Ejemplo n.º 31
0
        public bool DataCheck(string projectSUID)
        {
            string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'";
            string strCon2 = null;
            string strCon = null;
            {
                WaitDialogForm wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                strCon2 = " AND Type = '01'";
                strCon = strCon1 + strCon2;
                IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                strCon2 = " AND Type = '05'";
                strCon = strCon1 + strCon2;
                IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                strCon2 = " AND Type = '02'";
                strCon = strCon1 + strCon2;
                IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                strCon2 = " AND Type = '03'";
                strCon = strCon1 + strCon2;
                IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                Hashtable ht = new Hashtable();

                foreach (PSPDEV dev in listMX)
                {
                    if (dev.Number <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("母线" + dev.Name + "编号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    else
                    {
                        if (ht.Contains(dev.Number))
                        {
                            wait.Close();
                            MessageBox.Show("母线" + dev.Name + "," + ((PSPDEV)ht[dev.Number]).Name + "编号重复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return false;
                        }
                        else
                        {
                            ht.Add(dev.Number, dev);
                        }
                    }
                    if (dev.KSwitchStatus=="投入运行"||dev.KSwitchStatus=="退出运行")
                    {
                        wait.Close();
                        MessageBox.Show("母线" + dev.Name + "运行方式重新点击一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }
                ht.Clear();
                foreach (PSPDEV dev in listXL)
                {
                    if (dev.Number <= 0)
                    {
                        //wait.Close();
                        //MessageBox.Show("线路" + dev.Name + "编号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //return false;
                    }
                    else
                    {
                        if (dev.FirstNode <= 0)
                        {
                            wait.Close();
                            MessageBox.Show("线路" + dev.Name + "没有i侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return false;
                        }
                        if (dev.LastNode <= 0)
                        {
                            wait.Close();
                            MessageBox.Show("线路" + dev.Name + "没有j侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return false;
                        }
                        if (ht.Contains(dev.Number))
                        {
                            wait.Close();
                            MessageBox.Show("线路" + dev.Name + "," + ((PSPDEV)ht[dev.Number]).Name + "编号重复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return false;
                        }
                        else
                        {
                            ht.Add(dev.Number, dev);
                        }
                    }
                    if (dev.KSwitchStatus == "投入运行" || dev.KSwitchStatus == "退出运行")
                    {
                        wait.Close();
                        MessageBox.Show("线路" + dev.Name + "运行方式重新点击一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }
                foreach (PSPDEV dev in listBYQ2)
                {
                    if (dev.FirstNode <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("两绕组变压器" + dev.Name + "没有i侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (dev.LastNode <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("两绕组变压器" + dev.Name + "没有j侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (dev.KSwitchStatus == "投入运行" || dev.KSwitchStatus == "退出运行")
                    {
                        wait.Close();
                        MessageBox.Show("两绕组变压器" + dev.Name + "运行方式重新点击一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }
                foreach (PSPDEV dev in listBYQ3)
                {
                    if (dev.FirstNode <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("三绕组变压器" + dev.Name + "没有i侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (dev.LastNode <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("三绕组变压器" + dev.Name + "没有j侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (dev.Flag <= 0)
                    {
                        wait.Close();
                        MessageBox.Show("三绕组变压器" + dev.Name + "没有k侧母线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (dev.KSwitchStatus == "投入运行" || dev.KSwitchStatus == "退出运行")
                    {
                        wait.Close();
                        MessageBox.Show("三绕组变压器" + dev.Name + "运行方式重新点击一次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                }
                wait.Close();
            }

            return true;
        }
Ejemplo n.º 32
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            DocUtils.InitFTPTK();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file lên server!"))
                {
                    foreach (string filePath in ofd.FileNames)
                    {
                        ProcessTransaction pt = new ProcessTransaction();
                        pt.OpenConnection();
                        pt.BeginTransaction();
                        try
                        {
                            MisMatchImageModel errorImageModel;
                            bool isAdd = true;
                            if (!MisMatchImageBO.Instance.CheckExist("FileName", Path.GetFileName(filePath)))
                            {
                                errorImageModel = new MisMatchImageModel();
                            }
                            else
                            {
                                errorImageModel = (MisMatchImageModel)MisMatchImageBO.Instance.FindByAttribute("FileName", Path.GetFileName(filePath))[0];
                                isAdd           = false;
                            }

                            FileInfo fInfo = new FileInfo(filePath);

                            string ftpFolderPath = "Modules\\KPHImage\\" + MisMatch.Code;

                            errorImageModel.CreatedDate = TextUtils.GetSystemDate();
                            errorImageModel.CreatedBy   = Global.LoginName;
                            errorImageModel.FileName    = Path.GetFileName(filePath);
                            errorImageModel.Size        = fInfo.Length;
                            errorImageModel.FilePath    = ftpFolderPath + "\\" + errorImageModel.FileName;
                            errorImageModel.MisMatchID  = MisMatch.ID;

                            if (isAdd)
                            {
                                errorImageModel.ID = (int)pt.Insert(errorImageModel);
                            }
                            else
                            {
                                pt.Update(errorImageModel);
                            }

                            if (!DocUtils.CheckExits(ftpFolderPath))
                            {
                                DocUtils.MakeDir(ftpFolderPath);
                            }
                            DocUtils.UploadFile(filePath, ftpFolderPath);

                            pt.CommitTransaction();
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            pt.CloseConnection();
                        }
                    }

                    loadGridImage();
                }
            }
        }
Ejemplo n.º 33
0
        void KiemTraVatTu_VatLieu()
        {
            DataTable dtError = new DataTable();

            dtError.Columns.Add("ModuleCode");
            dtError.Columns.Add("STT");
            dtError.Columns.Add("MaterialCode");
            dtError.Columns.Add("MaterialName");
            dtError.Columns.Add("MaVatLieu");
            dtError.Columns.Add("VatLieu");
            dtError.Columns.Add("Error");

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang kiem tra..."))
            {
                string[] listFilePath = Directory.GetFiles("D:/ListDMVT");
                foreach (string filePath in listFilePath)
                {
                    try
                    {
                        string    moduleCode = Path.GetFileName(filePath).Substring(3, 10);
                        DataTable dtDMVT     = TextUtils.ExcelToDatatableNoHeader(filePath, "DMVT");

                        var results = from myRow in dtDMVT.AsEnumerable()
                                      where TextUtils.ToDecimal(myRow.Field <string>("F1") != "" && myRow.Field <string>("F1") != null
                                      ? myRow.Field <string>("F1").Substring(0, 1) : "") > 0
                                      select myRow;

                        if (results == null)
                        {
                            continue;
                        }
                        if (results.Count() == 0)
                        {
                            continue;
                        }
                        if (results.Count() > 0)
                        {
                            dtDMVT = results.CopyToDataTable();
                        }

                        for (int i = 0; i <= dtDMVT.Rows.Count - 1; i++)
                        {
                            string nameDMVT = dtDMVT.Rows[i]["F4"].ToString();
                            if (nameDMVT == "")
                            {
                                continue;
                            }
                            //string hang = dtDMVT.Rows[i][9].ToString();
                            string MaVatLieu = TextUtils.ToString(dtDMVT.Rows[i]["F5"]).Trim();
                            string VatLieu   = TextUtils.ToString(dtDMVT.Rows[i]["F8"]).Trim();
                            string stt       = TextUtils.ToString(dtDMVT.Rows[i]["F1"]).Trim();

                            List <string> errorString = new List <string>();

                            if (MaVatLieu != "")
                            {
                                DataTable dtMaVatLieu = LibQLSX.Select("SELECT top 1 PartsCode from Parts with(nolock)"
                                                                       + " where PartsCode = N'" + MaVatLieu.Replace(" ", "").Replace("(", "/") + "'");
                                if (dtMaVatLieu.Rows.Count == 0)
                                {
                                    errorString.Add("Mã vật liệu không tồn tại trên QLSX");
                                }
                            }

                            if (VatLieu != "" && VatLieu != "-")
                            {
                                DataTable dtVatLieu = LibQLSX.Select("SELECT top 1 MaterialsId from MaterialsModel with(nolock)"
                                                                     + " where MaterialsId = N'" + VatLieu + "'");
                                if (dtVatLieu.Rows.Count == 0)
                                {
                                    errorString.Add("Vật tư không tồn tại trên QLSX");
                                }
                            }

                            if (MaVatLieu != "" && (VatLieu == "" || VatLieu == "-"))
                            {
                                errorString.Add("Vật tư không có vật liệu");
                            }

                            if (errorString.Count > 0)
                            {
                                DataRow dr = dtError.NewRow();
                                dr["ModuleCode"]   = moduleCode;
                                dr["STT"]          = stt;
                                dr["MaterialCode"] = nameDMVT;
                                dr["MaterialName"] = TextUtils.ToString(dtDMVT.Rows[i]["F2"]);
                                dr["MaVatLieu"]    = MaVatLieu;
                                dr["VatLieu"]      = VatLieu;
                                dr["Error"]        = string.Join(", ", errorString.ToArray());
                                dtError.Rows.Add(dr);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            gridControl1.DataSource = dtError;
            MessageBox.Show("ok");
        }
Ejemplo n.º 34
0
 void closeWaitDlg() {
     if (waitdlg != null) {
         waitdlg.Close();
         waitdlg = null;
     }
 }
        private void btnAccept_Click(object sender, EventArgs e)
        {
            WaitDialogForm _wait = new WaitDialogForm("Đang tải kiểm tra dữ liệu...", "Vui lòng đợi giây lát");

            //try
            //{

            if (Validation())
            {
                _wait.Close();
                return;
            }

            int _countSP = 1;

            for (int i = 0; i < data.Rows.Count; i++)
            {
                _wait.Caption = string.Format("Đang nạp dữ liêu {0}/{1}", i, data.Rows.Count);

                if (this.removeCharacter(data.Rows[i][lueSTT.EditValue + string.Empty] + string.Empty) == "" ||
                    this.removeCharacter(data.Rows[i][lueDonViTinh.EditValue + string.Empty] + string.Empty) == "")
                {
                    continue;
                }

                _countSP++;
                string str = "Insert into DM_SANPHAM_CQLD (SP_STT, SP_TEN, SP_TENHOATCHAT ,SP_NONGDO_HAMLUONG ,SP_SDK_GPKD"
                             + " ,SP_QUYCACH_DONGGOI, SP_DVT, SP_CSSX, SP_CSNK_KEKHAI, SP_THONGTIN_CONGVAN, SP_GIA_KEKHAI, SP_NGAY_KEKHAI, SP_MAU) "
                             + "values (@SP_STT, @SP_TEN, @SP_TENHOATCHAT, @SP_NONGDO_HAMLUONG, @SP_SDK_GPKD, @SP_QUYCACH_DONGGOI, @SP_DVT "
                             + " ,@SP_CSSX,@SP_CSNK_KEKHAI, @SP_THONGTIN_CONGVAN, @SP_GIA_KEKHAI,@SP_NGAY_KEKHAI, @SP_MAU)";

                SqlCommand cmd = new SqlCommand(str, clsConnection._conn);
                cmd.Parameters.Add("@SP_STT", SqlDbType.BigInt).Value = Convert.ToInt64(this.removeCharacter(data.Rows[i][lueSTT.EditValue + string.Empty] + string.Empty));

                if (lueTenThuoc.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_TEN", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueTenThuoc.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_TEN", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueTenHoatChat.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_TENHOATCHAT", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueTenHoatChat.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_TENHOATCHAT", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueHamLuongNongDo.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_NONGDO_HAMLUONG", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueHamLuongNongDo.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_NONGDO_HAMLUONG", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueSDK_GPNK.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_SDK_GPKD", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueSDK_GPNK.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_SDK_GPKD", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueQuyCachDongGoi.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_QUYCACH_DONGGOI", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueQuyCachDongGoi.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_QUYCACH_DONGGOI", SqlDbType.NVarChar).Value = DBNull.Value;
                }


                if (lueDonViTinh.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_DVT", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueDonViTinh.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_DVT", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueCoSoSanXuat.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_CSSX", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueCoSoSanXuat.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_CSSX", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueCSNK_KeKhai.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_CSNK_KEKHAI", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueCSNK_KeKhai.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_CSNK_KEKHAI", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueThongTinCV_NgayCong.EditValue != null)
                {
                    cmd.Parameters.Add("@SP_THONGTIN_CONGVAN", SqlDbType.NVarChar).Value = this.removeCharacter(data.Rows[i][lueThongTinCV_NgayCong.EditValue + string.Empty] + string.Empty);
                }
                else
                {
                    cmd.Parameters.Add("@SP_THONGTIN_CONGVAN", SqlDbType.NVarChar).Value = DBNull.Value;
                }

                if (lueGiaKeKhai.EditValue != null)
                {
                    string giaKeKhai = (data.Rows[i][lueGiaKeKhai.EditValue + string.Empty] + string.Empty);
                    giaKeKhai = giaKeKhai.Replace(" ", "");
                    giaKeKhai = giaKeKhai.Replace(",", "");
                    if (giaKeKhai != "")
                    {
                        cmd.Parameters.Add("@SP_GIA_KEKHAI", SqlDbType.Decimal).Value = Convert.ToDecimal(giaKeKhai);
                    }
                    else
                    {
                        cmd.Parameters.Add("@SP_GIA_KEKHAI", SqlDbType.Decimal).Value = DBNull.Value;
                    }
                }
                else
                {
                    cmd.Parameters.Add("@SP_GIA_KEKHAI", SqlDbType.Decimal).Value = DBNull.Value;
                }


                if (lueNgayKeKhai.EditValue != null)
                {
                    string ngayKeKhai = this.removeCharacter(data.Rows[i][lueNgayKeKhai.EditValue + string.Empty] + string.Empty);
                    if (ngayKeKhai.Trim() != "")
                    {
                        cmd.Parameters.Add("@SP_NGAY_KEKHAI", SqlDbType.Date).Value = Convert.ToDateTime(ngayKeKhai);
                    }
                    else
                    {
                        cmd.Parameters.Add("@SP_NGAY_KEKHAI", SqlDbType.Date).Value = DBNull.Value;
                    }
                }
                else
                {
                    cmd.Parameters.Add("@SP_NGAY_KEKHAI", SqlDbType.Date).Value = DBNull.Value;
                }

                cmd.Parameters.Add("@SP_MAU", SqlDbType.NVarChar).Value = rdMau.EditValue + string.Empty;

                cmd.ExecuteNonQuery();
            }
            _wait.Close();
            ClearEditValue();
        }
Ejemplo n.º 36
0
        /// <summary>
        /// 切换tab触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tabcontrol_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (tabcontrol.SelectedTabPage != tabPagePrint)
            {
                return;
            }
            WaitDialogForm waitDialog = new WaitDialogForm("正在组织打印数据……", "请稍等。");

            try
            {
                //xll 2013-03-26 获取全部数据 点击全部了 就无需再次查找 点击其他的 需要查找
                foreach (XtraTabPage item in tabcontrol.TabPages)
                {
                    if (item.Controls.Count > 0)
                    {
                        UCIncommonNoteTab uCIncommonNoteTab = item.Controls[0] as UCIncommonNoteTab;
                        if (uCIncommonNoteTab != null)
                        {
                            m_inCommonNote = uCIncommonNoteTab.GetAllDetailDate();
                            break;
                        }
                    }
                }
                PrintInCommonView printInCommonView = ConvertPrintEntity();

                iPrintNurse = AbstractorFactry.GetNurseRecord(printInCommonView.PrintFileName);
                SetWaitDialogCaption("正在绘制预览界面……", waitDialog);
                if (iPrintNurse != null && iPrintNurse.IsCustomPrint == true)
                {
                    if (tabPagePrint.Controls == null || tabPagePrint.Controls.Count <= 0)
                    {
                        PrintForm1 printForm1 = new PrintForm1(printInCommonView);
                        printForm1.Dock            = DockStyle.Fill;
                        printForm1.TopLevel        = false;
                        printForm1.FormBorderStyle = FormBorderStyle.None;
                        printForm1.Show();
                        tabPagePrint.Controls.Add(printForm1);
                    }
                    else
                    {
                        PrintForm1 printForm1 = tabPagePrint.Controls[0] as PrintForm1;
                        if (printForm1 != null)
                        {
                            printForm1.m_printInCommonView = printInCommonView;
                            printForm1.RefreshView();
                        }
                    }
                }
                else
                {
                    if (ucPrintRecord == null)
                    {
                        ucPrintRecord = new UCPrintRecord();
                        tabPagePrint.Controls.Add(ucPrintRecord);
                        ucPrintRecord.Dock = DockStyle.Fill;
                    }
                    ucPrintRecord.LoadPrint(printInCommonView);
                }
                waitDialog.Hide();
                waitDialog.Close();
            }
            catch (Exception ex)
            {
                waitDialog.Hide();
                waitDialog.Close();
                DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show(1, ex);
            }
        }
Ejemplo n.º 37
0
        private void barButtonItem30_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm wait = null;
            WordBuilder wb = new WordBuilder();
            wb.InsertFromFile("Very.doc");

            //TONLI.BZH.UI.DSOFramerWordControl wb = new DSOFramerWordControl();
            try
            {
                wait = new WaitDialogForm("", "���ڵ���, ���Ժ�...");

                IList<LayoutContent> ls = Services.BaseService.GetList<LayoutContent>("SelectLayoutContentByLayoutIDBlogData", layoutUID);
                System.Data.DataTable dts = DataConverter.ToDataTable((IList)ls, typeof(LayoutContent));

                //IList<byte[]> lbt = new List<byte[]>();

                IList<LayoutContent> lbt = new List<LayoutContent>();

                InitExe("", dts, lbt);
                GetTop(layoutUID + "|1", wb);

                object obj = "���� 1";

                Style testStyle = wb.wordApp.Application.ActiveDocument.Styles.get_Item(ref obj);
                object listObject = testStyle;
                wb.wordApp.Selection.set_Style(ref listObject);

                InitAdd(lbt, wb);
                GetTop(layoutUID + "|2", wb);

                //IList<LayoutContent> lbt = new List<LayoutContent>();
                //InitExe("", dts, lbt);
                //GetTop(layoutUID + "|1", wb);
                //InitAdd(lbt, wb);
                //GetTop(layoutUID + "|2", wb);
            }
            catch
            {
                wb.Dispose();
                wait.Close();
                MsgBox.Show("����ʧ��");
                return;
            }
            wait.Close();

            string fname = "";
            saveFileDialog1.Filter = "Microsoft word (*.doc)|*.doc";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {

                fname = saveFileDialog1.FileName;
                wb.Save(fname, true);
                wb.Dispose();
                if (MsgBox.ShowYesNo("�����ɹ����Ƿ�򿪸��ĵ���") != DialogResult.Yes)
                    return;
                try
                {
                    System.Diagnostics.Process.Start(fname);
                }
                catch { }
            }
            else
            {

            }
        }
Ejemplo n.º 38
0
        /// <summary>
        /// 初始化界面
        /// </summary>
        private void InitForm()
        {
            WaitDialogForm waitDialog = new WaitDialogForm("正在获取数据……", "请稍等。");

            try
            {
                if (inCommonNoteBiz == null)
                {
                    inCommonNoteBiz = new InCommonNoteBiz(m_app);
                }
                //xll 在初始化列表界面的时候获取值
                //inCommonNoteBiz.GetDetaliInCommonNote(ref m_inCommonNote);
                inCommonNoteBiz.GetIncommTab(ref m_inCommonNote);
                waitDialog.Hide();
                waitDialog.Close();
                //判断选择节点是否被删除,删除则给出提示
                if (m_inCommonNote == null || m_inCommonNote.InCommonNoteFlow == null)
                {
                    DrectSoft.Common.Ctrs.DLG.MyMessageBox.Show("该单据已被他人删除");
                    return;
                }
                //int countItem=  inCommonNoteBiz.GetCommonItemCount(m_inCommonNote.InCommonNoteFlow);
                foreach (var item in m_inCommonNote.InCommonNoteTabList)
                {
                    CommonNote_TabEntity commonNote_TabEntity = null;
                    foreach (var itemTab in m_commonNoteEntity.CommonNote_TabList)
                    {
                        if (itemTab.CommonNote_Tab_Flow == item.CommonNote_Tab_Flow)
                        {
                            commonNote_TabEntity = itemTab;
                            break;
                        }
                    }
                    if (commonNote_TabEntity == null)
                    {
                        continue;
                    }
                    XtraTabPage tabPage = new XtraTabPage();
                    tabPage.Tag  = item;
                    tabPage.Text = item.CommonNoteTabName;
                    if (item.ShowType == "表格")
                    {
                        UCIncommonNoteTab UCIncommonNoteTab = new UCIncommonNoteTab(item, commonNote_TabEntity, m_inCommonNote, m_app, m_canEdit);
                        tabPage.Controls.Add(UCIncommonNoteTab);
                        UCIncommonNoteTab.Dock = DockStyle.Fill;
                    }
                    else
                    {
                        UCInCommonTabSingle ucInCommonTabSingle = new UCInCommonTabSingle(item, commonNote_TabEntity, m_inCommonNote, m_app, m_canEdit);
                        tabPage.Controls.Add(ucInCommonTabSingle);
                        ucInCommonTabSingle.Dock = DockStyle.Fill;
                    }
                    tabcontrol.TabPages.Add(tabPage);
                }
                tabcontrol.SelectedTabPageIndex = 1;
            }
            catch (Exception ex)
            {
                waitDialog.Hide();
                waitDialog.Close();
                throw ex;
            }
        }
Ejemplo n.º 39
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (treeList1.FocusedNode == null)
                return;

            string uid = treeList1.FocusedNode["UID"].ToString();
            LayoutContent obj = Services.BaseService.GetOneByKey<LayoutContent>(uid);
            WaitDialogForm wait=null;

            WordBuilder wb = new WordBuilder();
            //if (fb != null)
            //    wb.InsertFromStreamGzip(fb);

            try
            {
                wait = new WaitDialogForm("", "������������, ���Ժ�...");

                if (obj.Contents != null && obj.Contents.Length > 0)
                {
                    if (fb != null)
                    {
                        wb.InsertFromStreamGzip(obj.Contents);
                        dsoFramerWordControl1.FileData = wb.FileData;
                    }
                    else
                    {
                        dsoFramerWordControl1.FileDataGzip = obj.Contents;
                    }
                }
                else
                {
                    dsoFramerWordControl1.FileNew();
                }
                dsoFramerWordControl1.AxFramerControl.Menubar = true;
                wait.Close();
            }
            catch (Exception ex)
            {
                wait.Close();
            MessageBox.Show(ex.Message);

            }
        }
Ejemplo n.º 40
0
        private void gửiMailKhiĐãKhắcPhụcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                MisMatchModel misMatchModel = (MisMatchModel)MisMatchBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)));
                if (misMatchModel.StatusTK == 0)
                {
                    MessageBox.Show("Vấn đề này chưa được khắc phục!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }
                ModulesModel product = (ModulesModel)ModulesBO.Instance.FindByAttribute("Code", misMatchModel.ModuleCode)[0];

                frmSendEmailAttach frm = new frmSendEmailAttach();
                frm.To = "*****@*****.**";
                frm.CC = //"*****@*****.**";
                         "[email protected];[email protected];[email protected];[email protected];";
                frm.Subject = string.Format("INVALID REPORT - {0} - {1} - Đã khắc phục", misMatchModel.Code, product.Code);
                DataTable dtConfig = TextUtils.Select("select KeyValue from [ConfigSystem] where [KeyName]='TK_To_KCS_KphEmail'");
                string    content  = dtConfig.Rows[0][0].ToString();
                frm.Content = content.Replace("<ErrorCode>", "<b>" + misMatchModel.Code + "</b>")
                              .Replace("<ProjectCode>", "<b>" + misMatchModel.ProjectCode + "</b>")
                              .Replace("<ProductCode>", "<b>" + product.Code + "</b>")
                              .Replace("<ProductName>", product.Name)
                              .Replace("<ErrorStatus>", "<b>Đã khắc phục</b>")
                              .Replace("<Description>", grvData.GetFocusedRowCellValue(colDes).ToString());
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    misMatchModel.ConfirmSendMailTK = Global.AppFullName + " - " + Environment.MachineName + " đã gửi mail vào ngày: " + DateTime.Now;
                    MisMatchBO.Instance.Update(misMatchModel);
                    loadGrid();

                    if (Global.DepartmentID == 1)//phong thiet ke
                    {
                        DataTable dt = TextUtils.Select("select * from ModuleVersion where MisMatchCode = '" + misMatchModel.Code + "'");
                        if (dt.Rows.Count == 0)
                        {
                            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang tạo phiên bản thiết kế"))
                            {
                                try
                                {
                                    string path = TextUtils.DownloadAll(product.Code);

                                    ModuleVersionModel model = new ModuleVersionModel();
                                    model.ProjectCode  = misMatchModel.ProjectCode;
                                    model.ModuleCode   = product.Code;
                                    model.MisMatchCode = misMatchModel.Code;
                                    model.Version      = TextUtils.ToInt(Path.GetFileName(path));
                                    model.Path         = path;
                                    model.Description  = frm.Description;
                                    model.Reason       = "Sửa không phù hợp: " + misMatchModel.Code;
                                    ModuleVersionBO.Instance.Insert(model);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("Lỗi: " + ex.Message);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 41
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang thêm vật tư..."))
                {
                    foreach (DataRow r in frm.dtAll.Rows)
                    {
                        string code = TextUtils.ToString(r["Code"]);
                        if (code == "")
                        {
                            continue;
                        }
                        DataRow[] drs = _dtVT.Select("Code = '" + code + "'");
                        if (drs.Length > 0)
                        {
                            continue;
                        }
                        decimal tonKho = TextUtils.ToDecimal(r["TonKho"]);

                        //string sqlM = "SELECT top 1 * FROM  vGetPriceOfPart with(nolock)"
                        //                + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '"
                        //                + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'"
                        //                + " ORDER BY DateAboutF DESC";
                        //DataTable dtPrice = LibQLSX.Select(sqlM);

                        string    sqlM    = "exec spGetPriceOfPart '" + code.Replace(" ", "").Replace("/", "#").Replace(")", "#") + "'";
                        DataTable dtPrice = LibQLSX.Select(sqlM);

                        DataRow dr = _dtVT.NewRow();
                        dr["Code"]         = r["Code"].ToString();
                        dr["Name"]         = r["Name"].ToString();
                        dr["Hang"]         = r["Hang"].ToString();
                        dr["Unit"]         = r["Unit"].ToString();
                        dr["TonKho"]       = tonKho;
                        dr["DeliveryTime"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);

                        if (dtPrice.Rows.Count > 0)
                        {
                            dr["Price"] = TextUtils.ToDecimal(dtPrice.Rows[0]["Price"]).ToString("n0");
                            if (tonKho >= 1)
                            {
                                dr["Time"] = 1;
                            }
                            else
                            {
                                dr["Time"] = TextUtils.ToInt(dtPrice.Rows[0]["DeliveryTime"]);
                            }

                            DateTime dateP       = TextUtils.ToDate1(txtDateP.Text);
                            int      dateCurrent = TextUtils.ToInt(dr["Time"]);
                            if (dateCurrent < 0)
                            {
                                dr["Description"] = "Chưa phát sinh mua bán";
                            }
                            else
                            {
                                DateTime dateVT = DateTime.Now.AddDays(dateCurrent);
                                if (dateVT.Date <= dateP.Date)
                                {
                                    dr["Status"] = "Đạt";
                                }
                                else
                                {
                                    dr["Status"] = "Không đạt";
                                }
                            }
                        }
                        else
                        {
                            dr["Price"]       = TextUtils.ToDecimal(r["Price"]).ToString("n0");
                            dr["Description"] = "Chưa phát sinh mua bán";
                        }
                        dr["Total"] = TextUtils.ToDecimal(dr["Price"]).ToString("n0");

                        dr["Qty"] = 1;
                        _dtVT.Rows.Add(dr);
                    }
                    txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
                    txtDateM.Text  = TextUtils.ToDecimal(colMaTime.SummaryItem.SummaryValue).ToString("n0");
                }
            }
        }
Ejemplo n.º 42
0
        public static DataSet dataHoSoDauThau(Int64 IdGoiThau)
        {
            //Cập nhật lại trạng thái không cần load dữ liệu nữa chọn tất cả gói thầu
            if (IdGoiThau == 0)
            {
                clsParameter._isLoadHoSoDauThau = false;
            }

            DataSet        ds    = new DataSet();
            WaitDialogForm _wait = new WaitDialogForm("Đang tải dữ liệu đấu thầu ...", "Vui lòng đợi giây lát");

            SqlCommand cmd = new SqlCommand(clsParameter.pStoreDanhGiaHoSoDuThau, clsConnection._conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@GOITHAU_ID", SqlDbType.BigInt).Value = IdGoiThau;
            cmd.Parameters.Add("@DOT_MA", SqlDbType.NVarChar).Value   = clsParameter._dotMaDauThau;
            cmd.Parameters.Add("@SP_MA", SqlDbType.NVarChar).Value    = string.Empty;
            cmd.CommandTimeout = 0;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            da.Fill(ds, "ChiTietHoSo");


            _wait.Caption = "Đang tải sản phẩm ...";
            DataTable dtSP_MA = new DataTable();

            dtSP_MA = DsSanPhamMa(IdGoiThau);

            _wait.Caption = "Đang xét hồ sơ trúng thầu ...";
            string  sp_ma = string.Empty;
            Decimal max_DiemTH;
            Int32   _countRow = dtSP_MA.Rows.Count;

            for (int k = 0; k < _countRow; k++)
            {
                _wait.Caption = string.Format("Đang xét sản phẩm {0}/{1}", k + 1, _countRow);
                sp_ma         = dtSP_MA.Rows[k][0].ToString();

                try
                {
                    max_DiemTH = Convert.ToDecimal(ds.Tables[0].Compute("max(DiemTH)", "SP_MA='" + sp_ma + "' and LOAI_PL=False and VUOTGIA_KH=False and KHONGDAT_KT=False"));
                }
                catch (Exception)
                {
                    max_DiemTH = 0;
                }

                //Nếu sản phẩm đã được trúng thầu từ BTC có nghĩa là cột TT = 1
                //Không xét nữa nữa.
                DataRow[] r = ds.Tables[0].Select(string.Format("SP_MA='{0}' and TT=1", sp_ma));
                if (r.Length > 0)
                {
                    continue;
                }

                //Xét điều kiện trúng thầu.
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["SP_MA"].ToString() == sp_ma &&
                        clsChangeType.change_decimal(ds.Tables[0].Rows[i]["DiemTH"]) > 0 &&
                        clsChangeType.change_bool(ds.Tables[0].Rows[i]["LOAI_PL"]) == false
                        )
                    {
                        if (Convert.ToDecimal(ds.Tables[0].Rows[i]["DiemTH"]) == max_DiemTH)
                        {
                            ds.Tables[0].Rows[i]["TT"] = true;
                            //break;
                        }
                    }
                }
            }

            if (IdGoiThau == 0)
            {
                clsParameter._dataHoSoDauThau = ds;
            }

            _wait.Close();
            return(ds);
        }
Ejemplo n.º 43
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            grvVT.FocusedRowHandle = -1;
            if (grvVT.RowCount == 0)
            {
                return;
            }
            string moduleCode = TextUtils.ToString(grvModuleM.GetFocusedRowCellValue(colCodeM));
            string moduleName = TextUtils.ToString(grvModuleM.GetFocusedRowCellValue(colNameM));

            if (moduleCode == "")
            {
                MessageBox.Show("Bạn phải chọn một module thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            string path             = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string filePath    = Application.StartupPath + "\\Templates\\DuToanSoBo.xlsm";
            string currentPath = path + "\\DTSB." + moduleCode + ".xlsm";

            try
            {
                File.Copy(filePath, currentPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tạo file dự toán sơ bộ!" + Environment.NewLine + ex.Message,
                                TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo dự toán sơ bộ..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(currentPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    workSheet.Cells[3, 3]  = moduleName;
                    workSheet.Cells[3, 11] = "Mã:" + moduleCode;
                    workSheet.Cells[4, 3]  = workSheet.Cells[18, 10] = Global.AppFullName;
                    workSheet.Cells[6, 3]  = txtDateP.Text.Trim();
                    workSheet.Cells[6, 7]  = txtTotalP.Text.Trim();
                    workSheet.Cells[13, 1] = "Tân Phát, ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year;

                    for (int i = grvVT.RowCount - 1; i >= 0; i--)
                    {
                        workSheet.Cells[10, 1]  = i + 1;
                        workSheet.Cells[10, 2]  = grvVT.GetRowCellDisplayText(i, colMaName);
                        workSheet.Cells[10, 3]  = grvVT.GetRowCellDisplayText(i, colMaCode);
                        workSheet.Cells[10, 4]  = grvVT.GetRowCellDisplayText(i, colMaVatLieu);
                        workSheet.Cells[10, 5]  = grvVT.GetRowCellDisplayText(i, colMaHang);
                        workSheet.Cells[10, 6]  = grvVT.GetRowCellDisplayText(i, colMaTime);
                        workSheet.Cells[10, 7]  = grvVT.GetRowCellDisplayText(i, colMaStatus);
                        workSheet.Cells[10, 8]  = grvVT.GetRowCellDisplayText(i, colMaUnit);
                        workSheet.Cells[10, 9]  = grvVT.GetRowCellDisplayText(i, colMaQty);
                        workSheet.Cells[10, 10] = grvVT.GetRowCellDisplayText(i, colMaPrice);
                        workSheet.Cells[10, 11] = grvVT.GetRowCellDisplayText(i, colMaTotal);
                        workSheet.Cells[10, 12] = grvVT.GetRowCellDisplayText(i, colMaDes);
                        ((Excel.Range)workSheet.Rows[10]).Insert();
                    }
                    ((Excel.Range)workSheet.Rows[9]).Delete();
                    ((Excel.Range)workSheet.Rows[9]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
                Process.Start(currentPath);
            }
        }
Ejemplo n.º 44
0
        private void btnReloadData_Click(object sender, EventArgs e)
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu..."))
            {
                string dCode = TextUtils.ToString(cboPhongBan.EditValue);
                int    dID   = TextUtils.ToInt(grvCboPhongBan.GetFocusedRowCellValue(colPhanXuongID));
                int    year  = TextUtils.ToInt(cboYear.SelectedItem);

                DataTable dtData = new DataTable();

                if (dCode.ToUpper() == "P21")
                {
                    string sql = "exec spReportChiPhi_BanGiamDoc " + year;
                    dtData = LibIE.Select(sql);
                }
                else
                {
                    string sql = "exec spReportChiPhi " + year + ", '" + dCode + "'";
                    dtData = LibIE.Select(sql);
                }

                DataRow[] drs = dtData.Select("C_MA = 'C17'");

                if (dCode.ToUpper() == "P21" || dCode.ToUpper() == "P13" || dCode.ToUpper() == "P14") // Ban giam doc, kinh doanh cn, kinh doanh day nghe
                {
                    string    sql      = "SELECT Sum(ISNULL(C_PSNO,0)) XangXe,C_Month FROM [V_XNTC_REPORT] where (C_KMP_MA = 'C17') and C_Year = " + year + " Group by C_Month";
                    DataTable dtXangXe = LibIE.Select(sql);
                    decimal   tyle     = TextUtils.ToDecimal(LibIE.ExcuteScalar("select top 1 TYLE from T_DM_PHANXUONG_KMP where PK_KMP = 41 and PK_PHANXUONG = " + dID));

                    decimal total = 0;
                    for (int i = 1; i <= 12; i++)
                    {
                        try
                        {
                            decimal value    = TextUtils.ToDecimal(dtXangXe.Rows[i - 1]["XangXe"]);
                            decimal giaTriPB = tyle * value / 100;
                            drs[0]["T" + i + "_PB"] = giaTriPB;
                            drs[0]["T" + i]         = giaTriPB;
                            drs[0]["T" + i + "_TT"] = 0;

                            total += giaTriPB;
                        }
                        catch (Exception)
                        {
                        }
                    }

                    drs[0]["Total_PB"] = total;
                    drs[0]["Total_TT"] = 0;
                    drs[0]["Total"]    = total;
                }
                else if (dCode != "")
                {
                    for (int i = 1; i <= 12; i++)
                    {
                        drs[0]["T" + i + "_PB"] = 0;
                        drs[0]["T" + i]         = 0;
                        drs[0]["T" + i + "_TT"] = 0;
                    }

                    drs[0]["Total_PB"] = 0;
                    drs[0]["Total_TT"] = 0;
                    drs[0]["Total"]    = 0;
                }
                else
                {
                    for (int i = 1; i <= 12; i++)
                    {
                        drs[0]["T" + i + "_PB"] = TextUtils.ToDecimal(drs[0]["T" + i + "_TT"]);
                        drs[0]["T" + i]         = TextUtils.ToDecimal(drs[0]["T" + i + "_TT"]);
                        drs[0]["T" + i + "_TT"] = 0;
                    }
                    drs[0]["Total_PB"] = TextUtils.ToDecimal(drs[0]["Total_TT"]);
                    drs[0]["Total_TT"] = 0;
                    drs[0]["Total"]    = TextUtils.ToDecimal(drs[0]["Total_PB"]);
                }

                grdData.DataSource = dtData;
            }
        }
 public void CreateWaitDialog(string caption, string title)
 {
     CloseWaitDialog();
     dlg = new DevExpress.Utils.WaitDialogForm(caption, title);
 }
Ejemplo n.º 46
0
        private void btnCreateTHTL_Click(object sender, EventArgs e)
        {
            if (txtFilePathTHTK.Text.Trim() == "")
            {
                return;
            }
            DataTable dt = TextUtils.ExcelToDatatableNoHeader(txtFilePathTHTK.Text.Trim(), "3");

            string khCuoi  = TextUtils.ToString(dt.Rows[2]["F1"]);
            string duAn    = TextUtils.ToString(dt.Rows[2]["F8"]);
            string HangMuc = TextUtils.ToString(dt.Rows[5]["F12"]);
            string spHD    = TextUtils.ToString(dt.Rows[5]["F1"]);
            string maSPHD  = TextUtils.ToString(dt.Rows[5]["F8"]);

            //DataRow[] drs = dt.Select("F5 like 'TPAD.%' and F13 not like 'VTP%'");
            DataRow[] drs = dt.Select("F5 like 'TPAD.%' and (F13 <> 'VTP' or F13 is null)");

            string localPath = "";

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                localPath = fbd.SelectedPath + "\\THTL - Muc " + HangMuc.Replace(":", "") + " - " + duAn + ".xlsm";
            }
            else
            {
                return;
            }

            string filePath = Application.StartupPath + "\\Templates\\PhongKyThuat\\THTL.xlsm";

            try
            {
                File.Copy(filePath, localPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: File excel đang được mở.");
                return;
            }
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(localPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    workSheet.Cells[4, 1] = khCuoi;
                    workSheet.Cells[4, 5] = "Dự án: " + duAn;
                    workSheet.Cells[4, 6] = HangMuc;

                    workSheet.Cells[5, 1] = spHD;
                    workSheet.Cells[5, 5] = maSPHD;

                    workSheet.Cells[19, 6] = "Hà Nội, Ngày " + string.Format("{0:00}", DateTime.Now.Day)
                                             + " tháng " + string.Format("{0:00}", DateTime.Now.Month)
                                             + " năm " + DateTime.Now.Year;

                    for (int i = drs.Length - 1; i >= 0; i--)
                    {
                        ((Excel.Range)workSheet.Rows[10]).Insert();

                        string code = TextUtils.ToString(drs[i]["F5"]);

                        workSheet.Cells[10, 1] = i + 1;
                        workSheet.Cells[10, 2] = TextUtils.ToString(drs[i]["F2"]).ToUpper();
                        workSheet.Cells[10, 3] = TextUtils.ToString(drs[i]["F3"]).ToUpper();
                        workSheet.Cells[10, 4] = TextUtils.ToString(drs[i]["F4"]).ToUpper();
                        workSheet.Cells[10, 5] = code.ToUpper();
                        workSheet.Cells[10, 6] = "D0.00." + code.Substring(5, 5).ToUpper();
                        workSheet.Cells[10, 7] = TextUtils.ToString(drs[i]["F13"]);
                        //workSheet.Cells[10, 7] = TextUtils.ToString(drs[i][""]);
                    }
                    ((Excel.Range)workSheet.Rows[9]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
            }
            Process.Start(localPath);
        }
Ejemplo n.º 47
0
        private void barBtnRefreshData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            WaitDialogForm newwait = new WaitDialogForm("", "正在更新数据, 请稍候...");
            //生成一个空表用来保存当前表
            FarPoint.Win.Spread.SheetView obj_sheet = null;
            //生成一个空表,行列值都设为0用来做为程序处理时的当前表,这样可以提高处理速度
            FarPoint.Win.Spread.SheetView activesheet = new FarPoint.Win.Spread.SheetView();
            activesheet.RowCount = 0;
            activesheet.ColumnCount = 0;
            //添加空表
            fpSpread1.Sheets.Add(activesheet);
            //保留当前表,以备程序结束后还原当前表
            obj_sheet = fpSpread1.ActiveSheet;
            //将空表设为当前表
            fpSpread1.ActiveSheet = activesheet;

            //更新表3-1
            sh31.Sheet_AddData(fpSpread1.Sheets[0], year, ProjID, SxXjName);
            sh31.CellType(fpSpread1.Sheets[0]);

            //移除空表
            fpSpread1.Sheets.Remove(activesheet);
            //还原当前表
            fpSpread1.ActiveSheet = obj_sheet;
            //设文本自动换行
            fc.Sheet_Colautoenter(fpSpread1);
            newwait.Close();
            MessageBox.Show("更新数据完成!");
        }
Ejemplo n.º 48
0
        private void btnHuongDanSuDung_Click(object sender, EventArgs e)
        {
            if (cboModule.EditValue == null)
            {
                return;
            }
            if (cboVersion.SelectedIndex < 0)
            {
                return;
            }

            string localPath        = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                localPath = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string code     = TextUtils.ToString(cboModule.EditValue).Substring(5, 5);
            string name     = TextUtils.ToString(grvCboModule.GetFocusedRowCellValue(colModuleName)).ToUpper();
            string version  = string.Format("{0:00}", (int)cboVersion.SelectedValue);
            string _pPathDT = Application.StartupPath + "\\Templates\\PhongKyThuat\\";

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu"))
            {
                Word.Application word = new Word.Application();
                Word.Document    doc  = new Word.Document();
                try
                {
                    string fileName = "D0." + version + "." + code + ".docx";
                    try
                    {
                        File.Copy(_pPathDT + "HDSD.docx", (localPath + "\\" + fileName), true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        doc.Close();
                        word.Quit();
                        return;
                    }


                    doc = word.Documents.Open(localPath + "\\" + fileName);
                    doc.Activate();

                    TextUtils.FindReplaceAnywhere(word, "<code>", Path.GetFileNameWithoutExtension(fileName));
                    TextUtils.FindReplaceAnywhere(word, "<name>", name);
                    //TextUtils.FindReplaceAnywhere(word, "<thongso>", TextUtils.ToString(grvCboModule.GetFocusedRowCellValue(colSpecifications)));
                    //TextUtils.RepalaceText(doc, "<thongso>", TextUtils.ToString(grvCboModule.GetFocusedRowCellValue(colSpecifications)));
                    doc.Save();

                    Process.Start(localPath + "\\" + fileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    doc.Close();
                    word.Quit();
                    TextUtils.ReleaseComObject(doc);
                    TextUtils.ReleaseComObject(word);
                }
            }
        }
Ejemplo n.º 49
0
        private void fpSpread_addsheet()
        {
            WaitDialogForm wait = null;
            wait = new WaitDialogForm("", "正在加载数据, 请稍候...");
            try
            {
                //打开Excel表格
                //清空工作表
                fpSpread1.Sheets.Clear();
                fpSpread1.OpenExcel(System.Windows.Forms.Application.StartupPath + "\\xls\\PDWXZ" + year + ".xls");
                fc.SpreadRemoveEmptyCells(fpSpread1);
                //保持格式
                sh31.CellType(fpSpread1.Sheets[0]);

            }
            catch (System.Exception e)
            {
                //如果打开出错则重新生成并保存
                fpSpread1.Sheets.Clear();
                Firstadddata();
                //判断文件夹是否存在,不存在则创建
                if (!Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\xls"))
                {
                    Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\xls");
                }
                //保存excel文件
                fpSpread1.SaveExcel(System.Windows.Forms.Application.StartupPath + "\\xls\\PDWXZ" + year + ".xls");
                //以下是打开文件设表格自动换行

                // 定义要使用的Excel 组件接口
                // 定义Application 对象,此对象表示整个Excel 程序
                Microsoft.Office.Interop.Excel.Application excelApp = null;
                // 定义Workbook对象,此对象代表工作薄
                Microsoft.Office.Interop.Excel.Workbook workBook;
                // 定义Worksheet 对象,此对象表示Execel 中的一张工作表
                Microsoft.Office.Interop.Excel.Worksheet ws = null;
                Microsoft.Office.Interop.Excel.Range range = null;
                excelApp = new Microsoft.Office.Interop.Excel.Application();
                string filename = System.Windows.Forms.Application.StartupPath + "\\xls\\PDWXZ" + year + ".xls";
                workBook = excelApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                for (int i = 1; i <= workBook.Worksheets.Count; i++)
                {

                    ws = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Worksheets[i];
                    //取消保护工作表
                    ws.Unprotect(Missing.Value);
                    //有数据的行数
                    int row = ws.UsedRange.Rows.Count;
                    //有数据的列数
                    int col = ws.UsedRange.Columns.Count;
                    //创建一个区域
                    range = ws.get_Range(ws.Cells[1, 1], ws.Cells[row, col]);
                    //设区域内的单元格自动换行
                    range.WrapText = true;
                    //保护工作表
                    ws.Protect(Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                }
                //保存工作簿
                workBook.Save();
                //关闭工作簿
                excelApp.Workbooks.Close();

            }
            wait.Close();
        }
Ejemplo n.º 50
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            if (PaymentTable.ID == 0)
            {
                MessageBox.Show("Bạn phải lưu lại trước khi xuất file", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            string path             = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string filePath    = Application.StartupPath + "\\Templates\\PhongKeToan\\BKTT.xlsx";
            string currentPath = path + "\\" + PaymentTable.Number + ".xlsx";

            try
            {
                File.Copy(filePath, currentPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tạo bảng kê thanh toán!" + Environment.NewLine + ex.Message,
                                TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(currentPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    workSheet.Cells[6, 1]  = "(Số: " + PaymentTable.Number + ")";
                    workSheet.Cells[21, 8] = "Ngày " + DateTime.Now.ToString("dd/MM/yyyy");

                    DataTable dtItem     = LibQLSX.Select("select * from vPaymentTableItem with(nolock) where PaymentTableID = " + PaymentTable.ID);
                    DataTable dtSupplier = LibQLSX.Select("select Distinct SupplierCode from vPaymentTableItem with(nolock) where PaymentTableID = " + PaymentTable.ID);

                    for (int i = dtSupplier.Rows.Count - 1; i >= 0; i--)
                    {
                        string    supplierCode = TextUtils.ToString(dtSupplier.Rows[i]["SupplierCode"]);
                        DataRow[] drsItem      = dtItem.Select("SupplierCode = '" + supplierCode + "'");
                        decimal   total        = 0;

                        for (int j = drsItem.Length - 1; j >= 0; j--)
                        {
                            ((Excel.Range)workSheet.Cells[18, 9]).Formula  = "=IF(OR($T18=1,$T18=2,$T18=3),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 10]).Formula = "=IF(OR($T18=1,$T18=4,$T18=3),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 11]).Formula = "=IF(OR($T18=4,$T18=3),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 12]).Formula = "=IF(OR($T18=1,$T18=2,$T18=3,$T18=4,$T18=5),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 13]).Formula = "=IF(OR($T18=1),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 14]).Formula = "=IF(OR($T18=4,$T18=3),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 15]).Formula = "=IF(OR($T18=2),\"\",\"-\")";
                            ((Excel.Range)workSheet.Cells[18, 16]).Formula = "=IF(OR($T18=4,$T18=3),\"\",\"-\")";

                            workSheet.Cells[18, 1] = j + 1;
                            workSheet.Cells[18, 2] = TextUtils.ToString(drsItem[j]["Name"]);
                            workSheet.Cells[18, 3] = TextUtils.ToString(drsItem[j]["Content"]);
                            workSheet.Cells[18, 4] = TextUtils.ToString(drsItem[j]["Code"]);
                            workSheet.Cells[18, 5] = TextUtils.ToString(drsItem[j]["Target"]);
                            workSheet.Cells[18, 6] = TextUtils.ToString(drsItem[j]["TotalCash"]);
                            workSheet.Cells[18, 7] = TextUtils.ToString(drsItem[j]["TotalCK"]);

                            //int contractStatus = TextUtils.ToInt(drsItem[j]["ContractStatus"]);

                            workSheet.Cells[18, 9]  = TextUtils.ToString(drsItem[j]["ContractStatusText"]);
                            workSheet.Cells[18, 10] = TextUtils.ToString(drsItem[j]["InvoiceStatusText"]);
                            //workSheet.Cells[10, 11] = TextUtils.ToInt(drsItem[j]["IsPO"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 12] = TextUtils.ToInt(drsItem[j]["IsCongNo"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 13] = TextUtils.ToInt(drsItem[j]["IsCuongVe"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 14] = TextUtils.ToInt(drsItem[j]["IsTTGH"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 15] = TextUtils.ToInt(drsItem[j]["IsGDD"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 16] = TextUtils.ToInt(drsItem[j]["IsVV_DA_NCC"]) > 0 ? "R" : "£";
                            //workSheet.Cells[10, 17] = TextUtils.ToInt(drsItem[j]["IsApproved"]) > 0 ? "R" : "£";
                            workSheet.Cells[18, 18] = TextUtils.ToString(drsItem[j]["Note"]);
                            workSheet.Cells[18, 19] = TextUtils.ToString(drsItem[j]["UserName"]);

                            total += TextUtils.ToDecimal(drsItem[j]["TotalCash"]) +
                                     TextUtils.ToDecimal(drsItem[j]["TotalCK"]);
                            ((Excel.Range)workSheet.Rows[18]).Insert();
                        }

                        workSheet.Cells[18, 2] = supplierCode;
                        workSheet.Cells[18, 8] = total;
                        ((Excel.Range)workSheet.Rows[18]).Font.Bold = true;
                        ((Excel.Range)workSheet.Rows[18]).Font.Size = 10;
                        ((Excel.Range)workSheet.Rows[18]).Insert();
                    }

                    ((Excel.Range)workSheet.Rows[17]).Delete();
                    ((Excel.Range)workSheet.Rows[17]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
                Process.Start(currentPath);
            }
        }
Ejemplo n.º 51
0
        /// 待确认转化为待打印
        private void CommitWaitPrint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridView currentView   = gvTradeWaitConfirm;   //取得当前展示交易的GridView
            int      totalRowCount = currentView.RowCount; //循环获取需要提交的Trade
            DataRow  currentRow    = null;


            WaitDialogForm waitFrm = new WaitDialogForm(Alading.Taobao.Constants.OPERATE_DB_DATA);

            for (int runner = 0; runner < totalRowCount; runner++)
            {
                currentRow = currentView.GetDataRow(runner);
                if (Boolean.Parse(currentRow["IsSelected"].ToString()))
                {
                    if (string.IsNullOrEmpty(currentRow["RealPostFee"].ToString()))
                    {
                        XtraMessageBox.Show("收货人为:" + currentRow["receiver_name"] + "的交易实际邮费没有填写,不能提交,请核查!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                    string customTid   = currentRow["CustomTid"].ToString();
                    string lockedUser  = currentRow["LockedUserName"].ToString();
                    string currentUser = SystemHelper.User.nick;
                    if (currentRow["TradeIsLackProduct"].ToString() == LackProductOrNot.Normal)
                    {
                        #region  判断当前的操作人权限提交
                        if (lockedUser == UNLOCKED.VALUE || lockedUser == currentUser)
                        {
                            #region   调用存储过程提交打印,保持事务原子性
                            int returnValue = TradeService.SummitCommonTrade(customTid, LocalTradeStatus.HasNotSummit, LocalTradeStatus.SummitNotPrint, currentUser);
                            switch (returnValue)
                            {
                            case SummitReturnType.Success:
                                SystemHelper.CreateFlowMessage(customTid, "提交打印成功", "交易提交打印成功", "订单管理");
                                break;

                            case SummitReturnType.StatusChanged:
                                SystemHelper.CreateFlowMessage(customTid, "提交打印失败", "交易状态已经改变", "订单管理");
                                break;

                            case SummitReturnType.GoodsLacked:
                                SystemHelper.CreateFlowMessage(customTid, "提交打印失败", "交易此时处于缺货状态", "订单管理");
                                break;

                            case SummitReturnType.TemplateNeeded:
                                SystemHelper.CreateFlowMessage(customTid, "提交打印失败", "交易还没有选择物流模板", "订单管理");
                                break;
                            }

                            #endregion
                        }
                        else
                        {
                            SystemHelper.CreateFlowMessage(customTid, "提交权限不足", currentUser + " 提交订单,权限不足!", "订单管理");
                        }
                        #endregion
                    }
                }
            }

            waitFrm.Close();
            InitSelectTab();
        }
Ejemplo n.º 52
0
        private void btnExcelDetail_Click(object sender, EventArgs e)
        {
            if (PaymentTable.ID == 0)
            {
                MessageBox.Show("Bạn phải lưu lại trước khi xuất file", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            string path             = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string filePath    = Application.StartupPath + "\\Templates\\PhongKeToan\\MauChungTu.xlsx";
            string currentPath = path + "\\ChungTu-" + PaymentTable.Number + ".xlsx";

            try
            {
                File.Copy(filePath, currentPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tạo bảng kê thanh toán chi tiết!" + Environment.NewLine + ex.Message,
                                TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(currentPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    DataTable dtItem = LibQLSX.Select("select * from vPaymentTableItem with(nolock) where PaymentTableID = " + PaymentTable.ID);

                    for (int i = 0; i < dtItem.Rows.Count; i++)
                    {
                        string orderCode = TextUtils.ToString(dtItem.Rows[i]["Code"]);
                        //if (orderCode == "NCC1016.201702.007")
                        //{
                        //    MessageBox.Show("a");
                        //}
                        string   listProjects = TextUtils.ToString(dtItem.Rows[i]["Target"]);
                        decimal  vat          = TextUtils.ToDecimal(dtItem.Rows[i]["VAT"]);
                        decimal  delivery     = TextUtils.ToDecimal(dtItem.Rows[i]["DeliveryCost"]);
                        decimal  percentPay   = TextUtils.ToDecimal(dtItem.Rows[i]["PercentPay"]);
                        decimal  totalTH      = TextUtils.ToDecimal(dtItem.Rows[i]["TotalTH"]);
                        string[] arrProject   = listProjects.Split(',');
                        if (arrProject.Length == 1)
                        {
                            //workSheet.Cells[8, 1] = i + 1;
                            workSheet.Cells[8, 5]  = orderCode.Length > 7 ? orderCode.Substring(0, 7) : orderCode;
                            workSheet.Cells[8, 19] =
                                (TextUtils.ToDecimal(dtItem.Rows[i]["TotalCash"]) +
                                 TextUtils.ToDecimal(dtItem.Rows[i]["TotalCK"])).ToString();
                            workSheet.Cells[8, 7]  = TextUtils.ToString(dtItem.Rows[i]["Name"]);
                            workSheet.Cells[8, 20] = TextUtils.ToString(dtItem.Rows[i]["DCode"]);
                            workSheet.Cells[8, 21] = TextUtils.ToString(dtItem.Rows[i]["CostCode"]);
                            workSheet.Cells[8, 22] = TextUtils.ToString(dtItem.Rows[i]["Target"]);
                            workSheet.Cells[8, 23] = orderCode;

                            ((Excel.Range)workSheet.Rows[8]).Insert();
                        }
                        else if (arrProject.Length > 1)
                        {
                            //if (orderCode == "NCC1281.201803.017")
                            //{
                            //    MessageBox.Show(orderCode);
                            //}

                            //arrProject = arrProject.OrderByDescending(c => c).ToArray();
                            foreach (string projectCode in arrProject)
                            {
                                decimal total = 0;
                                if (orderCode.Length > 7)
                                {
                                    string sql = "";
                                    //bool isSXC = false;
                                    if (!projectCode.Trim().StartsWith("Mua"))
                                    {
                                        sql = "select sum(TotalPrice) as total from vGetPartWithOrder_New060318 where OrderCode = '" + orderCode +
                                              "' and ProjectCode = '" + projectCode.Trim() + "'";
                                        //isSXC = true;
                                    }
                                    else
                                    {
                                        sql = "select sum(TotalPrice) as total from vGetPartWithOrder_New060318 where OrderCode = '" + orderCode +
                                              "' and (ProjectCode is null or ProjectCode = '')";
                                    }
                                    //DataTable dtSum = LibQLSX.Select(sql);
                                    decimal totalTH_Project   = TextUtils.ToDecimal(LibQLSX.ExcuteScalar(sql));
                                    decimal total_TH_Delivery = (delivery / (totalTH == 0 ? 1 : totalTH) * totalTH_Project) + totalTH_Project;

                                    total = Math.Round((total_TH_Delivery + total_TH_Delivery * vat / 100) * (percentPay / 100));
                                }
                                else
                                {
                                    total = TextUtils.ToDecimal(dtItem.Rows[i]["TotalCash"]) + TextUtils.ToDecimal(dtItem.Rows[i]["TotalCK"]);
                                }

                                workSheet.Cells[8, 5]  = orderCode.Length > 7 ? orderCode.Substring(0, 7) : orderCode;
                                workSheet.Cells[8, 19] = total;
                                workSheet.Cells[8, 7]  = TextUtils.ToString(dtItem.Rows[i]["Name"]);
                                workSheet.Cells[8, 20] = TextUtils.ToString(dtItem.Rows[i]["DCode"]);
                                workSheet.Cells[8, 21] = TextUtils.ToString(dtItem.Rows[i]["CostCode"]);
                                workSheet.Cells[8, 22] = projectCode.Trim();
                                workSheet.Cells[8, 23] = orderCode;

                                ((Excel.Range)workSheet.Rows[8]).Insert();
                            }
                        }
                    }

                    ((Excel.Range)workSheet.Rows[7]).Delete();
                    ((Excel.Range)workSheet.Rows[7]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
                Process.Start(currentPath);
            }
        }
Ejemplo n.º 53
0
 public WaitingMsg()
 {
     this.wait = new WaitDialogForm("Xin vui l\x00f2ng chờ trong gi\x00e2y l\x00e1t", "Đang xử l\x00fd");
 }
Ejemplo n.º 54
0
        private void InitData1()
        {
            if (excelstate)
            {
                IsSave();
            }

            if (treeList1.FocusedNode == null)
                return;

            if (treeList1.FocusedNode.ParentNode == null)
            {
                barEdititem.Enabled=false;
                barDelitem.Enabled = false;
                barCS.Enabled = false;
                barButtonItem5.Enabled = false;
                barSave.Enabled = false;
            }
            else
            {
                barEdititem.Enabled = true ;
                barDelitem.Enabled = true;
                barCS.Enabled = true;
                barButtonItem5.Enabled = true;
                barSave.Enabled = true;
            }

            excelstate = false;

            if (!isloadstate)
                return;

            string uid = treeList1.FocusedNode["UID"].ToString();
            uid1 = uid;
            EconomyAnalysis obj = Services.BaseService.GetOneByKey<EconomyAnalysis>(uid);

            WaitDialogForm wait = null;
            try
            {
                wait = new WaitDialogForm("", "���ڼ�������, ���Ժ�...");
                System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Contents);
                by1 = obj.Contents;
                fpSpread1.Open(ms);

                try
                {
                    fpSpread1.Sheets[0].Cells[0, 0].Text = "����1 " + treeList1.FocusedNode["Title"].ToString() + "��������";
                }
                catch { }

                wait.Close();

                try
                {
                    nianshu1 = int.Parse(fpSpread1.Sheets[8].GetValue(10, 3).ToString());
                }
                catch { }

                try
                {
                    kaishinian = int.Parse(fpSpread1.Sheets[8].GetValue(9, 3).ToString());
                    xiangmunian1 = int.Parse(fpSpread1.Sheets[8].GetValue(13, 3).ToString());
                    lixinian1 = int.Parse(fpSpread1.Sheets[8].GetValue(2, 1).ToString());
                }
                catch { }

            }
            catch { wait.Close(); }
        }
Ejemplo n.º 55
0
 public WaitingMsg(string title, string caption)
 {
     this.wait = new WaitDialogForm(caption, title);
 }
Ejemplo n.º 56
0
        private void IsSave()
        {
            if (!editrights)
                return;

            if (MsgBox.ShowYesNo("�����Ѿ������ı䣬�Ƿ񱣴棿") != DialogResult.Yes)
            {
                return;
            }

            WaitDialogForm wait = null;
            EconomyAnalysis obj = Services.BaseService.GetOneByKey<EconomyAnalysis>(uid1);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            try
            {
                wait = new WaitDialogForm("", "���ڱ�������, ���Ժ�...");
                fpSpread1.Save(ms, false);

                obj.Contents = ms.GetBuffer();
                Services.BaseService.Update("UpdateEconomyAnalysisByContents", obj);
                wait.Close();
                MsgBox.Show("����ɹ�");
                excelstate = false;
            }
            catch
            {
                wait.Close();
                MsgBox.Show("����ʧ��");

            }
        }
Ejemplo n.º 57
0
        /// <summary>
        /// 获取满足需求的商品列表
        /// </summary>
        /// <param name="value"></param>
        /// <param name="si"></param>
        void GetStockItem(string value, StockItemElement si)
        {
            WaitDialogForm waitForm = new WaitDialogForm(Constants.OPERATE_DB_DATA);

            waitForm.Show();
            try
            {
                table.Rows.Clear();
                List <string>            skuOuterIDList = new List <string>();
                List <StockHouseProduct> houseProList   = new List <StockHouseProduct>();//StockHouseService.GetSHProBySkuOuterID(skuOuterIDList);
                if (stockHouseCode == null)
                {
                    List <View_StockItemProduct> stockItemList;
                    if (si == StockItemElement.Name && !string.IsNullOrEmpty(value))
                    {
                        Func <View_StockItemProduct, bool> func = new Func <View_StockItemProduct, bool>(c => c.Name.Contains(value) || c.SkuOuterID.Contains(value));
                        stockItemList = View_StockItemProductService.GetView_StockItemProduct(func, currentIndex, dataPerPage, out allIndex);
                    }
                    else
                    {
                        stockItemList = View_StockItemProductService.GetView_StockItemProduct(value, currentIndex, dataPerPage, ref allIndex);
                    }
                    if (stockItemList == null)
                    {
                        waitForm.Close();
                        XtraMessageBox.Show("没有找到对应的商品!", Constants.SYSTEM_PROMPT);
                        return;
                    }
                    foreach (View_StockItemProduct stockItem in stockItemList)
                    {
                        DataRow           row          = table.NewRow();
                        StockHouseProduct houseProduct = houseProList.Find(c => c.SkuOuterID == stockItem.SkuOuterID);

                        /*读取选中的节点显示名称*/
                        row["Select"]            = false;
                        row["CatName"]           = stockItem.CatName;      //淘宝类目
                        row["Cid"]               = stockItem.Cid;          //淘宝类目
                        row["StockCatName"]      = stockItem.StockCatName; //库存类目名称
                        row["Name"]              = stockItem.Name;         //商品名称
                        row["Num"]               = stockItem.SkuQuantity;  //商品库存总数量
                        row["SaleProps"]         = stockItem.SkuProps_Str; //销售属性
                        row["SkuOuterID"]        = stockItem.SkuOuterID;   //
                        row["Model"]             = stockItem.Model;
                        row["Specification"]     = stockItem.Specification;
                        row["StockUnitName"]     = stockItem.StockUnitName;
                        row["OuterID"]           = stockItem.OuterID;//
                        row[gcTaxCode.FieldName] = stockItem.Tax;
                        //用于展示所选商品的属性
                        row["StockCid"]       = stockItem.StockCid;       //
                        row["Props"]          = stockItem.Props;          //
                        row["InputPids"]      = stockItem.InputPids;      //
                        row["InputStr"]       = stockItem.InputStr;       //
                        row["Property_Alias"] = stockItem.Property_Alias; //

                        #region 入库需要信息
                        row["SkuPrice"] = stockItem.SkuPrice;//销售价
                        if (houseProduct != null)
                        {
                            row["HouseName"]  = houseProduct.HouseName;  //仓库名称
                            row["LayoutName"] = houseProduct.LayoutName; //库位名称
                            row["HouseCode"]  = houseProduct.HouseCode;  //仓库编号
                            row["LayoutCode"] = houseProduct.LayoutCode; //库位编号
                        }
                        #endregion

                        table.Rows.Add(row);
                        skuOuterIDList.Add(stockItem.SkuOuterID);
                    }
                }
                else
                {
                    if (stockHouseCode.Trim() != string.Empty)
                    {
                        List <View_StockProductHouse> stockItemList = View_StockItemProductService.GetView_StockProductHouse(value, stockHouseCode, currentIndex, dataPerPage, ref allIndex);
                        if (stockItemList == null)
                        {
                            return;
                        }
                        if (stockHouseCode != string.Empty)
                        {
                            foreach (View_StockProductHouse stockItem in stockItemList)
                            {
                                DataRow           row          = table.NewRow();
                                StockHouseProduct houseProduct = houseProList.Find(c => c.SkuOuterID == stockItem.SkuOuterID);

                                /*读取选中的节点显示名称*/
                                row["Select"]            = false;
                                row["CatName"]           = stockItem.CatName;      //淘宝类目
                                row["StockCatName"]      = stockItem.StockCatName; //库存类目名称
                                row["Cid"]               = stockItem.Cid;          //淘宝类目
                                row["Name"]              = stockItem.Name;         //商品名称
                                row["Num"]               = stockItem.SkuQuantity;  //商品库存总数量
                                row["SaleProps"]         = stockItem.SkuProps_Str; //销售属性
                                row["SkuOuterID"]        = stockItem.SkuOuterID;   //
                                row["Model"]             = stockItem.Model;
                                row["Specification"]     = stockItem.Specification;
                                row["OuterID"]           = stockItem.OuterID;       //
                                row["StockUnitName"]     = stockItem.StockUnitName; //计量单位
                                row[gcTaxCode.FieldName] = stockItem.Tax;
                                //用于展示所选商品的属性
                                row["StockCid"]       = stockItem.StockCid;       //
                                row["Props"]          = stockItem.Props;          //
                                row["InputPids"]      = stockItem.InputPids;      //
                                row["InputStr"]       = stockItem.InputStr;       //
                                row["Property_Alias"] = stockItem.Property_Alias; //

                                #region 入库需要信息
                                row["SkuPrice"] = stockItem.SkuPrice;//销售价
                                if (houseProduct != null)
                                {
                                    row["HouseName"]  = houseProduct.HouseName;  //仓库名称
                                    row["LayoutName"] = houseProduct.LayoutName; //库位名称
                                    row["HouseCode"]  = houseProduct.HouseCode;  //仓库编号
                                    row["LayoutCode"] = houseProduct.LayoutCode; //库位编号
                                }
                                #endregion
                                table.Rows.Add(row);
                                skuOuterIDList.Add(stockItem.SkuOuterID);
                            }
                        }
                    }
                }

                gridCtrlStockItem.DataSource = table;
                gridViewSelected.BestFitColumns();
                gridViewStockItem.BestFitColumns();

                #region 判断4个分页按钮哪个的enable应为false*/
                if (allIndex <= 1)
                {
                    /*若页码总数为1,则所有分页按钮都为false*/
                    bbtnFirstIndex.Enabled    = false;
                    bbtnNextIndex.Enabled     = false;
                    bbtnPriviousIndex.Enabled = false;
                    bbtnLastIndex.Enabled     = false;
                }
                else if (currentIndex == 1)
                {
                    /*若页码总数不为1但当前页码为1*/
                    bbtnFirstIndex.Enabled    = false;
                    bbtnNextIndex.Enabled     = true;
                    bbtnPriviousIndex.Enabled = false;
                    bbtnLastIndex.Enabled     = true;
                }
                else if (currentIndex < allIndex)
                {
                    /*若页码总数不为1且当前页码不等于1且小于页码总数*/
                    bbtnFirstIndex.Enabled    = true;
                    bbtnNextIndex.Enabled     = true;
                    bbtnPriviousIndex.Enabled = true;
                    bbtnLastIndex.Enabled     = true;
                }
                else if (currentIndex == allIndex)
                {
                    bbtnFirstIndex.Enabled    = true;
                    bbtnNextIndex.Enabled     = false;
                    bbtnPriviousIndex.Enabled = true;
                    bbtnLastIndex.Enabled     = false;
                }
                #endregion

                /*显示当前页码,末尾加个空格避免触发事件*/
                bbtnComboxChangeTo.EditValue = "第" + currentIndex.ToString() + "页" + " ";
                waitForm.Close();
            }
            catch (Exception ex)
            {
                waitForm.Close();
                XtraMessageBox.Show(ex.ToString(), Constants.SYSTEM_PROMPT, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 58
0
        private void barSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
                return;
            string uid = treeList1.FocusedNode["UID"].ToString();
            EconomyAnalysis obj = Services.BaseService.GetOneByKey<EconomyAnalysis>(uid);
            System.IO.MemoryStream ms=new System.IO.MemoryStream();
            WaitDialogForm wait = null;
            try
            {
                wait = new WaitDialogForm("", "���ڱ�������, ���Ժ�...");
                textBox1.Focus();
                fpSpread1.Update();
                fpSpread1.Save(ms, false);

                obj.Contents = ms.GetBuffer();
                Services.BaseService.Update("UpdateEconomyAnalysisByContents", obj);
                excelstate = false;
                wait.Close();
                MsgBox.Show("����ɹ�");

            }
            catch (Exception ex) { wait.Close();
                MsgBox.Show("����ʧ��");}
        }
Ejemplo n.º 59
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string strSQL = "where 1=1 and (type='非生产物资入库单' or type='非生产物资出库单' ) ";
            int i = 0;

            
            WaitDialogForm wdf = new WaitDialogForm("", "正在查询数据...");
            try
            {
                if (comboBoxEdit1.Text != "")
                    strSQL += " and ssgc='" + comboBoxEdit1.Text + "' ";
                if (comboBoxEdit2.Text != "")
                    strSQL += " and ssxm='" + comboBoxEdit2.Text + "' ";
                if (comboBoxEdit3.Text != "")
                    strSQL += " and wpmc='" + comboBoxEdit3.Text + "' ";
                if (comboBoxEdit4.Text != "")
                    strSQL += " and wpgg='" + comboBoxEdit4.Text + "' ";
                if (comboBoxEdit5.Text != "")
                    strSQL += " and type='" + comboBoxEdit5.Text + "' ";
                if (comboBoxEdit6.Text != "")
                    strSQL += " and yt='" + comboBoxEdit6.Text + "' ";
                if (checkEdit1.Checked && checkEdit2.Checked)
                {
                    strSQL = strSQL + " and ((indate between  '" + deCreatTimeStart.DateTime.ToString("d") + " 00:00:00' and '" + deCreatTimeEnd.DateTime.ToString("d") + " 23:59:59'  and (type like '%入库单'  )  ) "
                        + " or (ckdate between  '" + deEditTimeStart.DateTime.ToString("d") + " 00:00:00' and '" + deEditTimeEnd.DateTime.ToString("d") + " 23:59:59' and (type like '%出库单' or type like '%材料单' )  )) ";
                }
                else
                    if (checkEdit1.Checked && deCreatTimeStart.Text != "")
                {
                    strSQL = strSQL + " and (indate between  '" + deCreatTimeStart.DateTime.ToString("d") + " 00:00:00' and '" + deCreatTimeEnd.DateTime.ToString("d") + " 23:59:59' and (type like '%入库单'  ) ) ";
                }
                    else
                if (checkEdit2.Checked && deEditTimeStart.Text != "")
                {
                    strSQL = strSQL + " and (ckdate between  '" + deEditTimeStart.DateTime.ToString("d") + " 00:00:00' and '" + deEditTimeEnd.DateTime.ToString("d") + " 23:59:59'  and (type like '%出库单' or type like '%材料单' ) ) ";
                }
                ucsctz1.StrSQL = (strSQL);

            }
            catch { }
           
            
            wdf.Close();
        }
Ejemplo n.º 60
0
        private void _saveData()
        {
            if (_validateControl())
            {
                WaitDialogForm _wait = new WaitDialogForm("Đang lưu dữ liệu ...", "Vui lòng đợi giây lát");
                using (var _context = new QL_HOIVIEN_KTEntities())
                {
                    QL_HOATDONG_NHATAITRO item;
                    switch (_formStatus)
                    {
                    case EnumFormStatus.ADD:

                        item = new QL_HOATDONG_NHATAITRO();
                        _setObjectEntities(ref item);
                        idRowSelected = _maxID();
                        item.NTT_ID   = idRowSelected;
                        data.Add(item);

                        break;

                    case EnumFormStatus.MODIFY:
                        Int64 id = Convert.ToInt64(gvGrid.GetFocusedRowCellValue(colNTT_ID));
                        item = (from p in data where p.NTT_ID == id select p).FirstOrDefault();
                        if (item != null)
                        {
                            _setObjectEntities(ref item);
                        }

                        data.Where(p => p.NTT_ID == id).ToList().ForEach(p => p = item);
                        break;

                    case EnumFormStatus.DELETE:
                        Int64 deleteId = Convert.ToInt64(gvGrid.GetFocusedRowCellValue(colNTT_ID));
                        item = (from p in data where p.NTT_ID == deleteId select p).FirstOrDefault();
                        CategoryHoatDong enumLoai = (CategoryHoatDong)_loaiHoatDongId;
                        switch (enumLoai)
                        {
                        case CategoryHoatDong.ASXH:
                            if (item != null)
                            {
                                if (item.ASXH_ID == null)
                                {        //Nếu là dòng mới thì xóa luôn
                                    data.Remove(item);
                                }
                                else
                                {
                                    data.Where(p => p.NTT_ID == deleteId).ToList().ForEach(p => p.ASXH_ID = clsParameter.statusDeleted);
                                }
                            }
                            break;

                        case CategoryHoatDong.HNXH:
                            if (item != null)
                            {
                                if (item.HNXH_ID == null)
                                {        //Nếu là dòng mới thì xóa luôn
                                    data.Remove(item);
                                }
                                else
                                {
                                    data.Where(p => p.NTT_ID == deleteId).ToList().ForEach(p => p.HNXH_ID = clsParameter.statusDeleted);
                                }
                            }
                            break;

                        case CategoryHoatDong.KHAC:
                            if (item != null)
                            {
                                if (item.KHAC_ID == null)
                                {        //Nếu là dòng mới thì xóa luôn
                                    data.Remove(item);
                                }
                                else
                                {
                                    data.Where(p => p.NTT_ID == deleteId).ToList().ForEach(p => p.KHAC_ID = clsParameter.statusDeleted);
                                }
                            }
                            break;

                        default:
                            break;
                        }


                        break;

                    default:
                        break;
                    }
                    _context.SaveChanges();
                }
                FormStatus = EnumFormStatus.VIEW;
                _wait.Close();
            }
        }