示例#1
0
文件: frmMain.cs 项目: Wasim77500/Erp
        private void btnJournal_Click(object sender, EventArgs e)
        {
            ConnectionToDB cnn      = new ConnectionToDB();
            DataTable      dtDifFir = cnn.GetDataTable("select swid,acc_no,acc_name from accounts where system_acc_type='فرق كسر'");

            if (dtDifFir == null || dtDifFir.Rows.Count <= 0)
            {
                glb_function.MsgBox("لايوجد حساب لفرق الكسر");
            }
            else
            {
                Accounts.frmJournal frm = new Accounts.frmJournal();
                glb_function.OpenForm(this, frm, false);
                // new Account.frmJournal().Show(this);
            }
        }
示例#2
0
        public static void   FillListWithId(ref myList lstBranch, string strTable, string strCol)
        {
            ConnectionToDB conn = new ConnectionToDB();
            DataTable      MyDataTable;

            //myList lstBranch = new myList();
            MyDataTable = conn.GetDataTable("Select  SWID," + strCol + " From  " + strTable + "  order by " + strCol + "");
            if (MyDataTable != null)
            {
                lstBranch.DataSource = MyDataTable;

                lstBranch.ValueMember   = "SWID";
                lstBranch.DisplayMember = strCol;

                lstBranch.SelectedIndex = -1;
            }
        }
示例#3
0
        public static void FillList(ref myList lstRequired, string strTable, string strCol)
        {
            ConnectionToDB conn = new ConnectionToDB();
            DataTable      MyDataTable;

            //myList lstBranch = new myList();
            MyDataTable = conn.GetDataTable("Select  distinct " + strCol + " From  " + strTable + "  order by 1");
            if (MyDataTable != null)
            {
                lstRequired.DataSource = MyDataTable;


                lstRequired.DisplayMember = strCol;

                lstRequired.SelectedIndex = -1;
            }
        }
示例#4
0
        public static decimal GetAccBalance(string Currid, string accId)
        {
            //تستخدم لمعرفة رصيد حساب معين
            ConnectionToDB cnn      = new ConnectionToDB();
            DataTable      dtGetAcc = cnn.GetDataTable("select nvl( sum(jd.jour_value),0) from journal_header jh join journal_details jd on(jh.swid=jd.jour_id) " +
                                                       " where jd.curr_id =" + Currid +
                                                       " and jd.acc_id = " + accId + " and jd.stat <> 'ملغي' and jh.stat <> 'ملغي'");
            decimal balance = 0;

            if (dtGetAcc == null || dtGetAcc.Rows.Count <= 0)
            {
                balance = 0;
            }
            else
            {
                balance = Convert.ToDecimal(dtGetAcc.Rows[0][0].ToString());
            }

            return(balance);
        }
示例#5
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");
        }
示例#6
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();
        }
示例#7
0
        private void lstTemplet_SelectedIndexChanged(object sender, EventArgs e)
        {
            new glb_function().clearItems(this);

            if (lstTemplet.SelectedValue == null)
            {
                return;
            }

            if (lstTemplet.SelectedValue.ToString() != "System.Data.DataRowView" && lstTemplet.SelectedValue.ToString() != "")
            {
                string strStat = "select h.swid,h.form_eng_name,h.form_type ,d.control_type,d.en_name,d.real_value,d.ar_name,multi_form_for_user " +
                                 " from templet_header h,templet_details d" +
                                 "  where h.swid = d.temp_header_id" +
                                 "  and h.swid = " + lstTemplet.SelectedValue.ToString();

                ConnectionToDB cnn = new ConnectionToDB();
                dtPri = cnn.GetDataTable(strStat);

                if (dtPri.Rows[0]["multi_form_for_user"].ToString() == "1")
                {
                    lstTemplet.Visible = true;
                    lblTemplet.Visible = true;
                }


                for (int i = 0; i < dtPri.Rows.Count; i++)
                {
                    if (dtPri.Rows[i]["control_type"].ToString() == "Visability")
                    {
                        if (dtPri.Rows[i]["real_value"].ToString() == "1")
                        {
                            Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                            if (ctr != null)
                            {
                                ctr.Visible = true;
                            }
                        }

                        else
                        {
                            Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                            if (ctr != null)
                            {
                                ctr.Visible = false;
                            }
                        }
                    }
                    else if (dtPri.Rows[i]["control_type"].ToString() == "Enability")
                    {
                        if (dtPri.Rows[i]["real_value"].ToString() == "1")
                        {
                            Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                            if (ctr != null)
                            {
                                ctr.Enabled = true;
                            }
                            //string strss = dtPri.Rows[i]["en_name"].ToString();
                            //this.Controls[dtPri.Rows[i]["en_name"].ToString()].Enabled = true;
                        }

                        else
                        {
                            Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                            if (ctr != null)
                            {
                                ctr.Enabled = false;
                            }
                        }
                    }
                    else if (dtPri.Rows[i]["control_type"].ToString() == "List" || dtPri.Rows[i]["control_type"].ToString() == "Text" || dtPri.Rows[i]["control_type"].ToString() == "MultiChoices" || dtPri.Rows[i]["control_type"].ToString() == "Free MultiChoices" || dtPri.Rows[i]["control_type"].ToString() == "Free List")
                    {
                        //if (dtPri.Rows[i]["ar_name"].ToString() == "الفروع" || dtPri.Rows[i]["ar_name"].ToString() == "الفرع")
                        //{
                        //    // (GetControlByName(this, dtPri.Rows[i]["en_name"].ToString())).Text = dtPri.Rows[i]["real_value"].ToString();
                        //    Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                        //    if (ctr != null)
                        //        ctr.Text = dtPri.Rows[i]["real_value"].ToString();
                        //}
                        //else if (dtPri.Rows[i]["ar_name"].ToString() == "الاقسام" || dtPri.Rows[i]["ar_name"].ToString() == "القسم")
                        //{
                        //    // (GetControlByName(this, dtPri.Rows[i]["en_name"].ToString())).Text = dtPri.Rows[i]["real_value"].ToString();
                        Control ctr = GetControlByName(this, dtPri.Rows[i]["en_name"].ToString());
                        if (ctr != null)
                        {
                            ctr.Text = dtPri.Rows[i]["real_value"].ToString();
                        }
                        //}
                    }
                }



                lstTemplet_MorePrivilleges(sender, e);
            }
        }
