public static Boolean GetState(StudentProp std) { if (std.Subjects.Adbms < 35 || std.Subjects.Se < 35 || std.Subjects.Ns < 35 || std.Subjects.Mc < 35 || std.Subjects.An < 35) { return(true); } else { return(false); } }
private void mBtn_Click(object sender, EventArgs e) { Boolean isUserExist = false; if (File.Exists(MainWindow.FilePath)) { using (StreamReader reader = new StreamReader(MainWindow.FilePath)) { string json = reader.ReadToEnd(); List <StudentProp> readObject = JsonConvert.DeserializeObject <List <StudentProp> >(json); foreach (StudentProp pr in readObject) { if (pr.Rollno == rollno) { isUserExist = true; } } } } if (isUserExist == false) { String name = mName.Text; String cls = mClass.Text; String sem = mSem.Text; int adbms; if (!int.TryParse(mAdbms.Text, out adbms)) { MetroMessageBox.Show(this, "ADBMS mark in not valid format"); } int ns; if (!int.TryParse(mNs.Text, out ns)) { MetroMessageBox.Show(this, "NS mark in not valid format"); } int mc; if (!int.TryParse(mMc.Text, out mc)) { MetroMessageBox.Show(this, "MC mark in not valid format"); } int an; if (!int.TryParse(mAn.Text, out an)) { MetroMessageBox.Show(this, "AN mark in not valid format"); } int se; if (!int.TryParse(mSe.Text, out se)) { MetroMessageBox.Show(this, "SE mark in not valid format"); } StudentProp data = new StudentProp(); data.Rollno = rollno; data.Name = name; data.Cls = cls; data.Sem = sem; data.Subjects = new SubProp() { Adbms = adbms, An = an, Mc = mc, Ns = ns, Se = se, Total = (adbms + an + mc + ns + se), Percentage = (adbms + an + mc + ns + se) / 5 }; list.Add(data); File.WriteAllText(MainWindow.FilePath, JsonConvert.SerializeObject(list)); ResetValue(); rollno++; mRNo.Text = rollno.ToString(); } else { MetroMessageBox.Show(this, "User already exist with this roll number!"); } }
public void EnbleLayout(StudentProp std, int flag) { if (flag == 1) { lblName.Visible = true; lblCls.Visible = true; lblSem.Visible = true; lblAdbms.Visible = true; lblAn.Visible = true; lblMc.Visible = true; lblSe.Visible = true; lblNs.Visible = true; mName.Visible = true; mName.Text = std.Name; mClass.Visible = true; mClass.Text = std.Cls; mSem.Visible = true; mSem.Text = std.Sem; mAdbms.Visible = true; mAdbms.Text = std.Subjects.Adbms.ToString(); mAn.Visible = true; mAn.Text = std.Subjects.An.ToString(); mMc.Visible = true; mMc.Text = std.Subjects.Mc.ToString(); mSe.Visible = true; mSe.Text = std.Subjects.Se.ToString(); mNs.Visible = true; mNs.Text = std.Subjects.Ns.ToString(); mBtn.Visible = true; mBtn.Click += MBtn_Click; } else if (flag == 2) { lblName.Visible = false; lblCls.Visible = false; lblSem.Visible = false; lblAdbms.Visible = false; lblAn.Visible = false; lblMc.Visible = false; lblSe.Visible = false; lblNs.Visible = false; mName.Visible = false; mClass.Visible = false; mSem.Visible = false; mAdbms.Visible = false; mAn.Visible = false; mMc.Visible = false; mSe.Visible = false; mNs.Visible = false; mBtn.Visible = false; } }