コード例 #1
0
        private void myBottun1_Click(object sender, EventArgs e)
        {
            string         strBarcod = "";
            ConnectionToDB cnn       = new ConnectionToDB();
            DataTable      dtChar    = cnn.GetDataTable("select barcode from beneficiary where swid=1827 ");
            string         str       = dtChar.Rows[0][0].ToString();

            str = str.Substring(str.Length - 1);
            int icheck = 0;

            dtChar.Clear();
            dtChar = cnn.GetDataTable("select swid, barcode from beneficiary");
            try
            {
                for (int i = 0; i < dtChar.Rows.Count; i++)
                {
                    if (dtChar.Rows[i]["barcode"].ToString() != "")
                    {
                        if (dtChar.Rows[i]["barcode"].ToString().Substring(dtChar.Rows[i]["barcode"].ToString().Length - 1) == str)
                        {
                            icheck = cnn.TranDataToDB("update beneficiary set barcode='" + dtChar.Rows[i]["barcode"].ToString().Replace(str, "") + "' where swid=" + dtChar.Rows[i]["swid"].ToString());
                        }
                    }
                }
            }
            catch (Exception)
            {
                string strtes = strBarcod;
            }

            cnn.glb_commitTransaction();
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: Wasim77500/Erp
        private void rblogout_Click(object sender, EventArgs e)
        {
            lblUserLable.Text = "";

            ConnectionToDB cnn    = new ConnectionToDB();
            int            icheck = cnn.TranDataToDB("update USER_LOGS set USER_LOGS.logoff_date=sysdate" +
                                                     " where USER_LOGS.user_id = " + glb_function.glb_strUserId +
                                                     " and USER_LOGS.logoff_date is null   ");

            cnn.glb_commitTransaction();
            glb_function.glb_strUserName = "";
            InitialLogin();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Wasim77500/Erp
        private void myBottun1_Click(object sender, EventArgs e)
        {
            ConnectionToDB cnn = new ConnectionToDB();

            if (txtItemSwid.Text == "")
            {
                if (txtItemNo.Text == "")
                {
                    glb_function.MsgBox("الرجاء ادخال رقم القطعة");
                    return;
                }
                DataTable dt = cnn.GetDataTable("select swid from items where item_no='" + txtItemNo.Text + "'");
                if (dt == null || dt.Rows.Count <= 0)
                {
                    glb_function.MsgBox("No data");
                    return;
                }
                else if (dt.Rows.Count > 1)
                {
                    glb_function.MsgBox("more than One Item");
                    txtItemSwid.Text = dt.Rows[0][0].ToString();
                    //  return;
                }
                else
                {
                    return;
                }
            }

            int icheck = cnn.TranDataToDB("delete from ITEM_UNITS where item_id=" + txtItemSwid.Text);

            if (icheck < 0)
            {
                glb_function.MsgBox("Error in item units");
                return;
            }


            // icheck = cnn.TranDataToDB("delete from PROPERTY_ITEM where item_id=" + txtItemSwid.Text);

            //if (icheck < 0)
            //{
            //    glb_function.MsgBox("Error in item PROPERTY");
            //    cnn.glb_RollbackTransaction();
            //    return;
            //}


            icheck = cnn.TranDataToDB("delete from PROPERTY_ITEM where item_id=" + txtItemSwid.Text);

            if (icheck < 0)
            {
                glb_function.MsgBox("Error in item PROPERTY");
                cnn.glb_RollbackTransaction();
                return;
            }

            icheck = cnn.TranDataToDB("delete from PACK_ITEM where itemid=" + txtItemSwid.Text);

            if (icheck < 0)
            {
                glb_function.MsgBox("Error in item Package");
                cnn.glb_RollbackTransaction();
                return;
            }

            icheck = cnn.TranDataToDB("delete from items where swid=" + txtItemSwid.Text);

            if (icheck <= 0)
            {
                glb_function.MsgBox("Error in items");
                cnn.glb_RollbackTransaction();
                return;
            }


            cnn.glb_commitTransaction();

            glb_function.MsgBox("Deleted");
        }
コード例 #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            // CnnDB  cnn = new CnnDB();
            ConnectionToDB cnn     = new ConnectionToDB();
            DataTable      dtLogin = cnn.GetDataTable("select swid,STAT,USER_LOGIN,USER_NAME,USER_BRANCH,(select branch_aname from  branches where swid=nvl(USER_BRANCH,0)) BranchName,access_type,dept_id,(select d.dept_aname from departements d where d.swid=dept_id) dept_name,to_char(sysdate,'dd/mm/yyyy')  TodayDate from USERINFO " +
                                                      " where USER_LOGIN=N'" + txtUserid.Text.Trim().Replace("'", "").Trim() + "' and USER_PASSWORD='******'");

            if (dtLogin != null && dtLogin.Rows.Count != 0)
            {
                #region test
                // frmMain f = (frmMain)Application.OpenForms["frmMain"];
                //new glb_function(). LoginMethod(txtUserid.Text);
                #endregion


                if (dtLogin.Rows[0]["stat"].ToString() == "غير فعال")
                {
                    glb_function.MsgBox("المستخدم غير فعال", "رسالة نظام");
                    return;
                }
                string    userip    = glb_function.GetLocalIPAddress();
                DataTable dtUserAcc = new DataTable();
                // 1التاكد من ان المستخدم لديه الحق في الدخول من هذا الجهاز
                string str = dtLogin.Rows[0]["access_type"].ToString();
                if (dtLogin.Rows[0]["access_type"].ToString() != "كل")
                {
                    dtUserAcc = cnn.GetDataTable("select swid from USER_COMPUTERS t " +
                                                 " where t.userid =" + dtLogin.Rows[0]["swid"].ToString() + " and (device_code = '" + glb_function.GetProcessorId() + "' or '" + userip + "' like t.device_code || '%' ) ");

                    if (dtUserAcc == null || dtUserAcc.Rows.Count <= 0)
                    {
                        glb_function.MsgBox("ليس لديك صلاحية للدخول من هذا الجهاز");
                        return;
                    }
                }



                //1*******************************************************

                //2التاكد ان المستخدم داخل من جهاز ثاني
                dtUserAcc.Rows.Clear();

                dtUserAcc = cnn.GetDataTable("select swid,ip from USER_LOGS where user_id=" + dtLogin.Rows[0]["swid"].ToString() + " and (logoff_date ='' or logoff_date is null)");
                if (dtUserAcc.Rows.Count >= 1)
                {
                    IPAddress ip = IPAddress.Parse(dtUserAcc.Rows[0]["ip"].ToString());
                    if (dtUserAcc.Rows[0]["ip"].ToString() != glb_function.GetLocalIPAddress())
                    {
                        if (glb_function.MsgBox("هذا المستخدم مسجل بجهاز اخر هل تريد الخروج منه والتسجيل من هذا الجهاز", "", true))
                        {
                            // glb_function.  SendMessage("<log off user >" +txtUserid.Text.Trim(), ip);
                        }
                        else
                        {
                            return;
                        }
                    }
                    int icheck1 = cnn.TranDataToDB("update USER_LOGS set logoff_date= sysdate where user_id=" + dtLogin.Rows[0]["swid"].ToString() + " and (logoff_date ='' or logoff_date is null)");
                    if (icheck1 <= 0)
                    {
                        glb_function.MsgBox("حدث خطأ ");
                        return;
                    }
                    cnn.glb_commitTransaction();
                }
                //2********************************

                //3 فحص هل المستخدم تغير ام لا
                if (glb_function.glb_strUserLogin != txtUserid.Text)
                {
                    //OpenForms f = new Application.OpenForms();

                    for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
                    {
                        if (((Form)(Application.OpenForms[i])).Name != "frmMain" && Application.OpenForms[i].Name != "frmLogin")
                        {
                            Application.OpenForms[i].Close();
                        }
                    }
                }


                //3***************************
                //4 إنشاء بيانات الدخول وفتح جلسة للمستخدم

                int icheck = cnn.TranDataToDB("insert into USER_LOGS values((select nvl(max(swid),0)+1 from USER_LOGS)," + dtLogin.Rows[0]["swid"].ToString() + ",sys_context('USERENV','SID'),sys_context('USERENV','HOST'),sysdate,null,'" + userip + "')");
                if (icheck <= 0)
                {
                    glb_function.MsgBox("حدث خطأ اثناء تسجيل بيانات الدخول");
                    return;
                }
                cnn.glb_commitTransaction();
                //4***************************************
                glb_function.glb_strUserId    = dtLogin.Rows[0]["swid"].ToString();
                glb_function.glb_strUserLogin = dtLogin.Rows[0]["USER_LOGIN"].ToString();
                glb_function.glb_strUserName  = dtLogin.Rows[0]["USER_NAME"].ToString();
                glb_function.glb_BranchNo     = Convert.ToInt16(dtLogin.Rows[0]["USER_BRANCH"].ToString());
                glb_function.glb_BranchName   = dtLogin.Rows[0]["BranchName"].ToString();
                glb_function.glb_deptId       = Convert.ToInt16(dtLogin.Rows[0]["dept_id"].ToString());
                glb_function.glb_DeptName     = dtLogin.Rows[0]["dept_name"].ToString();
                glb_function.dtSysdate        = DateTime.ParseExact(dtLogin.Rows[0]["TodayDate"].ToString(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

                //***************
                DataTable dtMainCurr = cnn.GetDataTable("select swid,curr_name,curr_decimal from currency c where c.is_main_curr = '1'");

                if (dtMainCurr == null || dtMainCurr.Rows.Count <= 0)
                {
                    glb_function.MsgBox("لايوجد عملة رئيسية للنظام");
                    //   SOWAID.frmCurrency frm = new frmCurrency();
                    //frm.FormClosed += Frm_FormClosed;
                    //frm.ShowDialog();
                }
                else
                {
                    glb_function.glb_MainCurrencyId  = Convert.ToInt16(dtMainCurr.Rows[0]["swid"].ToString());
                    glb_function.glbMainCurrencyName = dtMainCurr.Rows[0]["curr_name"].ToString();
                    glb_function.glbMainDecimalPoint = Convert.ToInt16(dtMainCurr.Rows[0]["curr_decimal"].ToString());
                }

                //*****************
            }
            else
            {
                glb_function.MsgBox("كلمة السر او اسم المستخدم غير صحيحة", "تنبية");
                return;
            }



            //DataTable dtSession = cnn.GetDataTable("select sys_context('USERENV', 'SID') from dual ");
            //MessageBox.Show(dtSession.Rows[0][0].ToString());


            this.Close();
        }