示例#8
0
        public static bool MultiTransData()
        {
            if (arrInsertLogs.Count == 0)
            {
                MsgBox("Error saving MultiTransData");
                return(false);
            }

            int            iTransCount = arrInsertLogs.Count;
            ConnectionToDB cnn         = new ConnectionToDB();

            ConnectionToDB.objCmd = new Oracle.ManagedDataAccess.Client.OracleCommand();


            string    strResult = "";
            DataTable dt        = new DataTable();

            dt.Columns.Add("sqlstcol");

            foreach (var item in glb_function.arrInsertLogs)
            {
                DataRow dRow = dt.NewRow();
                string  str  = item.ToString();

                dRow[0] = str;

                dt.Rows.Add(dRow);
            }



            dt.TableName = "sqlsttab";
            System.IO.StringWriter writer = new System.IO.StringWriter();
            dt.WriteXml(writer);
            string strDataAsXML = writer.ToString();



            string str1 = strDataAsXML.Length.ToString();

            ConnectionToDB.objCmd.Parameters.Add("mytab", Oracle.ManagedDataAccess.Client.OracleDbType.Clob).Value = strDataAsXML;

            ConnectionToDB.objCmd.Parameters.Add("ExcutSqlStCout", Oracle.ManagedDataAccess.Client.OracleDbType.Varchar2, 2000).Direction = ParameterDirection.Output;
            strResult = cnn.ExecutePro("GeneralTrans.ExcuteSqlSt", "ExcutSqlStCout");



            arrInsertLogs.Clear();
            if (iTransCount.ToString() == strResult.Trim())
            {
                cnn.glb_commitTransaction();
                glb_function.MsgBox("تمت العملية بنجاح");

                return(true);
            }
            else
            {
                cnn.glb_RollbackTransaction();
                glb_function.MsgBox("حدث خطأ اثناء العملية");
                return(false);
            }
        }
示例#9
0
文件: frmMain.cs 项目: Wasim77500/Erp
        private void InitialLogin()
        {
            ConnectionToDB myconn = new ConnectionToDB();
            DataTable      MyDataTable;

            MyDataTable = myconn.GetDataTable("select Instance_name From sys.V_$INSTANCE");

            this.Text = this.Text + " @ " + MyDataTable.Rows[0][0].ToString();

            foreach (RibbonTab ribonTab in sowaidribbon.Tabs)
            {
                ribonTab.Visible = false;
            }

            //***************888

            Rectangle rect = Screen.FromHandle(this.Handle).WorkingArea;

            rect.Location        = new Point(0, 0);
            this.MaximizedBounds = rect;
            this.WindowState     = FormWindowState.Maximized;
            Theme.ColorTable     = new sowaidRibbonRendererColorTableBlack();
            //***********
            //pnlToolBar.Width = splitContainer2.Width / 3 * 2;
            //pnlToolBar.Left = splitContainer2.Width - pnlToolBar.Width;
            //pnlToolBar.Height = splitContainer2.Panel1.Height;
            //pnlToolBar.Top = 0;
            splitContainer2.SplitterWidth    = 1;
            splitContainer2.SplitterDistance = sowaidribbon.Height;


            // pbxSowaidLogo.Height = splitContainer2.Panel1.Height + 10;
            pbxLogo.Left = 0;
            pbxLogo.Top  = 27;


            //tmrCurrentTime.Start();
            // lblUserLable.Text = "اسم المستخدم : .....";
            //glb_function.glb_strUserName = "";
            // lblUserLable.Left = pnlRight.Width / 2 - lblUserLable.Width / 2;
            RemoveUserToolIcons();



            frmLogin myform = new frmLogin();

            myform.ShowDialog(this);



            //if (glb_function.glb_strUserName == "")
            //{
            //    this.Close();
            //    return;
            //}

            lblUserLable.Text = "     " + glb_function.glb_strUserName;
            // lblUserLable.Left = pbxLogout.Left + lblUserLable.Width -50;
            //lblUserLable.Top = pbxLogout.Top;


            ConnectionToDB cnn = new ConnectionToDB();

            //dtUserForm = cnn.GetDataTable("select p.swid,m.form_name,m.form_type from models_file m " +
            //      "   join privilege_file p on(m.swid = p.model_no and user_no = " + glb_function.glb_strUserId + ")" +
            //         "   union all" +
            //          "  select p.swid, m.form_name, m.form_type from models_account m" +
            //           " join privilege_account p on (m.swid = p.model_no and user_no = " + glb_function.glb_strUserId + ")" +
            //            "   union all" +
            //            " select p.swid,m.form_name,m.form_type from MODELS_CHARITIES m " +
            //      "   join PRIVILEGE_CHARITIES p on(m.swid = p.model_no and user_no = " + glb_function.glb_strUserId + ")" +
            //           "");

            dtUserForm = cnn.GetDataTable("select u.swid,m.form_name,m.form_eng_name,m.form_type from templet_header m,user_templet u " +
                                          " where m.swid = u.templet_id and u.user_id= " + glb_function.glb_strUserId);
            CreateToolIcons(this);
        }