Ejemplo n.º 1
0
        /// <summary>
        /// 用于更新sale00相应产品使用退货的功能
        /// </summary>
        /// <param name="sale_id">销售单号</param>
        /// <param name="totmoney">总退货额</param>
        /// <param name="qty">总退货数量</param>
        /// <returns>bool</returns>
        public bool UpdateSale00(string sale_id, decimal totmoney, double qty)
        {
            bool     a        = false;
            DateTime datetime = DateTime.Now;

            try
            {
                string sql = "UPDATE sale00 SET BACK_SALES=" + totmoney + ", BACK_QUAN=" + qty + ", LAST_UPDATE='" + datetime + "' ,STATUS_ID='3',transfer_status='0' WHERE SALE_ID='" + sale_id + "'";
                a = base.RunSQL(sql);
            }
            catch
            {
                string da  = datetime.ToString("yyyy-MM-dd HH:mm:ss");
                string sql = "UPDATE sale00 SET BACK_SALES=" + totmoney + ", BACK_QUAN=" + qty + ", LAST_UPDATE='" + da + "' ,STATUS_ID='3',transfer_status='0' WHERE SALE_ID='" + sale_id + "'";
                a = base.RunSQL(sql);
            }
            if (a)
            {
                try
                {
                    ReadIni readIni     = new ReadIni("config.ini");
                    string  srvIp       = readIni.ReadString("RepastErp", "txtServerIP");
                    string  srvPort     = readIni.ReadString("RepastErp", "txtPort");
                    string  srvDBName   = readIni.ReadString("RepastErp", "txtIPdataname");
                    string  srvUserName = readIni.ReadString("RepastErp", "txtFTPuser");
                    string  srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword");
                    string  sql         = "begin " + "UPDATE sale01 SET  transfer_status='0' WHERE SALE_ID='" + sale_id + "';" + "UPDATE sale02 SET  transfer_status='0' WHERE SALE_ID='" + sale_id + "';" + "delete from OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.sale00 where shop_id='" + Info.shop_id + "' and sale_id='" + sale_id + "';end";

                    DBSql.SRunSQL(sql);
                }
                catch { }
            }
            return(a);
        }
 /// <summary>
 /// 基本分析窗体初始化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Analyze_Load(object sender, EventArgs e)
 {
     ini      = new ReadIni();
     data3    = new DataOperation(ini.ReadString("filePath"));
     filepath = ini.ReadString("fielPath");
     data2    = new DataOperation();
     //获取当前时间
     System.DateTime dateTimes = System.DateTime.Now;
     Time_LS.Text = dateTimes.ToString("yyyy-MM-dd");
     button_search_Click(0);
 }
        /// <summary>
        /// 构造方法
        /// </summary>
        public FrmMain()
        {
            InitializeComponent();
            this.Width  = (Screen.PrimaryScreen.WorkingArea.Width) * 6 / 7;
            this.Height = (Screen.PrimaryScreen.WorkingArea.Height) * 18 / 19;

            ReadIni ini     = new ReadIni();
            string  version = ini.ReadString("version");

            if (version == "")
            {
                version = ini.ReadString("tempversion");
            }
            this.Text = "干部信息管理系统(" + version + "---上报端)";
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 窗体关闭时所进行的操作,程序退出。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UnitForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!LoginMain)
     {
         ReadIni readIni = new ReadIni();
         if (readIni.ReadString("version") == "")
         {
             Application.Exit();
         }
         string filePath1 = readIni.ReadString("filePath");
         if (filePath1.Equals("") || System.IO.File.Exists(filePath1) == false)
         {
             Application.Exit();
         }
     }
 }
        /// <summary>
        /// 修改密码的确定键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            ReadIni readIni = new ReadIni();

            if (readIni.ReadString("password").Equals(oldPassWord.Text))
            {
                if (newPassWord.Text.Equals(confirm.Text))
                {
                    readIni.WriteString("password", newPassWord.Text);
                    MessageBox.Show("密码修改成功!", "提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("新密码与确认密码不一致!", "提示");
                    oldPassWord.Text = "";
                    newPassWord.Text = "";
                    confirm.Text     = "";
                }
            }
            else
            {
                MessageBox.Show("原始密码不正确!", "提示");
                oldPassWord.Text = "";
                newPassWord.Text = "";
                confirm.Text     = "";
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 设置单位类别
        /// </summary>
        private void SetUnitClass()
        {
            ReadIni readIni     = new ReadIni();
            string  tempversion = readIni.ReadString("tempversion");

            if (tempversion.Equals(""))
            {
                tempversion = readIni.ReadString("version");
            }
            DataTable dt = dataOperation.GetOneDataTable_sql("select  unitClass from TB_GradeUnitClass where version='" + tempversion + "'");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBox_select.Items.Add(dt.Rows[i]["unitClass"].ToString());
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 构造方法
 /// </summary>
 public FrmSearchForm()
 {
     InitializeComponent();
     ini     = new ReadIni();
     version = ini.ReadString("version");
     //读取所有单位的信息表
     a2 = new DataOperation(Application.StartupPath + "\\DB\\DBHBMSU.db");
 }
        /// <summary>
        /// 初始化单位类型
        /// </summary>
        private void SetUnitClass()
        {
            DataOperation dataOperation = new DataOperation(Application.StartupPath + "\\DB\\DBHBMSU.db");
            ReadIni       readIni       = new ReadIni();
            string        tempversion   = readIni.ReadString("tempversion");

            if (tempversion == "")
            {
                tempversion = readIni.ReadString("version");
            }
            DataTable dt = dataOperation.GetOneDataTable_sql("select  unitClass from TB_GradeUnitClass where version='" + tempversion + "'");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBox_unitKind.Items.Add(dt.Rows[i]["unitClass"].ToString());
            }
        }
        /// <summary>
        /// 根据用户名从服务器的pos_rounds表中获取登录有关的信息
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>DataSet</returns>
        public DataSet GetOnlineInfo(string userName)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0]       = new SqlParameter("@USER_ID", SqlDbType.NVarChar);
            para[0].Value = userName;


            ReadIni readIni     = new ReadIni("config.ini");
            string  srvIp       = readIni.ReadString("RepastErp", "txtServerIP");
            string  srvPort     = readIni.ReadString("RepastErp", "txtPort");
            string  srvDBName   = readIni.ReadString("RepastErp", "txtIPdataname");
            string  srvUserName = readIni.ReadString("RepastErp", "txtFTPuser");
            string  srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword");
            string  str         = " select * from OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.POS_ROUNDS where user_id=@USER_ID and exit_date is null";

            return(DBSql.SCreateDataSet(str, para));
        }
 /// <summary>
 /// 读取info.ini信息
 /// </summary>
 /// <param name="key">关键字</param>
 /// <returns>关键字对应的值(读取失败返回空字符串)</returns>
 public string GetIniInfo(string key)
 {
     try
     {
         return(readIniInfo.ReadString("RepastErp", key));
     }
     catch
     {
         return("");
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 关闭本窗体
        /// </summary>
        public void CloseCurrentWindow()
        {
            ReadIni readIni = new ReadIni();

            if (System.IO.File.Exists(readIni.ReadString("filePath")))
            {
                if (ci != null)
                {
                    ci.nowUnit.Text = readIni.ReadString("unitName");
                    ci.listView.Items.Clear();
                    ci.insertPanel.Visible = true;
                }
            }
            else
            {
                readIni.WriteString("filePath", "");//清空ini文件中的路径信息
                Application.Exit();
            }
            this.Close();
        }
        /// <summary>
        /// 综合管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click_Insert(object sender, EventArgs e)
        {
            if (controlMain.nowUnit.Text.Equals(""))
            {
                MessageBox.Show("请先创建数据文件!", "提示");
                return;
            }
            ReadIni readIni = new ReadIni();

            cp.Visible = false;
            if (readIni.ReadString("filePath").Equals(Application.StartupPath + "\\DB\\Default.db"))
            {
                controlMain.listView.Items.Clear();
            }
            controlMain.Visible = true;
            controlMain.tabControl1.TabPages[0].Text = "录入管理";
            controlMain.reservenamesheet_pB.Visible  = true;
            controlMain.regist_pB.Visible            = false;
            controlMain.talk_pB.Visible    = true;
            controlMain.Meeting_pB.Visible = true;

            controlMain.All_pB.Visible         = true;
            controlMain.All_pB.BackgroundImage = Properties.Resources.AllPeoplein;
            controlMain.reservenamesheet_pB.BackgroundImage = Properties.Resources.NameSheet;
            controlMain.regist_pB.BackgroundImage           = Properties.Resources.SituationRegiste;
            controlMain.talk_pB.BackgroundImage             = Properties.Resources.Dialog;  //另存为
            controlMain.Meeting_pB.BackgroundImage          = Properties.Resources.meeting; //关闭

            controlMain.reservenamesheet_pB.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
            controlMain.regist_pB.BackgroundImageLayout           = System.Windows.Forms.ImageLayout.Zoom;
            controlMain.talk_pB.BackgroundImageLayout             = System.Windows.Forms.ImageLayout.Zoom;
            controlMain.Meeting_pB.BackgroundImageLayout          = System.Windows.Forms.ImageLayout.Zoom;

            controlMain.allpeople_Lb.Visible     = true;
            controlMain.label_meeting.Visible    = true;
            controlMain.label_talk.Visible       = true;
            controlMain.label_name_sheet.Visible = true;
            controlMain.label_regist.Visible     = false;

            controlMain.allpeople_Lb.Text     = "基本信息采集";
            controlMain.label_meeting.Text    = "简要情况登记";
            controlMain.label_talk.Text       = "其他信息采集";
            controlMain.label_name_sheet.Text = "考察材料";

            controlMain.panelStyle = "insert";
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 窗体加载事件处理,判断用户是否已经选择版本号.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmLogin_Load(object sender, EventArgs e)
        {
            if (readIni.ReadString("version") != "" && File.Exists(readIni.ReadString("filepath")))
            {
                this.Text            = this.Text + "(" + readIni.ReadString("version") + "---上报端)";
                radioButton1.Visible = false;
                radioButton2.Visible = false;
                radioButton3.Visible = false;
            }
            else
            {
                this.Text = this.Text + "(上报端)";
                string tempversion = readIni.ReadString("version");
                if (tempversion != "")
                {
                    this.Text            = this.Text + "(" + readIni.ReadString("version") + "---上报端)";
                    radioButton1.Visible = true;
                    radioButton2.Visible = true;
                    radioButton3.Visible = true;

                    switch (tempversion)
                    {
                    case "市(厅)级":
                        radioButton1.Checked = true;
                        break;

                    case "县(处)级":
                        radioButton2.Checked = true;
                        break;

                    case "乡(科)级":
                        radioButton3.Checked = true;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 点击创建数据文件的事件的处理,创建数据文件。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_sure_Click(object sender, EventArgs e)
        {
            try
            {
                ReadIni readini = new ReadIni();
                if (!label_showUnit.Text.Equals("") && !label_showUnit.Text.Equals(string.Empty))
                {
                    saveFileDialog1.Filter = ".hbs文件|*.hbs";
                    string newPath = "C:\\HBGB";
                    if (!Directory.Exists(newPath))
                    {
                        Directory.CreateDirectory(newPath);
                    }
                    saveFileDialog1.InitialDirectory = newPath;
                    saveFileDialog1.FileName         = label_showUnit.Text;
                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        this.ControlBox = false;

                        button_sure.Enabled = false;

                        button_regist.Enabled = false;

                        comboBox_select.Enabled = false;

                        listView1.Enabled = false;

                        string filepath = saveFileDialog1.FileName.ToString();

                        Object path = (Object)filepath;//把filePath转换为object的对象
                        run1(path);

                        readini.WriteString("unitName", label_showUnit.Text);

                        readini.WriteString("unitClass", comboBox_select.Text.ToString());

                        string s = readini.ReadString("tempversion");

                        if (s != "")
                        {
                            //记录版本
                            readini.WriteString("version", s);
                            readini.WriteString("tempversion", "");
                        }
                        if (!LoginMain)
                        {
                            frmlogin.IsSuccessful = true;
                        }

                        if (System.IO.File.Exists(readini.ReadString("filePath")))
                        {
                            if (ci != null)
                            {
                                ci.nowUnit.Text = label_showUnit.Text;
                                ci.listView.Items.Clear();
                                ci.insertPanel.Visible = true;
                            }
                        }
                        else
                        {
                            readini.WriteString("filePath", "");//清空ini文件中的路径信息
                            Application.Exit();
                        }
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("单位选择不能为空", "提示");
                }
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// 查询读取收银员帐
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet Cashier(int select)
        {
            #region//查询收银员的总营业额
            if (select == 0)
            {
                sqlstr = "Select SALE_USER, SUM(TOT_SALES) from SALE00 where SALE_USER ="******" GROUP BY sale_user ";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
            #region//查询收银员的本月营业额
            else if (select == 1)
            {
                string monthstr0 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-1 0:0:0";
                string monthstr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " 0:0:0";
                sqlstr = "select SALE_USER ,sum(tot_sales) from sale00 where sale_user='******' and SALE_DATE BETWEEN '" + monthstr0 + "' and '" + monthstr1 + "' GROUP BY sale_user";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
            #region//查询收营员的本周营业额
            else if (select == 2)
            {
                string weekstr = "";
                int    week    = Convert.ToInt32(DateTime.Now.DayOfWeek);
                if (DateTime.Now.Day - week > 0)
                {
                    weekstr = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day - week).ToString() + " 0:0:0";
                }
                else if (DateTime.Now.Day - week <= 0)
                {
                    switch (DateTime.Now.Month - 1)
                    {
                    case 1:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "1-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 3:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "3-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 5:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "5-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 7:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "7-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 8:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "8-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 10:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "10-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 4:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "4-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 6:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "6-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 9:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "9-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 11:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "11-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 2:
                        if ((DateTime.Now.Year % 4 == 0 && DateTime.Now.Year % 100 != 0) || DateTime.Now.Year % 400 == 0)
                        {
                            weekstr = DateTime.Now.Year.ToString() + "-" + "2-" + (29 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                            break;
                        }
                        else
                        {
                            weekstr = DateTime.Now.Year.ToString() + "-" + "2-" + (28 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                            break;
                        }

                    default:
                        weekstr = (DateTime.Now.Year - 1).ToString() + "-" + "12-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;
                    }
                }
                string weekstr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " 0:0:0";
                sqlstr = "select SALE_USER ,sum(tot_sales) from sale00 where  sale_user='******' and SALE_DATE BETWEEN '" + weekstr + "' and '" + weekstr1 + "' GROUP BY sale_user";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
            #region//查询收银员的今日营业额
            else
            {
                ReadIni  readini = new ReadIni();
                DateTime dt;
                try
                {
                    dt = Convert.ToDateTime(readini.ReadString("RepastErp", "changeWorkTime"));
                }
                catch { dt = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + " 0:0:0"); }

                string daystr0 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + " " + dt.Hour.ToString() + ":" + dt.Minute.ToString() + ":" + dt.Second.ToString();       // " 0:0:0";
                string daystr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " " + dt.Hour.ToString() + ":" + dt.Minute.ToString() + ":" + dt.Second.ToString(); // " 0:0:0";
                sqlstr = "select SALE_USER ,sum(tot_sales) from sale00 where sale_user='******' and SALE_DATE BETWEEN '" + daystr0 + "' and '" + daystr1 + "' GROUP BY sale_user";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
        }
        /// <summary>
        /// 查询本店营业额
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet ShopTur(int select)
        {
            //后台服务器信息
            ReadIni readIni     = new ReadIni("config.ini");
            string  srvIp       = readIni.ReadString("RepastErp", "txtServerIP");
            string  srvPort     = readIni.ReadString("RepastErp", "txtPort");
            string  srvDBName   = readIni.ReadString("RepastErp", "txtIPdataname");
            string  srvUserName = readIni.ReadString("RepastErp", "txtFTPuser");
            string  srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword");
            string  str         = "OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.";

            //#region//查询本店的总营业额
            //if (select == 0)
            //{
            //    sqlstr = " Select shop_id, SUM(TOT_SALES) from SALE00 where shop_id = '" + Info.shop_id + "' GROUP BY shop_id";
            //    return base.CreateDataSet(sqlstr);
            //}
            //#endregion #endregion
            #region//查询本店当月营业额
            if (select == 1)
            {
                string monthstr0 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-1 0:0:0";
                string monthstr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " 0:0:0";
                sqlstr = "select shop_id ,sum(tot_sales) from " + str + "sale00 where shop_id='" + Info.shop_id + "' and SALE_DATE BETWEEN '" + monthstr0 + "' and '" + monthstr1 + "' GROUP BY shop_id";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
            #region //查询本店本周营业额
            else if (select == 2)
            {
                string weekstr = "";
                int    week    = Convert.ToInt32(DateTime.Now.DayOfWeek);
                if (DateTime.Now.Day - week > 0)
                {
                    weekstr = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day - week).ToString() + " 0:0:0";
                }
                else if (DateTime.Now.Day - week <= 0)
                {
                    switch (DateTime.Now.Month - 1)
                    {
                    case 1:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "1-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 3:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "3-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 5:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "5-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 7:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "7-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 8:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "8-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 10:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "10-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 4:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "4-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 6:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "6-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 9:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "9-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 11:
                        weekstr = DateTime.Now.Year.ToString() + "-" + "11-" + (30 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;

                    case 2:
                        if ((DateTime.Now.Year % 4 == 0 && DateTime.Now.Year % 100 != 0) || DateTime.Now.Year % 400 == 0)
                        {
                            weekstr = DateTime.Now.Year.ToString() + "-" + "2-" + (29 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                            break;
                        }
                        else
                        {
                            weekstr = DateTime.Now.Year.ToString() + "-" + "2-" + (28 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                            break;
                        }

                    default:
                        weekstr = (DateTime.Now.Year - 1).ToString() + "-" + "12-" + (31 + DateTime.Now.Day - week).ToString() + " 0:0:0";
                        break;
                    }
                }
                string weekstr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " 0:0:0";
                sqlstr = "select shop_id ,sum(tot_sales) from " + str + " sale00 where shop_id='" + Info.shop_id + "' and SALE_DATE BETWEEN '" + weekstr + "' and '" + weekstr1 + "' GROUP BY shop_id";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
            #region//查询本店的当日营业额
            else
            {
                string daystr0 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + " 0:0:0";
                string daystr1 = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day + 1).ToString() + " 0:0:0";
                sqlstr = "select shop_id ,sum(tot_sales) from  " + str + " sale00 where shop_id='" + Info.shop_id + "' and SALE_DATE BETWEEN '" + daystr0 + "' and '" + daystr1 + "' GROUP BY shop_id";
                return(base.CreateDataSet(sqlstr));
            }
            #endregion
        }
        /// <summary>
        /// 如果满足条件,清空交班点时间
        /// </summary>
        public void ClearTime()
        {
            //交班点
            int timePoint;
            //上次上线时间
            DateTime preLoginTime;
            //交班时间
            DateTime changeWorkTime;
            //本次登录时间
            DateTime nowLoginTime = DateTime.Now;

            try
            {
                preLoginTime = Convert.ToDateTime(readIni.ReadString("RepastErp", "preLoginTime"));
                //changeWorkTime = Convert.ToDateTime(readIni.ReadString("RepastErp", "changeWorkTime"));
                //timePoint = Convert.ToInt32(changeWorkTime.Hour);
            }
            catch { return; }

            //截取空格后的字符串
            // string s1 = changeWorkTime.ToString();
            //string s2 = s1.Substring(s1.IndexOf(" ") + 1);
            string s2 = readIni.ReadString("RepastErp", "changeWorkTime");

            timePoint = Convert.ToInt32(s2.Substring(0, 2));
            if (timePoint >= 0 && timePoint <= 6)
            {
                //截取空格前的字符串
                string s3 = nowLoginTime.ToString();
                string s4 = s3.Substring(0, s3.IndexOf(" "));
                string s  = s2 + " " + s4;
                //若交班时间是凌晨以后,则交班时间的年月日跟当前时间相同
                changeWorkTime = Convert.ToDateTime(s);
            }
            else
            {
                //截取空格前的字符串
                string s3 = preLoginTime.ToString();
                string s4 = s3.Substring(0, s3.IndexOf(" "));
                string s  = s2 + " " + s4;
                //若交班时间是凌晨以前,则交班时间的年月日跟上次登录时间相同
                changeWorkTime = Convert.ToDateTime(s);
            }

            //如第二次上线时间大于交班时间
            if (DateTime.Compare(nowLoginTime, changeWorkTime) >= 0 && DateTime.Compare(changeWorkTime, preLoginTime) >= 0)
            {
                //清空配置文件config.ini中的班次
                readIni.WriteString("RepastErp", "workNumber", "0");
                //清空Info.ini配置文件中的交易号
                ReadIni readIni1 = new ReadIni("Info.ini");
                readIni1.WriteString("RepastErp", "deal_number", "1");
                ReadIni readIniInfo = new ReadIni("Info.ini");
                readIniInfo.WriteString("RepastErp", "isNormalOff", "true");
                string oldSaleId = readIniInfo.ReadString("RepastErp", "sale_id");
                try
                {
                    DBSql.SRunSQL("delete saletmp00 where sale_id=" + oldSaleId + "");
                    DBSql.SRunSQL("delete saletmp01 where sale_id=" + oldSaleId + "");
                    DBSql.SRunSQL("delete saletmp02 where sale_id=" + oldSaleId + "");
                }
                catch { }
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public FrmLogin()
 {
     InitializeComponent();
     readIni  = new ReadIni();
     filePath = readIni.ReadString("filePath");
 }
        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string  str = "select * from employee where emp_id =" + Info.emp_id;
            DataSet ds  = DBSql.SCreateDataSet(str);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                string md5PassDB       = ds.Tables[0].Rows[0]["PASSWORD"].ToString();
                string oldmd5PassInput = InfoToMD5(oldPassWord.Text);
                string newMD5Pass      = InfoToMD5(newPassWord.Text);
                if (md5PassDB.Equals(oldmd5PassInput))
                {
                    if (newPassWord.Text.Equals(confirm.Text))
                    {
                        if (newPassWord.Text.Trim() == "")
                        {
                            MessageBox.Show("密码不可为空", "消息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        //往服务器中插入交班信息
                        ReadIni readIni     = new ReadIni("config.ini");
                        string  srvIp       = readIni.ReadString("RepastErp", "txtServerIP");
                        string  srvPort     = readIni.ReadString("RepastErp", "txtPort");
                        string  srvDBName   = readIni.ReadString("RepastErp", "txtIPdataname");
                        string  srvUserName = readIni.ReadString("RepastErp", "txtFTPuser");
                        string  srvPassword = readIni.ReadString("RepastErp", "txtFTPpassword");
                        string  sql         = "update OPENDATASOURCE('SQLOLEDB','Data Source=" + srvIp + "," + srvPort + ";User ID=" + srvUserName + ";Password="******"' )." + srvDBName + ".dbo.employee set PASSWORD='******' where emp_id=" + Info.emp_id;
                        string  sql2        = "update employee set PASSWORD='******' where emp_id=" + Info.emp_id;
                        bool    b           = DBSql.SRunSQL(sql2);
                        b = DBSql.SRunSQL(sql);
                        if (b)
                        {
                            MessageBox.Show("密码修改成功!");
                        }
                        else
                        {
                            MessageBox.Show("密码修改失败!");
                        }
                        oldPassWord.Text = "";
                        newPassWord.Text = "";
                        confirm.Text     = "";
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("新密码与确认密码不一致!");
                        oldPassWord.Text = "";
                        newPassWord.Text = "";
                        confirm.Text     = "";
                    }
                }
                else
                {
                    MessageBox.Show("原始密码不正确!");
                    oldPassWord.Text = "";
                    newPassWord.Text = "";
                    confirm.Text     = "";
                }
            }
            else
            {
                MessageBox.Show("该用户不存在!");
            }
        }